aboutsummaryrefslogtreecommitdiff
path: root/c/pl.h
diff options
context:
space:
mode:
Diffstat (limited to 'c/pl.h')
-rw-r--r--c/pl.h11
1 files changed, 9 insertions, 2 deletions
diff --git a/c/pl.h b/c/pl.h
index 5720eda..b0cdbbd 100644
--- a/c/pl.h
+++ b/c/pl.h
@@ -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,