diff options
author | John Ankarström <john@ankarstrom.se> | 2022-08-04 16:26:27 +0200 |
---|---|---|
committer | John Ankarström <john@ankarstrom.se> | 2022-08-04 17:25:01 +0200 |
commit | 2ac7d06a503b256b290678f5bba158bf7d219bdd (patch) | |
tree | 86abdf303f8a3059efbd040c6eae95accf5b432c /c/pl.h | |
parent | 407b6cab4093b3c0ee23412ac07cf83fd9f03b82 (diff) | |
download | EpisodeBrowser-2ac7d06a503b256b290678f5bba158bf7d219bdd.tar.gz |
Add comments.
Diffstat (limited to 'c/pl.h')
-rw-r--r-- | c/pl.h | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -7,19 +7,23 @@ #include "wcharptr.h" +/* Convert Prolog term to wide characters. */ WcharPtr PlString(const term_t t, const int flags = CVT_WRITE); +/* Wrapper for opening and closing Prolog foreign frames. */ struct Frame { Frame(); ~Frame(); void Close(); + /* Close foreign frame AND invalidate associated data. */ void Discard(); void Rewind(); private: fid_t m_f; }; +/* Wrapper for marking and releasing strings on the Prolog stack. */ struct Mark { Mark(); @@ -28,12 +32,14 @@ private: buf_mark_t m_m; }; +/* Wrapper for opening, solving and cutting Prolog query. */ struct Query { Query(module_t ctx, predicate_t p, term_t t0); ~Query(); int Cut(); int Cut(std::nothrow_t); + /* Cut query AND invalidate associated data. */ int Close(); int Close(std::nothrow_t); int NextSolution(); @@ -67,12 +73,13 @@ inline int PlGet(term_t t, long* x) { return PL_get_long(t, x); } inline int PlGet(term_t t, long long* x) { return PL_get_int64(t, x); } inline int PlGet(term_t t, atom_t* x) { return PL_get_atom(t, x); } inline int PlGet(term_t t, char** x) { return PL_get_atom_chars(t, x); } -inline int PlGet(term_t t, WcharPtr* x) { +inline int PlGet(term_t t, WcharPtr* x) +{ Mark m; char* s; if (!PlGet(t, &s)) return 0; *x = WcharPtr::FromNarrow(s); - return 1; /* or catch potential exception from BstrFromSz? */ + return 1; } /* Put in or get from a term reference an arbitrary number of values, |