improve C++ interface

This commit is contained in:
Vitor Santos Costa
2016-07-31 10:22:24 -05:00
parent be313a5b49
commit 460dfafcc8
6 changed files with 563 additions and 260 deletions

View File

@@ -1,10 +1,11 @@
#define YAP_CPP_INTERFACE 1
#include <gmpxx.h>
//! @{
//! @{
/**
*
* @defgroup yap-cplus-interface An object oriented interface for YAP.
@@ -65,6 +66,35 @@ extern "C" {
// taken from yap_structs.h
#include "iopreds.h"
#ifdef SWIGPYTHON
extern PyObject *term_to_python(yhandle_t t, bool eval);
extern PyObject *deref_term_to_python(yhandle_t t);
X_API bool init_python(void);
extern PyObject *py_Main;
extern inline PyObject *AtomToPy( const char *s)
{
if (strcmp(s, "true") == 0)
return Py_True;
if (strcmp(s, "false") == 0)
return Py_False;
if (strcmp(s, "none") == 0)
return Py_None;
if (strcmp(s, "[]") == 0)
return PyList_New(0);
else if (strcmp(s, "{}") == 0)
return PyDict_New();
/* return __main__,s */
else if (PyObject_HasAttrString(py_Main, s)) {
return PyObject_GetAttrString(py_Main, s);
}
// no way to translate
return NULL;
}
#endif
X_API void YAP_UserCPredicate(const char *, YAP_UserCPred, YAP_Arity arity);
/* void UserCPredicateWithArgs(const char *name, int *fn(), unsigned int arity) */
@@ -76,6 +106,8 @@ X_API void YAP_UserCPredicateWithArgs(const char *, YAP_UserCPred, YAP_Arity, YA
X_API Term Yap_StringToTerm(const char *s, size_t len, encoding_t *encp, int prio, Term *bindings_p);
}
class YAPEngine;