2014-04-28 11:47:09 +01:00
|
|
|
|
2016-07-31 16:22:24 +01:00
|
|
|
|
2014-04-28 11:47:09 +01:00
|
|
|
#define YAP_CPP_INTERFACE 1
|
|
|
|
|
2016-04-12 16:22:53 +01:00
|
|
|
#include <gmpxx.h>
|
2016-09-21 20:41:23 +01:00
|
|
|
#include <vector>
|
2015-01-06 17:47:58 +00:00
|
|
|
|
2016-07-31 16:22:24 +01:00
|
|
|
//! @{
|
2014-05-04 22:31:22 +01:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @defgroup yap-cplus-interface An object oriented interface for YAP.
|
|
|
|
*
|
2014-09-11 20:06:57 +01:00
|
|
|
* @ingroup ChYInterface
|
2014-05-04 22:31:22 +01:00
|
|
|
* @tableofcontents
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* C++ interface to YAP. Designed to be object oriented and to fit naturally
|
|
|
|
* with the swig interface language generator. It uses ideas from the old YAP
|
|
|
|
* interface and from the SWI foreign language interface.
|
|
|
|
*
|
|
|
|
*/
|
2014-04-28 11:47:09 +01:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
2015-07-23 01:33:30 +01:00
|
|
|
#include <string>
|
|
|
|
|
2014-06-22 17:35:05 +01:00
|
|
|
// Bad export from Python
|
2016-04-12 16:22:53 +01:00
|
|
|
|
2014-05-04 22:31:22 +01:00
|
|
|
#include <config.h>
|
|
|
|
|
2014-06-11 19:27:54 +01:00
|
|
|
extern "C" {
|
|
|
|
|
2014-06-12 01:48:36 +01:00
|
|
|
#include <stddef.h>
|
2015-04-13 13:28:17 +01:00
|
|
|
|
2014-04-28 11:47:09 +01:00
|
|
|
#include "Yap.h"
|
|
|
|
|
|
|
|
#include "Yatom.h"
|
|
|
|
|
|
|
|
#include "YapHeap.h"
|
|
|
|
|
|
|
|
#include "clause.h"
|
|
|
|
|
|
|
|
#include "yapio.h"
|
|
|
|
|
|
|
|
#include "Foreign.h"
|
|
|
|
|
|
|
|
#include "attvar.h"
|
|
|
|
|
|
|
|
#include "YapText.h"
|
|
|
|
|
|
|
|
#if HAVE_STDARG_H
|
|
|
|
#include <stdarg.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if HAVE_STDINT_H
|
|
|
|
#include <stdint.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if HAVE_STRING_H
|
|
|
|
#include <string.h>
|
|
|
|
#endif
|
|
|
|
|
2014-06-19 15:06:15 +01:00
|
|
|
#if _MSC_VER || defined(__MINGW32__)
|
2016-04-10 14:21:17 +01:00
|
|
|
//#include <windows.h>
|
2014-04-28 11:47:09 +01:00
|
|
|
#endif
|
|
|
|
|
2014-05-04 22:31:22 +01:00
|
|
|
// taken from yap_structs.h
|
2014-04-28 11:47:09 +01:00
|
|
|
#include "iopreds.h"
|
2015-07-06 12:01:55 +01:00
|
|
|
|
2016-07-31 16:22:24 +01:00
|
|
|
#ifdef SWIGPYTHON
|
2016-09-21 20:41:23 +01:00
|
|
|
extern PyObject *term_to_python(yhandle_t t, bool eval);
|
|
|
|
extern PyObject *deref_term_to_python(yhandle_t t);
|
2016-07-31 16:22:24 +01:00
|
|
|
X_API bool init_python(void);
|
|
|
|
|
|
|
|
extern PyObject *py_Main;
|
|
|
|
|
2016-09-21 20:41:23 +01:00
|
|
|
extern inline PyObject *AtomToPy(const char *s) {
|
2016-07-31 16:22:24 +01:00
|
|
|
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();
|
2016-09-21 20:41:23 +01:00
|
|
|
/* return __main__,s */
|
2016-07-31 16:22:24 +01:00
|
|
|
else if (PyObject_HasAttrString(py_Main, s)) {
|
|
|
|
return PyObject_GetAttrString(py_Main, s);
|
|
|
|
}
|
|
|
|
// no way to translate
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2016-04-10 14:21:17 +01:00
|
|
|
X_API void YAP_UserCPredicate(const char *, YAP_UserCPred, YAP_Arity arity);
|
2015-07-06 12:01:55 +01:00
|
|
|
|
2016-09-21 20:41:23 +01:00
|
|
|
/* void UserCPredicateWithArgs(const char *name, int *fn(), unsigned int arity)
|
|
|
|
*/
|
|
|
|
X_API void YAP_UserCPredicateWithArgs(const char *, YAP_UserCPred, YAP_Arity,
|
|
|
|
YAP_Term);
|
2015-07-06 12:01:55 +01:00
|
|
|
|
2015-07-23 01:33:30 +01:00
|
|
|
/* void UserBackCPredicate(const char *name, int *init(), int *cont(), int
|
2015-06-18 00:52:31 +01:00
|
|
|
arity, int extra) */
|
2016-09-21 20:41:23 +01:00
|
|
|
X_API void YAP_UserBackCPredicate(const char *, YAP_UserCPred, YAP_UserCPred,
|
|
|
|
YAP_Arity, YAP_Arity);
|
2016-07-31 16:22:24 +01:00
|
|
|
|
2016-09-21 20:41:23 +01:00
|
|
|
X_API Term Yap_StringToTerm(const char *s, size_t len, encoding_t *encp,
|
|
|
|
int prio, Term *bindings_p);
|
2014-04-28 11:47:09 +01:00
|
|
|
}
|
|
|
|
|
2014-05-04 22:31:22 +01:00
|
|
|
class YAPEngine;
|
2014-04-28 11:47:09 +01:00
|
|
|
class YAPAtom;
|
|
|
|
class YAPFunctor;
|
2014-06-04 22:08:37 +01:00
|
|
|
class YAPApplTerm;
|
|
|
|
class YAPPairTerm;
|
2014-04-28 11:47:09 +01:00
|
|
|
class YAPQuery;
|
2015-02-09 01:52:10 +00:00
|
|
|
class YAPModule;
|
|
|
|
class YAPError;
|
|
|
|
class YAPPredicate;
|
2014-04-28 11:47:09 +01:00
|
|
|
|
2015-02-09 01:52:10 +00:00
|
|
|
#include "yapa.hh"
|
2014-05-04 22:31:22 +01:00
|
|
|
|
2015-02-09 01:52:10 +00:00
|
|
|
#include "yapie.hh"
|
2014-04-28 11:47:09 +01:00
|
|
|
|
2015-02-09 01:52:10 +00:00
|
|
|
#include "yapt.hh"
|
2014-04-28 11:47:09 +01:00
|
|
|
|
2015-02-09 01:52:10 +00:00
|
|
|
#include "yapdb.hh"
|
2014-04-28 11:47:09 +01:00
|
|
|
|
2015-02-09 01:52:10 +00:00
|
|
|
#include "yapq.hh"
|
2014-04-29 11:45:19 +01:00
|
|
|
|
2014-05-04 22:31:22 +01:00
|
|
|
/**
|
2014-06-11 19:27:54 +01:00
|
|
|
* @}
|
2014-05-04 22:31:22 +01:00
|
|
|
*
|
|
|
|
*/
|