support python interface.

This commit is contained in:
Vitor Santos Costa
2017-02-20 14:38:00 +00:00
parent 5d6ff87d19
commit b17f4967cb
8 changed files with 578 additions and 437 deletions

View File

@@ -5,8 +5,10 @@
#include <gmpxx.h>
#include <vector>
#include <string>
#include <iostream>
//! @{
//! @{
/**
*
* @defgroup yap-cplus-interface An object oriented interface for YAP.
@@ -67,38 +69,6 @@ extern "C" {
// taken from yap_structs.h
#include "iopreds.h"
#ifdef SWIGPYTHON
extern PyObject *yap_to_pythond(YAP_Term t, bool eval);
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 Term pythonToYAP(PyObject *p);
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;
}
X_API extern PyObject *yap_to_python(YAP_Term t, bool eval);
#endif
X_API void YAP_UserCPredicate(const char *, YAP_UserCPred, YAP_Arity arity);
/* void UserCPredicateWithArgs(const char *name, int *fn(), unsigned int arity)