diff options
Diffstat (limited to 'c')
-rw-r--r-- | c/datalistview.cpp | 1 | ||||
-rw-r--r-- | c/pl.cpp | 26 | ||||
-rw-r--r-- | c/pl.h | 12 |
3 files changed, 39 insertions, 0 deletions
diff --git a/c/datalistview.cpp b/c/datalistview.cpp index c83c65f..704b689 100644 --- a/c/datalistview.cpp +++ b/c/datalistview.cpp @@ -39,6 +39,7 @@ void DataListView::ShowEpisode(const int iEpisode) lviKey.mask = LVIF_TEXT; lviValue.mask = LVIF_TEXT; + Frame f; const term_t t = PL_new_term_refs(3); if (!PL_put_integer(t,iEpisode)) return; const qid_t q = PL_open_query(NULL, PL_Q_NORMAL, @@ -3,6 +3,31 @@ #include "pl.h" +Frame::Frame() +{ + m_f = PL_open_foreign_frame(); +} + +Frame::~Frame() +{ + PL_close_foreign_frame(m_f); +} + +void Frame::Close() +{ + PL_close_foreign_frame(m_f); +} + +void Frame::Discard() +{ + PL_discard_foreign_frame(m_f); +} + +void Frame::Rewind() +{ + PL_rewind_foreign_frame(m_f); +} + Query::Query(const module_t ctx, const predicate_t p, const term_t t0) { m_q = PL_open_query(ctx, PL_Q_CATCH_EXCEPTION, p, t0); @@ -50,6 +75,7 @@ int PL_get_tchars(const term_t t, TCHAR** const pTsz, const int iFlags) int Plx(const char* const szMod, const char* const szPred) { + Frame f; const term_t t = PL_new_term_refs(0); Query q(NULL, PL_predicate(szPred, 0, szMod), t); return q.NextSolution(); @@ -7,6 +7,17 @@ int PL_get_tchars(term_t t, TCHAR** pTsz, int iFlags); int Plx(const char* szMod, const char* szPred); +struct Frame +{ + Frame(); + ~Frame(); + void Close(); + void Discard(); + void Rewind(); +private: + fid_t m_f; +}; + struct Query { Query(module_t ctx, predicate_t p, term_t t0); @@ -65,6 +76,7 @@ int Countv(const int i, T, R... rest) { return Countv(i+1, rest...); } template <typename ...T> int Plx(const char* const szMod, const char* const szPred, T... args) { + Frame f; const int iArity = Countv(0, args...); const term_t t = PL_new_term_refs(iArity); if (!PlPutv(t, args...)) return 0; |