Merge branch 'master' of github.com:vscosta/yap-6.3
This commit is contained in:
commit
12f93e10d3
@ -132,7 +132,7 @@ else()
|
|||||||
if (WIN32)
|
if (WIN32)
|
||||||
List (APPEND YLIBS $<TARGET_OBJECTS:YAP++> )
|
List (APPEND YLIBS $<TARGET_OBJECTS:YAP++> )
|
||||||
if (WITH_PYTHON )
|
if (WITH_PYTHON )
|
||||||
List (APPEND YLIBS $<TARGET_OBJECTS:Obj4Py> )
|
List (APPEND YLIBS $<TARGET_OBJECTS:Py4YAP> )
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -254,6 +254,7 @@ class X_API YAPPrologPredicate : public YAPPredicate {
|
|||||||
public:
|
public:
|
||||||
YAPPrologPredicate(YAPTerm t) : YAPPredicate(t){};
|
YAPPrologPredicate(YAPTerm t) : YAPPredicate(t){};
|
||||||
YAPPrologPredicate(const char *s, arity_t arity) : YAPPredicate(s, arity){};
|
YAPPrologPredicate(const char *s, arity_t arity) : YAPPredicate(s, arity){};
|
||||||
|
YAPPrologPredicate(YAPAtom s, arity_t arity) : YAPPredicate(s, arity){};
|
||||||
/// add a new clause
|
/// add a new clause
|
||||||
bool assertClause(YAPTerm clause, bool last = true,
|
bool assertClause(YAPTerm clause, bool last = true,
|
||||||
YAPTerm source = YAPTerm());
|
YAPTerm source = YAPTerm());
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
set (Python_ADDITIONAL_VERSIONS 3.7 3.6 3.5 3.6 3.4 )
|
set (Python_ADDITIONAL_VERSIONS 3.7 3.6 ) #3.5 3.6 3.4 )
|
||||||
|
|
||||||
|
|
||||||
# PYTHONLIBS_FOUND - have the Python libs been found
|
# PYTHONLIBS_FOUND - have the Python libs been found
|
||||||
@ -9,9 +9,9 @@ set (Python_ADDITIONAL_VERSIONS 3.7 3.6 3.5 3.6 3.4 )
|
|||||||
# PYTHONLIBS_VERSION_STRING - version of the Python libs found (since CMake 2.8.8)
|
# PYTHONLIBS_VERSION_STRING - version of the Python libs found (since CMake 2.8.8)
|
||||||
##
|
##
|
||||||
#
|
#
|
||||||
if (WIN32)
|
if (WIN320)
|
||||||
set (PYTHONLIBS_FOUND YES CACHE BOOL "MINGW/MSYS2" FORCE )
|
set (PYTHONLIBS_FOUND YES CACHE BOOL "MINGW/MSYS2" FORCE )
|
||||||
set (PYTHON_LIBRARY C:/msys64/mingw64/lib/libpython3.5m.dll.a CACHE FILEPATH "MINGW/MSYS2" FORCE )
|
set (PYTHON_LIBRARY C:/msys64/mingw64/lib/libpython3.6m.dll.a CACHE FILEPATH "MINGW/MSYS2" FORCE )
|
||||||
set (PYTHON_LIBRARIES C:/msys64/mingw64/lib/libpython3.5m.dll.a CACHE FILEPATH "MINGW/MSYS2" FORCE )
|
set (PYTHON_LIBRARIES C:/msys64/mingw64/lib/libpython3.5m.dll.a CACHE FILEPATH "MINGW/MSYS2" FORCE )
|
||||||
set (PYTHON_INCLUDE_PATH C:/msys64/mingw64/include/python3.5m CACHE PATH "MINGW/MSYS2" FORCE )
|
set (PYTHON_INCLUDE_PATH C:/msys64/mingw64/include/python3.5m CACHE PATH "MINGW/MSYS2" FORCE )
|
||||||
set (PYTHON_INCLUDE_DIRS C:/msys64/mingw64/include/python3.5m CACHE PATH "MINGW/MSYS2" FORCE )
|
set (PYTHON_INCLUDE_DIRS C:/msys64/mingw64/include/python3.5m CACHE PATH "MINGW/MSYS2" FORCE )
|
||||||
|
@ -150,19 +150,19 @@ PyObject *term_to_python(term_t t, bool eval, PyObject *o) {
|
|||||||
out = PyList_New(len);
|
out = PyList_New(len);
|
||||||
if (!out) {
|
if (!out) {
|
||||||
PL_reset_term_refs(tail);
|
PL_reset_term_refs(tail);
|
||||||
return CHECKNULL(t, Py_None);
|
YAPPy_ThrowError(SYSTEM_ERROR_INTERNAL, t, "list->python");
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < len; i++) {
|
for (i = 0; i < len; i++) {
|
||||||
if (!PL_get_list(t, arg, t)) {
|
if (!PL_get_list(t, arg, t)) {
|
||||||
PL_reset_term_refs(tail);
|
PL_reset_term_refs(tail);
|
||||||
return Py_None;
|
YAPPy_ThrowError(SYSTEM_ERROR_INTERNAL, t, "list->python");
|
||||||
}
|
}
|
||||||
a = term_to_python(arg, eval, o);
|
a = term_to_python(arg, eval, o);
|
||||||
if (a) {
|
if (a) {
|
||||||
if (PyList_SetItem(out, i, a) < 0) {
|
if (PyList_SetItem(out, i, a) < 0) {
|
||||||
PL_reset_term_refs(tail);
|
PL_reset_term_refs(tail);
|
||||||
return Py_None;
|
YAPPy_ThrowError(SYSTEM_ERROR_INTERNAL, t, "list->python");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -170,11 +170,33 @@ PyObject *term_to_python(term_t t, bool eval, PyObject *o) {
|
|||||||
return CHECKNULL(t, out);
|
return CHECKNULL(t, out);
|
||||||
} else {
|
} else {
|
||||||
functor_t fun;
|
functor_t fun;
|
||||||
|
atom_t name;
|
||||||
|
int arity;
|
||||||
PyObject *rc;
|
PyObject *rc;
|
||||||
|
|
||||||
if (!PL_get_functor(t, &fun)) {
|
if (!PL_get_functor(t, &fun)) {
|
||||||
PL_reset_term_refs(tail);
|
PL_reset_term_refs(tail);
|
||||||
return CHECKNULL(t, Py_None);
|
YAPPy_ThrowError(SYSTEM_ERROR_INTERNAL, t, "list->python");
|
||||||
|
}
|
||||||
|
AOK(PL_get_name_arity(t, &name, &arity), NULL);
|
||||||
|
if (name == ATOM_t) {
|
||||||
|
int i;
|
||||||
|
rc = PyTuple_New(arity);
|
||||||
|
for (i = 0; i < len; i++) {
|
||||||
|
term_t arg = PL_new_term_ref();
|
||||||
|
if (!PL_get_arg(i+1, t, arg)) {
|
||||||
|
PL_reset_term_refs(arg);
|
||||||
|
YAPPy_ThrowError(SYSTEM_ERROR_INTERNAL, t, "t(...)->python");
|
||||||
|
}
|
||||||
|
PyObject *a = term_to_python(arg, eval, o);
|
||||||
|
if (a) {
|
||||||
|
if (PyTuple_SetItem(rc, i, a) < 0) {
|
||||||
|
PL_reset_term_refs(arg);
|
||||||
|
YAPPy_ThrowError(SYSTEM_ERROR_INTERNAL, t, "t(...)->python");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
PL_reset_term_refs(arg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (eval)
|
if (eval)
|
||||||
rc = compound_to_pyeval(t, o);
|
rc = compound_to_pyeval(t, o);
|
||||||
@ -185,7 +207,7 @@ PyObject *term_to_python(term_t t, bool eval, PyObject *o) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return CHECKNULL(t, Py_None);
|
return Py_None;
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *yap_to_python(YAP_Term t, bool eval, PyObject *o) {
|
PyObject *yap_to_python(YAP_Term t, bool eval, PyObject *o) {
|
||||||
@ -209,3 +231,7 @@ PyObject *deref_term_to_python(term_t t) {
|
|||||||
}
|
}
|
||||||
return term_to_python(t, false, NULL);
|
return term_to_python(t, false, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void YAPPy_ThrowError__(const char *file, const char *function, int lineno,
|
||||||
|
yap_error_number type, term_t where, ...);
|
||||||
|
@ -698,7 +698,7 @@ static PyObject *structseq_repr(PyObject *iobj) {
|
|||||||
|
|
||||||
PyObject *term_to_nametuple(const char *s, arity_t arity, PyObject *tuple) {
|
PyObject *term_to_nametuple(const char *s, arity_t arity, PyObject *tuple) {
|
||||||
PyObject *o;
|
PyObject *o;
|
||||||
#if PY_MAJOR_VERSION >= 30
|
#if PY_MAJOR_VERSION >= 3
|
||||||
PyTypeObject *typp;
|
PyTypeObject *typp;
|
||||||
PyObject *key = PyUnicode_FromString(s);
|
PyObject *key = PyUnicode_FromString(s);
|
||||||
if (py_F2P && PyDict_Contains(py_F2P, key)) {
|
if (py_F2P && PyDict_Contains(py_F2P, key)) {
|
||||||
@ -729,7 +729,6 @@ PyObject *term_to_nametuple(const char *s, arity_t arity, PyObject *tuple) {
|
|||||||
}
|
}
|
||||||
o = PyStructSequence_New(typp);
|
o = PyStructSequence_New(typp);
|
||||||
Py_INCREF(typp);
|
Py_INCREF(typp);
|
||||||
fprintf(stderr, "<<< %p\n",typp);
|
|
||||||
arity_t i;
|
arity_t i;
|
||||||
for (i = 0; i < arity; i++) {
|
for (i = 0; i < arity; i++) {
|
||||||
PyObject *pArg = PyTuple_GET_ITEM(tuple, i);
|
PyObject *pArg = PyTuple_GET_ITEM(tuple, i);
|
||||||
|
@ -24,9 +24,7 @@ SET_SOURCE_FILES_PROPERTIES(../../swig/yap.i PROPERTIES SWIG_MODULE_NAME yap)
|
|||||||
|
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
|
|
||||||
set (SYS_DLLS ${GMP_LIBRARIES})
|
set (SYS_DLLS ${GMP_LIBRARIES} c:/msys64/mingw64/bin/libgmp-10.dll)
|
||||||
|
|
||||||
set (SYS_DLLS c:/msys64/mingw64/bin/libgmp-10.dll)
|
|
||||||
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
See:
|
See:
|
||||||
https://packaging.python.org/en/latest/distributing.html
|
https://packaging.python.org/en/latest/distributing.html
|
||||||
https://github.com/pypa/sampleproject
|
https://github.com/pypa/sampleproject
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Always prefer setuptools over distutils
|
# Always prefer setuptools over distutils
|
||||||
|
@ -789,4 +789,4 @@ module_state :-
|
|||||||
fail.
|
fail.
|
||||||
module_state.
|
module_state.
|
||||||
|
|
||||||
// @}
|
%% @}
|
Reference in New Issue
Block a user