C-interface

This commit is contained in:
Vítor Santos Costa
2018-09-18 19:27:10 +01:00
parent 7661b8581c
commit a6e578090c
6 changed files with 36 additions and 22 deletions

View File

@@ -387,7 +387,7 @@ PyObject *term_to_python(term_t t, bool eval, PyObject *o, bool cvt) {
if (entry_to_dictionary(dict, yt, eval, cvt))
return dict;
else
return NULL;
return Py_None;
}
atom_t name;
int arity;
@@ -424,8 +424,8 @@ PyObject *term_to_python(term_t t, bool eval, PyObject *o, bool cvt) {
}
PyObject *yap_to_python(YAP_Term t, bool eval, PyObject *o, bool cvt) {
if (t == 0)
return NULL;
if (t == 0 || t == TermNone)
return Py_None;
term_t yt = YAP_InitSlot(t);
o = term_to_python(yt, eval, o, cvt);
PL_reset_term_refs(yt);

View File

@@ -55,8 +55,9 @@ static Term python_to_term__(PyObject *pVal) {
if (pVal == Py_None) {
// fputs("<<*** ",stderr);Yap_DebugPlWrite(YAP_GetFromSlot(t)); fputs("
// >>***\n",stderr);
return YAP_MkVarTerm();
//return YAP_MkVarTerm();
// fputs("<<*** ",stderr);Yap_DebugPlWrite(YAP_GetFromSlot(t)); fputs("
return MkAtomTerm(Yap_LookupAtom("none"));
// >>***\n",stderr);
} else if (PyBool_Check(pVal)) {
if(PyObject_IsTrue(pVal)) return TermTrue;

View File

@@ -238,15 +238,16 @@ static foreign_t python_string_to(term_t f) {
if (!PL_get_chars(f, &s, CVT_ALL | CVT_EXCEPTION | REP_UTF8)) {
pyErrorAndReturn(false);
}
if (!strcmp(s,"atom"))
if (!strcmp(s,"atom")) {
pyStringToString = false;
if (!strcmp(s,"string"))
return true;
}
if (!strcmp(s,"string")) {
pyStringToString = true;
else
return false;
return true;
return true;
}
}
return true;
return false;
}
static foreign_t python_builtin_eval(term_t caller, term_t dict, term_t out) {