X_API
This commit is contained in:
parent
c2f6d968c3
commit
0d96197ddf
@ -25,6 +25,7 @@
|
|||||||
#ifndef C_INTERFACE_C
|
#ifndef C_INTERFACE_C
|
||||||
|
|
||||||
#define C_INTERFACE_C 1
|
#define C_INTERFACE_C 1
|
||||||
|
#define _EXPORT_KERNEL 1
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#if HAVE_UNISTD_H
|
#if HAVE_UNISTD_H
|
||||||
@ -1079,7 +1080,7 @@ static uintptr_t complete_exit(choiceptr ptr, int has_cp,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
Int YAP_Execute(PredEntry *pe, CPredicate exec_code) {
|
X_API Int YAP_Execute(PredEntry *pe, CPredicate exec_code) {
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
Int ret;
|
Int ret;
|
||||||
Int OASP = LCL0 - (CELL *)B;
|
Int OASP = LCL0 - (CELL *)B;
|
||||||
@ -1120,7 +1121,7 @@ Int YAP_Execute(PredEntry *pe, CPredicate exec_code) {
|
|||||||
#define REDO_INT 0x02 /* Returned an integer */
|
#define REDO_INT 0x02 /* Returned an integer */
|
||||||
#define REDO_PTR 0x03 /* returned a pointer */
|
#define REDO_PTR 0x03 /* returned a pointer */
|
||||||
|
|
||||||
Int YAP_ExecuteFirst(PredEntry *pe, CPredicate exec_code) {
|
X_API Int YAP_ExecuteFirst(PredEntry *pe, CPredicate exec_code) {
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
CELL ocp = LCL0 - (CELL *)B;
|
CELL ocp = LCL0 - (CELL *)B;
|
||||||
/* for slots to work */
|
/* for slots to work */
|
||||||
@ -1168,7 +1169,7 @@ Int YAP_ExecuteFirst(PredEntry *pe, CPredicate exec_code) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Int YAP_ExecuteOnCut(PredEntry *pe, CPredicate exec_code,
|
X_API Int YAP_ExecuteOnCut(PredEntry *pe, CPredicate exec_code,
|
||||||
struct cut_c_str *top) {
|
struct cut_c_str *top) {
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
Int oB = LCL0 - (CELL *)B;
|
Int oB = LCL0 - (CELL *)B;
|
||||||
@ -1216,7 +1217,7 @@ Int YAP_ExecuteOnCut(PredEntry *pe, CPredicate exec_code,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Int YAP_ExecuteNext(PredEntry *pe, CPredicate exec_code) {
|
X_API Int YAP_ExecuteNext(PredEntry *pe, CPredicate exec_code) {
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
/* for slots to work */
|
/* for slots to work */
|
||||||
Yap_StartSlots();
|
Yap_StartSlots();
|
||||||
@ -1847,7 +1848,7 @@ X_API YAP_opaque_tag_t YAP_NewOpaqueType(struct YAP_opaque_handler_struct *f) {
|
|||||||
return i + USER_BLOB_START;
|
return i + USER_BLOB_START;
|
||||||
}
|
}
|
||||||
|
|
||||||
Term YAP_NewOpaqueObject(YAP_opaque_tag_t tag, size_t bytes) {
|
X_API Term YAP_NewOpaqueObject(YAP_opaque_tag_t tag, size_t bytes) {
|
||||||
Term t = Yap_AllocExternalDataInStack((CELL)tag, bytes);
|
Term t = Yap_AllocExternalDataInStack((CELL)tag, bytes);
|
||||||
if (t == TermNil)
|
if (t == TermNil)
|
||||||
return 0L;
|
return 0L;
|
||||||
@ -2322,7 +2323,7 @@ bool Yap_embedded = true;
|
|||||||
/* this routine is supposed to be called from an external program
|
/* this routine is supposed to be called from an external program
|
||||||
that wants to control Yap */
|
that wants to control Yap */
|
||||||
|
|
||||||
YAP_file_type_t YAP_Init(YAP_init_args *yap_init) {
|
X_API YAP_file_type_t YAP_Init(YAP_init_args *yap_init) {
|
||||||
YAP_file_type_t restore_result = yap_init->boot_file_type;
|
YAP_file_type_t restore_result = yap_init->boot_file_type;
|
||||||
bool do_bootstrap = (restore_result & YAP_CONSULT_MODE);
|
bool do_bootstrap = (restore_result & YAP_CONSULT_MODE);
|
||||||
CELL Trail = 0, Stack = 0, Heap = 0, Atts = 0;
|
CELL Trail = 0, Stack = 0, Heap = 0, Atts = 0;
|
||||||
@ -3088,7 +3089,7 @@ X_API void YAP_signal(int sig) { Yap_signal(sig); }
|
|||||||
X_API int YAP_SetYAPFlag(Term flag, Term val) { return setYapFlag(flag, val); }
|
X_API int YAP_SetYAPFlag(Term flag, Term val) { return setYapFlag(flag, val); }
|
||||||
|
|
||||||
/* yhandle_t YAP_VarSlotToNumber(yhandle_t) */
|
/* yhandle_t YAP_VarSlotToNumber(yhandle_t) */
|
||||||
yhandle_t YAP_VarSlotToNumber(yhandle_t s) {
|
X_API yhandle_t YAP_VarSlotToNumber(yhandle_t s) {
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
Term *t = (CELL *)Deref(Yap_GetFromSlot(s));
|
Term *t = (CELL *)Deref(Yap_GetFromSlot(s));
|
||||||
if (t < HR)
|
if (t < HR)
|
||||||
@ -3097,14 +3098,14 @@ yhandle_t YAP_VarSlotToNumber(yhandle_t s) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Term YAP_ModuleUser() */
|
/* Term YAP_ModuleUser() */
|
||||||
Term YAP_ModuleUser(void) { return MkAtomTerm(AtomUser); }
|
X_API Term YAP_ModuleUser(void) { return MkAtomTerm(AtomUser); }
|
||||||
|
|
||||||
/* int YAP_PredicateHasClauses() */
|
/* int YAP_PredicateHasClauses() */
|
||||||
yhandle_t YAP_NumberOfClausesForPredicate(PredEntry *pe) {
|
X_API yhandle_t YAP_NumberOfClausesForPredicate(PredEntry *pe) {
|
||||||
return pe->cs.p_code.NOfClauses;
|
return pe->cs.p_code.NOfClauses;
|
||||||
}
|
}
|
||||||
|
|
||||||
int YAP_MaxOpPriority(Atom at, Term module) {
|
X_API int YAP_MaxOpPriority(Atom at, Term module) {
|
||||||
AtomEntry *ae = RepAtom(at);
|
AtomEntry *ae = RepAtom(at);
|
||||||
OpEntry *info;
|
OpEntry *info;
|
||||||
WRITE_LOCK(ae->ARWLock);
|
WRITE_LOCK(ae->ARWLock);
|
||||||
@ -3122,7 +3123,7 @@ int YAP_MaxOpPriority(Atom at, Term module) {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int YAP_OpInfo(Atom at, Term module, int opkind, int *yap_type, int *prio) {
|
X_API int YAP_OpInfo(Atom at, Term module, int opkind, int *yap_type, int *prio) {
|
||||||
AtomEntry *ae = RepAtom(at);
|
AtomEntry *ae = RepAtom(at);
|
||||||
OpEntry *info;
|
OpEntry *info;
|
||||||
int n;
|
int n;
|
||||||
@ -3184,14 +3185,14 @@ int YAP_OpInfo(Atom at, Term module, int opkind, int *yap_type, int *prio) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int YAP_Argv(char ***argvp) {
|
X_API int YAP_Argv(char ***argvp) {
|
||||||
if (argvp) {
|
if (argvp) {
|
||||||
*argvp = GLOBAL_argv;
|
*argvp = GLOBAL_argv;
|
||||||
}
|
}
|
||||||
return GLOBAL_argc;
|
return GLOBAL_argc;
|
||||||
}
|
}
|
||||||
|
|
||||||
YAP_tag_t YAP_TagOfTerm(Term t) {
|
X_API YAP_tag_t YAP_TagOfTerm(Term t) {
|
||||||
if (IsVarTerm(t)) {
|
if (IsVarTerm(t)) {
|
||||||
CELL *pt = VarOfTerm(t);
|
CELL *pt = VarOfTerm(t);
|
||||||
if (IsUnboundVar(pt)) {
|
if (IsUnboundVar(pt)) {
|
||||||
@ -3246,7 +3247,7 @@ Term YAP_BPROLOG_curr_toam_status;
|
|||||||
*
|
*
|
||||||
* @return a positive number with the size, or 0.
|
* @return a positive number with the size, or 0.
|
||||||
*/
|
*/
|
||||||
size_t YAP_UTF8_TextLength(Term t) {
|
X_API size_t YAP_UTF8_TextLength(Term t) {
|
||||||
utf8proc_uint8_t dst[8];
|
utf8proc_uint8_t dst[8];
|
||||||
size_t sz = 0;
|
size_t sz = 0;
|
||||||
|
|
||||||
@ -3280,7 +3281,7 @@ size_t YAP_UTF8_TextLength(Term t) {
|
|||||||
return sz;
|
return sz;
|
||||||
}
|
}
|
||||||
|
|
||||||
Int YAP_ListLength(Term t) {
|
X_API Int YAP_ListLength(Term t) {
|
||||||
Term *aux;
|
Term *aux;
|
||||||
|
|
||||||
Int n = Yap_SkipList(&t, &aux);
|
Int n = Yap_SkipList(&t, &aux);
|
||||||
@ -3291,14 +3292,14 @@ Int YAP_ListLength(Term t) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Int YAP_NumberVars(Term t, Int nbv) { return Yap_NumberVars(t, nbv, FALSE); }
|
X_API Int YAP_NumberVars(Term t, Int nbv) { return Yap_NumberVars(t, nbv, FALSE); }
|
||||||
|
|
||||||
Term YAP_UnNumberVars(Term t) {
|
X_API Term YAP_UnNumberVars(Term t) {
|
||||||
/* don't allow sharing of ground terms */
|
/* don't allow sharing of ground terms */
|
||||||
return Yap_UnNumberTerm(t, FALSE);
|
return Yap_UnNumberTerm(t, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
int YAP_IsNumberedVariable(Term t) {
|
X_API int YAP_IsNumberedVariable(Term t) {
|
||||||
return IsApplTerm(t) && FunctorOfTerm(t) == FunctorDollarVar &&
|
return IsApplTerm(t) && FunctorOfTerm(t) == FunctorDollarVar &&
|
||||||
IsIntegerTerm(ArgOfTerm(1, t));
|
IsIntegerTerm(ArgOfTerm(1, t));
|
||||||
}
|
}
|
||||||
|
@ -159,7 +159,7 @@ void jmp_deb2(void) { fprintf(stderr, "Here\n"); }
|
|||||||
|
|
||||||
void jmp_deb(int i) {
|
void jmp_deb(int i) {
|
||||||
if (i)
|
if (i)
|
||||||
printf("Here we go %ld\n", old_value++);
|
printf("Here we go " Int_FORMAT "\n", old_value++);
|
||||||
if (old_value == 716)
|
if (old_value == 716)
|
||||||
jmp_deb2();
|
jmp_deb2();
|
||||||
}
|
}
|
||||||
@ -354,8 +354,8 @@ bool low_level_trace__(yap_low_level_port port, PredEntry *pred, CELL *args) {
|
|||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
b += snprintf(b, top - b, "%lld %ld ", vsc_count, LCL0 - (CELL *)B);
|
b += snprintf(b, top - b, Int_FORMAT " "UInt_FORMAT " ", vsc_count, LCL0 - (CELL *)B);
|
||||||
b += snprintf(b, top - b, "%ld ", LCL0 - (CELL *)Yap_REGS.CUT_C_TOP);
|
b += snprintf(b, top - b, Int_FORMAT " ", LCL0 - (CELL *)Yap_REGS.CUT_C_TOP);
|
||||||
#if defined(THREADS) || defined(YAPOR)
|
#if defined(THREADS) || defined(YAPOR)
|
||||||
b += snprintf(b, top - b, "(%d)", worker_id);
|
b += snprintf(b, top - b, "(%d)", worker_id);
|
||||||
#endif
|
#endif
|
||||||
@ -482,7 +482,7 @@ static Int reset_total_choicepoints(USES_REGS1) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Int show_low_level_trace(USES_REGS1) {
|
static Int show_low_level_trace(USES_REGS1) {
|
||||||
fprintf(stderr, "Call counter=%llu\n", vsc_count);
|
fprintf(stderr, "Call counter=" Int_FORMAT "\n", vsc_count);
|
||||||
return (TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,7 +113,10 @@ else()
|
|||||||
List (APPEND YLIBS $<TARGET_OBJECTS:Yapsqlite3> )
|
List (APPEND YLIBS $<TARGET_OBJECTS:Yapsqlite3> )
|
||||||
List (APPEND YLIBS $<TARGET_OBJECTS:libswi> )
|
List (APPEND YLIBS $<TARGET_OBJECTS:libswi> )
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
List (APPEND YLIBS $<TARGET_OBJECTS:YAP++> )
|
List (APPEND YLIBS $<TARGET_OBJECTS:YAP++> )
|
||||||
|
if (PYTHON_INCLUDE_DIRS AND PYTHON_LIBRARIES )
|
||||||
|
List (APPEND YLIBS $<TARGET_OBJECTS:YAPPython0> )
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
@ -132,6 +135,9 @@ add_library( # Sets the name of the library.
|
|||||||
|
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
target_link_libraries(libYap ${WINDLLS})
|
target_link_libraries(libYap ${WINDLLS})
|
||||||
|
if (PYTHON_INCLUDE_DIRS AND PYTHON_LIBRARIES )
|
||||||
|
target_link_libraries(libYap ${PYTHON_LIBRARIES})
|
||||||
|
endif()
|
||||||
endif (WIN32)
|
endif (WIN32)
|
||||||
|
|
||||||
include(libYap NO_POLICY_SCOPE)
|
include(libYap NO_POLICY_SCOPE)
|
||||||
|
@ -68,7 +68,7 @@ enum PropTag {
|
|||||||
* predicates, operators, modules, almost everything.
|
* predicates, operators, modules, almost everything.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class YAPAtom {
|
class X_API YAPAtom {
|
||||||
friend class YAPEngine;
|
friend class YAPEngine;
|
||||||
friend class YAPModuleProp;
|
friend class YAPModuleProp;
|
||||||
friend class YAPPredicate;
|
friend class YAPPredicate;
|
||||||
@ -104,7 +104,7 @@ public:
|
|||||||
* predicates, operators, modules, almost everything.
|
* predicates, operators, modules, almost everything.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class YAPProp {
|
class X_API YAPProp {
|
||||||
friend class YAPModuleProp;
|
friend class YAPModuleProp;
|
||||||
friend class YAPFunctor;
|
friend class YAPFunctor;
|
||||||
/// does nothing, p is defined by the subclass
|
/// does nothing, p is defined by the subclass
|
||||||
|
12
CXX/yapdb.hh
12
CXX/yapdb.hh
@ -43,7 +43,7 @@ class YAPModule;
|
|||||||
* Info about the module is in YAPModuleProp
|
* Info about the module is in YAPModuleProp
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class YAPModule : protected YAPAtomTerm {
|
class X_API YAPModule : protected YAPAtomTerm {
|
||||||
friend class YAPPredicate;
|
friend class YAPPredicate;
|
||||||
friend class YAPModuleProp;
|
friend class YAPModuleProp;
|
||||||
Term t() { return gt(); }
|
Term t() { return gt(); }
|
||||||
@ -61,7 +61,7 @@ public:
|
|||||||
* A YAPModuleProp controls access to a module property.
|
* A YAPModuleProp controls access to a module property.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class YAPModuleProp : public YAPProp {
|
class X_API YAPModuleProp : public YAPProp {
|
||||||
friend class YAPPredicate;
|
friend class YAPPredicate;
|
||||||
ModEntry *m;
|
ModEntry *m;
|
||||||
|
|
||||||
@ -77,7 +77,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
* @brief YAPFunctor represents Prolog functors Name/Arity
|
* @brief YAPFunctor represents Prolog functors Name/Arity
|
||||||
*/
|
*/
|
||||||
class YAPFunctor : public YAPProp {
|
class X_API YAPFunctor : public YAPProp {
|
||||||
friend class YAPApplTerm;
|
friend class YAPApplTerm;
|
||||||
friend class YAPTerm;
|
friend class YAPTerm;
|
||||||
friend class YAPPredicate;
|
friend class YAPPredicate;
|
||||||
@ -127,7 +127,7 @@ public:
|
|||||||
*
|
*
|
||||||
* This class interfaces with PredEntry in Yatom.
|
* This class interfaces with PredEntry in Yatom.
|
||||||
*/
|
*/
|
||||||
class YAPPredicate : public YAPModuleProp {
|
class X_API YAPPredicate : public YAPModuleProp {
|
||||||
friend class YAPQuery;
|
friend class YAPQuery;
|
||||||
friend class YAPEngine;
|
friend class YAPEngine;
|
||||||
|
|
||||||
@ -297,7 +297,7 @@ Yap_ThrowError(DOMAIN_ERROR_OUT_OF_RANGE, MkIntTerm(0), "YAPFunctor::functor");
|
|||||||
*
|
*
|
||||||
* This class interfaces with Predicates Implemented in Prolog.
|
* This class interfaces with Predicates Implemented in Prolog.
|
||||||
*/
|
*/
|
||||||
class YAPPrologPredicate : public YAPPredicate {
|
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){};
|
||||||
@ -319,7 +319,7 @@ public:
|
|||||||
*
|
*
|
||||||
* This class interfaces with Predicates Implemented in Prolog.
|
* This class interfaces with Predicates Implemented in Prolog.
|
||||||
*/
|
*/
|
||||||
class YAPFLIP : public YAPPredicate {
|
class X_API YAPFLIP : public YAPPredicate {
|
||||||
public:
|
public:
|
||||||
YAPFLIP(CPredicate call, YAPAtom name, uintptr_t arity,
|
YAPFLIP(CPredicate call, YAPAtom name, uintptr_t arity,
|
||||||
YAPModule module = YAPModule(), CPredicate retry = 0,
|
YAPModule module = YAPModule(), CPredicate retry = 0,
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
|
|
||||||
#define YAP_CPP_INTERFACE 1
|
#define _EXPORT_KERNEL 1
|
||||||
|
|
||||||
#include "yapi.hh"
|
#include "yapi.hh"
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@ -1012,7 +1012,7 @@ YAPEngine::YAPEngine(int argc, char *argv[],
|
|||||||
return ap;
|
return ap;
|
||||||
}
|
}
|
||||||
|
|
||||||
X_API bool YAPPrologPredicate::assertClause(YAPTerm cl, bool last,
|
bool YAPPrologPredicate::assertClause(YAPTerm cl, bool last,
|
||||||
YAPTerm source)
|
YAPTerm source)
|
||||||
{
|
{
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/**
|
/**
|
||||||
* @file yapie.hh
|
* @file yapie.hh
|
||||||
*
|
*
|
||||||
* @defgroup yap-cplus-error-hanadlinge Errir Handling in the YAP interface.
|
* @defgroup yap-cplus-error-hanadlinge Errir Handling in the YAP interface.
|
||||||
@ -23,11 +23,11 @@
|
|||||||
#ifndef YAPIE_HH
|
#ifndef YAPIE_HH
|
||||||
#define YAPIE_HH
|
#define YAPIE_HH
|
||||||
|
|
||||||
class YAPPPredicate;
|
class X_API YAPPPredicate;
|
||||||
class YAPTerm;
|
class X_API YAPTerm;
|
||||||
|
|
||||||
/// take information on a Prolog error:
|
/// take information on a Prolog error:
|
||||||
class YAPError {
|
class X_API YAPError {
|
||||||
yap_error_number ID;
|
yap_error_number ID;
|
||||||
std::string goal, info;
|
std::string goal, info;
|
||||||
int swigcode;
|
int swigcode;
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#ifndef YAPQ_HH
|
#ifndef YAPQ_HH
|
||||||
#define YAPQ_HH 1
|
#define YAPQ_HH 1
|
||||||
|
|
||||||
class YAPPredicate;
|
class X_API YAPPredicate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Queries and engines
|
Queries and engines
|
||||||
@ -31,7 +31,7 @@ class YAPPredicate;
|
|||||||
* interface to a YAP Query;
|
* interface to a YAP Query;
|
||||||
* uses an SWI-like status info internally.
|
* uses an SWI-like status info internally.
|
||||||
*/
|
*/
|
||||||
class YAPQuery : public YAPPredicate
|
class X_API YAPQuery : public YAPPredicate
|
||||||
{
|
{
|
||||||
bool q_open;
|
bool q_open;
|
||||||
int q_state;
|
int q_state;
|
||||||
@ -171,7 +171,7 @@ inline bool command()
|
|||||||
/// This class implements a callback Prolog-side. It will be inherited by the
|
/// This class implements a callback Prolog-side. It will be inherited by the
|
||||||
/// Java or Python
|
/// Java or Python
|
||||||
/// class that actually implements the callback.
|
/// class that actually implements the callback.
|
||||||
class YAPCallback
|
class X_API YAPCallback
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~YAPCallback() {}
|
virtual ~YAPCallback() {}
|
||||||
@ -181,7 +181,7 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
/// @brief Setup all arguments to a new engine
|
/// @brief Setup all arguments to a new engine
|
||||||
class YAPEngineArgs {
|
class X_API YAPEngineArgs {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
78
CXX/yapt.hh
78
CXX/yapt.hh
@ -34,7 +34,7 @@ class YAPError;
|
|||||||
/**
|
/**
|
||||||
* @brief Generic Prolog Term
|
* @brief Generic Prolog Term
|
||||||
*/
|
*/
|
||||||
class YAPTerm {
|
class X_API YAPTerm {
|
||||||
friend class YAPPredicate;
|
friend class YAPPredicate;
|
||||||
friend class YAPPrologPredicate;
|
friend class YAPPrologPredicate;
|
||||||
friend class YAPQuery;
|
friend class YAPQuery;
|
||||||
@ -254,39 +254,10 @@ public:
|
|||||||
inline bool initialized() { return t != 0; };
|
inline bool initialized() { return t != 0; };
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Variable Term
|
|
||||||
*/
|
|
||||||
class YAPVarTerm : public YAPTerm {
|
|
||||||
YAPVarTerm(Term t) {
|
|
||||||
if (IsVarTerm(t)) {
|
|
||||||
mk(t);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
|
||||||
/// constructor
|
|
||||||
YAPVarTerm();
|
|
||||||
/// get the internal representation
|
|
||||||
CELL *getVar() { return VarOfTerm(gt()); }
|
|
||||||
/// is the variable bound to another one
|
|
||||||
bool unbound() { return IsUnboundVar(VarOfTerm(gt())); }
|
|
||||||
virtual bool isVar() { return true; } /// type check for unbound
|
|
||||||
virtual bool isAtom() { return false; } /// type check for atom
|
|
||||||
virtual bool isInteger() { return false; } /// type check for integer
|
|
||||||
virtual bool isFloat() { return false; } /// type check for floating-point
|
|
||||||
virtual bool isString() { return false; } /// type check for a string " ... "
|
|
||||||
virtual bool isCompound() { return false; } /// is a primitive term
|
|
||||||
virtual bool isAppl() { return false; } /// is a structured term
|
|
||||||
virtual bool isPair() { return false; } /// is a pair term
|
|
||||||
virtual bool isGround() { return false; } /// term is ground
|
|
||||||
virtual bool isList() { return false; } /// term is a list
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Compound Term
|
* @brief Compound Term
|
||||||
*/
|
*/
|
||||||
class YAPApplTerm : public YAPTerm {
|
class X_API YAPApplTerm : public YAPTerm {
|
||||||
friend class YAPTerm;
|
friend class YAPTerm;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -324,7 +295,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
* @brief List Constructor Term
|
* @brief List Constructor Term
|
||||||
*/
|
*/
|
||||||
class YAPPairTerm : public YAPTerm {
|
class X_API YAPPairTerm : public YAPTerm {
|
||||||
friend class YAPTerm;
|
friend class YAPTerm;
|
||||||
|
|
||||||
|
|
||||||
@ -362,7 +333,7 @@ public:
|
|||||||
* @brief Number Term
|
* @brief Number Term
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class YAPNumberTerm : public YAPTerm {
|
class X_API YAPNumberTerm : public YAPTerm {
|
||||||
public:
|
public:
|
||||||
YAPNumberTerm(){};
|
YAPNumberTerm(){};
|
||||||
bool isTagged() { return IsIntTerm(gt()); }
|
bool isTagged() { return IsIntTerm(gt()); }
|
||||||
@ -372,7 +343,7 @@ public:
|
|||||||
* @brief Integer Term
|
* @brief Integer Term
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class YAPIntegerTerm : public YAPNumberTerm {
|
class X_API YAPIntegerTerm : public YAPNumberTerm {
|
||||||
public:
|
public:
|
||||||
YAPIntegerTerm(intptr_t i);
|
YAPIntegerTerm(intptr_t i);
|
||||||
intptr_t getInteger() { return IntegerOfTerm(gt()); };
|
intptr_t getInteger() { return IntegerOfTerm(gt()); };
|
||||||
@ -382,14 +353,14 @@ public:
|
|||||||
* @brief Floating Point Term
|
* @brief Floating Point Term
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class YAPFloatTerm : public YAPNumberTerm {
|
class X_API YAPFloatTerm : public YAPNumberTerm {
|
||||||
public:
|
public:
|
||||||
YAPFloatTerm(double dbl) { mk(MkFloatTerm(dbl)); };
|
YAPFloatTerm(double dbl) { mk(MkFloatTerm(dbl)); };
|
||||||
|
|
||||||
double getFl() { return FloatOfTerm(gt()); };
|
double getFl() { return FloatOfTerm(gt()); };
|
||||||
};
|
};
|
||||||
|
|
||||||
class YAPListTerm : public YAPTerm {
|
class X_API YAPListTerm : public YAPTerm {
|
||||||
public:
|
public:
|
||||||
/// Create a list term out of a standard term. Check if a valid operation.
|
/// Create a list term out of a standard term. Check if a valid operation.
|
||||||
///
|
///
|
||||||
@ -447,7 +418,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
* @brief String Term
|
* @brief String Term
|
||||||
*/
|
*/
|
||||||
class YAPStringTerm : public YAPTerm {
|
class X_API YAPStringTerm : public YAPTerm {
|
||||||
public:
|
public:
|
||||||
/// your standard constructor
|
/// your standard constructor
|
||||||
YAPStringTerm(char *s);
|
YAPStringTerm(char *s);
|
||||||
@ -464,7 +435,7 @@ public:
|
|||||||
* @brief Atom Term
|
* @brief Atom Term
|
||||||
* Term Representation of an Atom
|
* Term Representation of an Atom
|
||||||
*/
|
*/
|
||||||
class YAPAtomTerm : public YAPTerm {
|
class X_API YAPAtomTerm : public YAPTerm {
|
||||||
friend class YAPModule;
|
friend class YAPModule;
|
||||||
// Constructor: receives a C-atom;
|
// Constructor: receives a C-atom;
|
||||||
YAPAtomTerm(Term t) : YAPTerm(t) { IsAtomTerm(t); }
|
YAPAtomTerm(Term t) : YAPTerm(t) { IsAtomTerm(t); }
|
||||||
@ -498,4 +469,35 @@ public:
|
|||||||
};
|
};
|
||||||
#endif /* YAPT_HH */
|
#endif /* YAPT_HH */
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Variable Term
|
||||||
|
*/
|
||||||
|
class X_API YAPVarTerm : public YAPTerm {
|
||||||
|
friend class YAPTerm;
|
||||||
|
|
||||||
|
public:
|
||||||
|
/// constructor
|
||||||
|
YAPVarTerm();
|
||||||
|
/// get the internal representation
|
||||||
|
CELL *getVar() { return VarOfTerm(gt()); }
|
||||||
|
/// is the variable bound to another one
|
||||||
|
YAPVarTerm(Term t) {
|
||||||
|
if (IsVarTerm(t)) {
|
||||||
|
mk(t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
bool unbound() { return IsUnboundVar(VarOfTerm(gt())); }
|
||||||
|
virtual bool isVar() { return true; } /// type check for unbound
|
||||||
|
virtual bool isAtom() { return false; } /// type check for atom
|
||||||
|
virtual bool isInteger() { return false; } /// type check for integer
|
||||||
|
virtual bool isFloat() { return false; } /// type check for floating-point
|
||||||
|
virtual bool isString() { return false; } /// type check for a string " ... "
|
||||||
|
virtual bool isCompound() { return false; } /// is a primitive term
|
||||||
|
virtual bool isAppl() { return false; } /// is a structured term
|
||||||
|
virtual bool isPair() { return false; } /// is a pair term
|
||||||
|
virtual bool isGround() { return false; } /// term is ground
|
||||||
|
virtual bool isList() { return false; } /// term is a list
|
||||||
|
};
|
||||||
|
|
||||||
/// @}
|
/// @}
|
||||||
|
@ -90,7 +90,6 @@ ATOMS
|
|||||||
#ifdef EUROTRA
|
#ifdef EUROTRA
|
||||||
Term TermDollarU MkAT AtomDollarU
|
Term TermDollarU MkAT AtomDollarU
|
||||||
#endif
|
#endif
|
||||||
Term TermAnswer MkAT AtomAnswer
|
|
||||||
|
|
||||||
//modules
|
//modules
|
||||||
Term USER_MODULE MkAT AtomUser
|
Term USER_MODULE MkAT AtomUser
|
||||||
|
@ -83,7 +83,6 @@
|
|||||||
#ifdef EUROTRA
|
#ifdef EUROTRA
|
||||||
#define TermDollarU Yap_heap_regs->TermDollarU_
|
#define TermDollarU Yap_heap_regs->TermDollarU_
|
||||||
#endif
|
#endif
|
||||||
#define TermAnswer Yap_heap_regs->TermAnswer_
|
|
||||||
|
|
||||||
#define USER_MODULE Yap_heap_regs->USER_MODULE_
|
#define USER_MODULE Yap_heap_regs->USER_MODULE_
|
||||||
#define IDB_MODULE Yap_heap_regs->IDB_MODULE_
|
#define IDB_MODULE Yap_heap_regs->IDB_MODULE_
|
||||||
|
@ -87,7 +87,6 @@ EXTERNAL AtomHashEntry *HashChain;
|
|||||||
#ifdef EUROTRA
|
#ifdef EUROTRA
|
||||||
EXTERNAL Term TermDollarU;
|
EXTERNAL Term TermDollarU;
|
||||||
#endif
|
#endif
|
||||||
EXTERNAL Term TermAnswer;
|
|
||||||
//modules
|
//modules
|
||||||
EXTERNAL Term USER_MODULE;
|
EXTERNAL Term USER_MODULE;
|
||||||
EXTERNAL Term IDB_MODULE;
|
EXTERNAL Term IDB_MODULE;
|
||||||
|
@ -87,7 +87,6 @@
|
|||||||
#ifdef EUROTRA
|
#ifdef EUROTRA
|
||||||
Term TermDollarU_;
|
Term TermDollarU_;
|
||||||
#endif
|
#endif
|
||||||
Term TermAnswer_;
|
|
||||||
//modules
|
//modules
|
||||||
Term USER_MODULE_;
|
Term USER_MODULE_;
|
||||||
Term IDB_MODULE_;
|
Term IDB_MODULE_;
|
||||||
|
@ -83,7 +83,6 @@
|
|||||||
#ifdef EUROTRA
|
#ifdef EUROTRA
|
||||||
TermDollarU = MkAtomTerm(AtomDollarU);
|
TermDollarU = MkAtomTerm(AtomDollarU);
|
||||||
#endif
|
#endif
|
||||||
TermAnswer = MkAtomTerm(AtomAnswer);
|
|
||||||
|
|
||||||
USER_MODULE = MkAtomTerm(AtomUser);
|
USER_MODULE = MkAtomTerm(AtomUser);
|
||||||
IDB_MODULE = MkAtomTerm(AtomIDB);
|
IDB_MODULE = MkAtomTerm(AtomIDB);
|
||||||
|
@ -83,7 +83,6 @@
|
|||||||
#ifdef EUROTRA
|
#ifdef EUROTRA
|
||||||
TermDollarU = AtomTermAdjust(TermDollarU);
|
TermDollarU = AtomTermAdjust(TermDollarU);
|
||||||
#endif
|
#endif
|
||||||
TermAnswer = AtomTermAdjust(TermAnswer);
|
|
||||||
|
|
||||||
USER_MODULE = AtomTermAdjust(USER_MODULE);
|
USER_MODULE = AtomTermAdjust(USER_MODULE);
|
||||||
IDB_MODULE = AtomTermAdjust(IDB_MODULE);
|
IDB_MODULE = AtomTermAdjust(IDB_MODULE);
|
||||||
|
@ -1,6 +1,16 @@
|
|||||||
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 )
|
||||||
|
set (PythonInterp_FIND_VERSION 3)
|
||||||
find_package(PythonInterp)
|
find_package(PythonInterp)
|
||||||
|
|
||||||
|
get_filename_component( d ${PYTHON_EXECUTABLE} DIRECTORY )
|
||||||
|
get_filename_component( s ${PYTHON_EXECUTABLE} EXT )
|
||||||
|
get_filename_component( n ${PYTHON_EXECUTABLE} NAME_WE )
|
||||||
|
|
||||||
|
set( o ${d}/${n}3${s} )
|
||||||
|
if (EXISTS o)
|
||||||
|
set (PYTHON_EXECUTABLE ${o})
|
||||||
|
endif()
|
||||||
|
|
||||||
find_package(PythonLibs)
|
find_package(PythonLibs)
|
||||||
|
|
||||||
|
|
||||||
@ -29,6 +39,7 @@ ENDIF()
|
|||||||
|
|
||||||
if (PYTHONLIBS_FOUND AND SWIG_FOUND)
|
if (PYTHONLIBS_FOUND AND SWIG_FOUND)
|
||||||
add_subdirectory(packages/python/swig)
|
add_subdirectory(packages/python/swig)
|
||||||
|
|
||||||
include(FindPythonModule)
|
include(FindPythonModule)
|
||||||
|
|
||||||
find_python_module( jupyter )
|
find_python_module( jupyter )
|
||||||
|
@ -2052,24 +2052,5 @@ calls it, or to nothing if 'inline' is not supported under any name. */
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* X_API macro
|
|
||||||
*
|
|
||||||
* @brief Linux exports all symbols by default, but WIN32 does
|
|
||||||
* not. cmake can enable exports, using CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS
|
|
||||||
*
|
|
||||||
* @param _WIN32
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
#if _WIN32 && !defined(YAP_KERNEL)
|
|
||||||
#define X_API __declspec(dllimport)
|
|
||||||
#else
|
|
||||||
#define X_API
|
|
||||||
#endif
|
|
||||||
#define O_API
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ typedef struct vfs {
|
|||||||
/// in this space, usual w,r,a,b flags plus B (store in a buffer)
|
/// in this space, usual w,r,a,b flags plus B (store in a buffer)
|
||||||
bool (*close)(int sno); /// close the object
|
bool (*close)(int sno); /// close the object
|
||||||
int (*get_char)(int sno); /// get an octet to the stream
|
int (*get_char)(int sno); /// get an octet to the stream
|
||||||
int (*put_char)(int sno, wchar_t ch); /// output an octet to the stream
|
int (*put_char)(int sno, int ch); /// output an octet to the stream
|
||||||
void (*flush)(int sno); /// flush a stream
|
void (*flush)(int sno); /// flush a stream
|
||||||
int64_t (*seek)(int sno, int64_t offset,
|
int64_t (*seek)(int sno, int64_t offset,
|
||||||
int whence); /// jump around the stream
|
int whence); /// jump around the stream
|
||||||
|
@ -18,6 +18,36 @@
|
|||||||
|
|
||||||
#define _YAPDEFS_H 1
|
#define _YAPDEFS_H 1
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* X_API macro
|
||||||
|
*
|
||||||
|
* @brief Linux exports all symbols by default, but WIN32 does
|
||||||
|
* not. cmake can enable exports, using CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS
|
||||||
|
*
|
||||||
|
* @param _WIN32
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
#if _WIN32
|
||||||
|
#if defined(_EXPORT_KERNEL)
|
||||||
|
// __declspec(dllexport)
|
||||||
|
#define X_API
|
||||||
|
#else
|
||||||
|
// __declspec(dllimport)
|
||||||
|
#define X_API
|
||||||
|
#endif
|
||||||
|
// __declspec(dllexport)
|
||||||
|
#define O_API
|
||||||
|
// __declspec(dllimport)
|
||||||
|
#define I_API
|
||||||
|
#else
|
||||||
|
#define O_API
|
||||||
|
#define I_API
|
||||||
|
#define X_API
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#include <setjmp.h>
|
#include <setjmp.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
* @addtogroup swi-c-interface
|
* @addtogroup swi-c-interface
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
#define _EXPORT_KERNEL 1
|
||||||
|
|
||||||
#include <Yap.h>
|
#include <Yap.h>
|
||||||
#include <Yatom.h>
|
#include <Yatom.h>
|
||||||
@ -44,7 +45,7 @@
|
|||||||
static PL_blob_t unregistered_blob_atom = {
|
static PL_blob_t unregistered_blob_atom = {
|
||||||
PL_BLOB_MAGIC, PL_BLOB_NOCOPY | PL_BLOB_TEXT, "unregistered"};
|
PL_BLOB_MAGIC, PL_BLOB_NOCOPY | PL_BLOB_TEXT, "unregistered"};
|
||||||
|
|
||||||
int PL_is_blob(term_t t, PL_blob_t **type) {
|
X_API int PL_is_blob(term_t t, PL_blob_t **type) {
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
Term yt = Yap_GetFromSlot(t);
|
Term yt = Yap_GetFromSlot(t);
|
||||||
Atom a;
|
Atom a;
|
||||||
|
@ -20,6 +20,7 @@ Moyle. All rights reserved.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#define PL_KERNEL 1
|
#define PL_KERNEL 1
|
||||||
|
#define _EXPORT_KERNEL 1
|
||||||
|
|
||||||
//=== includes ===============================================================
|
//=== includes ===============================================================
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
@ -1858,8 +1858,8 @@ void Yap_InitPlIO(struct yap_boot_params *argi) {
|
|||||||
Yap_stdout = fdopen(argi->out-1, "a");
|
Yap_stdout = fdopen(argi->out-1, "a");
|
||||||
else if (argi->out)
|
else if (argi->out)
|
||||||
Yap_stdout = NULL;
|
Yap_stdout = NULL;
|
||||||
else
|
else
|
||||||
Yap_stdout = stdout;
|
Yap_stdout = stdout;
|
||||||
if (argi->err >0 )
|
if (argi->err >0 )
|
||||||
Yap_stderr = fdopen(argi->err-1, "a");
|
Yap_stderr = fdopen(argi->err-1, "a");
|
||||||
else if (argi->out)
|
else if (argi->out)
|
||||||
|
@ -7,7 +7,10 @@ set (PYTHON_HEADERS python.h)
|
|||||||
|
|
||||||
set (CMAKE_POSITION_INDEPENDENT_CODE TRUE)
|
set (CMAKE_POSITION_INDEPENDENT_CODE TRUE)
|
||||||
|
|
||||||
add_library (YAPPython SHARED ${PYTHON_SOURCES})
|
add_library (YAPPython0 OBJECT ${PYTHON_SOURCES})
|
||||||
|
if (WIN32)
|
||||||
|
add_library (YAPPython SHARED pyload.c )
|
||||||
|
endif()
|
||||||
|
|
||||||
# arithmetic hassle.
|
# arithmetic hassle.
|
||||||
set_property(TARGET YAPPython PROPERTY CXX_STANDARD 11)
|
set_property(TARGET YAPPython PROPERTY CXX_STANDARD 11)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
#include "python.h"
|
#include "py4yap.h"
|
||||||
|
|
||||||
static foreign_t array_to_python_list(term_t addr, term_t type, term_t szt,
|
static foreign_t array_to_python_list(term_t addr, term_t type, term_t szt,
|
||||||
term_t py) {
|
term_t py) {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "python.h"
|
#include "py4yap.h"
|
||||||
|
|
||||||
extern PyObject *py_Local, *py_Global;
|
extern PyObject *py_Local, *py_Global;
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
#include "python.h"
|
#include "py4yap.h"
|
||||||
|
|
||||||
static foreign_t repr_term(PyObject *pVal, term_t t) {
|
static foreign_t repr_term(PyObject *pVal, term_t t) {
|
||||||
term_t to = PL_new_term_ref(), t1 = PL_new_term_ref();
|
term_t to = PL_new_term_ref(), t1 = PL_new_term_ref();
|
||||||
|
@ -23,6 +23,12 @@
|
|||||||
#define EXTRA_MESSSAGES 1
|
#define EXTRA_MESSSAGES 1
|
||||||
|
|
||||||
#ifndef PYTHON_H
|
#ifndef PYTHON_H
|
||||||
|
|
||||||
|
#define X_API
|
||||||
|
#define I_API
|
||||||
|
#define O_API
|
||||||
|
|
||||||
|
|
||||||
#define PYTHON_H 1
|
#define PYTHON_H 1
|
||||||
|
|
||||||
PyObject *find_obj(PyObject *ob, term_t lhs, bool eval);
|
PyObject *find_obj(PyObject *ob, term_t lhs, bool eval);
|
@ -1,4 +1,4 @@
|
|||||||
#include "python.h"
|
#include "py4yap.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -700,6 +700,7 @@ static PyObject *structseq_repr(PyObject *iobj) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
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 >= 3
|
#if PY_MAJOR_VERSION >= 3
|
||||||
@ -722,7 +723,7 @@ PyObject *term_to_nametuple(const char *s, arity_t arity, PyObject *tuple) {
|
|||||||
return NULL;
|
return NULL;
|
||||||
typp->tp_flags &= ~Py_TPFLAGS_HEAPTYPE;
|
typp->tp_flags &= ~Py_TPFLAGS_HEAPTYPE;
|
||||||
// typp->tp_str = structseq_str;
|
// typp->tp_str = structseq_str;
|
||||||
// typp->tp_repr = structseq_repr;
|
typp->tp_repr = structseq_repr;
|
||||||
// typp = PyStructSequence_NewType(desc);
|
// typp = PyStructSequence_NewType(desc);
|
||||||
// don't do this: we cannot add a type as an atribute.
|
// don't do this: we cannot add a type as an atribute.
|
||||||
//PyModule_AddObject(py_Main, s, (PyObject *)typp);
|
//PyModule_AddObject(py_Main, s, (PyObject *)typp);
|
||||||
|
27
packages/python/pyload.c
Normal file
27
packages/python/pyload.c
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
|
||||||
|
#include "py4yap.h"
|
||||||
|
|
||||||
|
X_API bool init_python(void) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
|
int WINAPI win_python(HANDLE, DWORD, LPVOID);
|
||||||
|
|
||||||
|
int WINAPI win_python(HANDLE hinst, DWORD reason, LPVOID reserved) {
|
||||||
|
switch (reason) {
|
||||||
|
case DLL_PROCESS_ATTACH:
|
||||||
|
break;
|
||||||
|
case DLL_PROCESS_DETACH:
|
||||||
|
break;
|
||||||
|
case DLL_THREAD_ATTACH:
|
||||||
|
break;
|
||||||
|
case DLL_THREAD_DETACH:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
#endif
|
@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
#include "python.h"
|
#include "py4yap.h"
|
||||||
|
|
||||||
PyObject *py_Main;
|
PyObject *py_Main;
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
|
|
||||||
#include "python.h"
|
#include "py4yap.h"
|
||||||
#include <YapStreams.h>
|
|
||||||
#include <VFS.h>
|
#include <VFS.h>
|
||||||
|
|
||||||
atom_t ATOM_true, ATOM_false, ATOM_colon, ATOM_dot, ATOM_none, ATOM_t,
|
atom_t ATOM_true, ATOM_false, ATOM_colon, ATOM_dot, ATOM_none, ATOM_t,
|
||||||
@ -207,29 +206,3 @@ X_API bool do_init_python(void) {
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
X_API bool init_python(void) {
|
|
||||||
if (python_in_python)
|
|
||||||
return true;
|
|
||||||
return do_init_python();
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
|
|
||||||
#include <windows.h>
|
|
||||||
|
|
||||||
int WINAPI win_python(HANDLE, DWORD, LPVOID);
|
|
||||||
|
|
||||||
int WINAPI win_python(HANDLE hinst, DWORD reason, LPVOID reserved) {
|
|
||||||
switch (reason) {
|
|
||||||
case DLL_PROCESS_ATTACH:
|
|
||||||
break;
|
|
||||||
case DLL_PROCESS_DETACH:
|
|
||||||
break;
|
|
||||||
case DLL_THREAD_ATTACH:
|
|
||||||
break;
|
|
||||||
case DLL_THREAD_DETACH:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
# This is a CMake example for Python
|
# This is a CMake example for Python
|
||||||
|
|
||||||
INCLUDE(NewUseSWIG)
|
#INCLUDE(NewUseSWIG)
|
||||||
|
|
||||||
include(FindPythonModule)
|
include(FindPythonModule)
|
||||||
|
|
||||||
@ -23,22 +23,6 @@ SET_SOURCE_FILES_PROPERTIES(../../swig/yap.i PROPERTIES SWIG_FLAGS "-O;-py3")
|
|||||||
SET_SOURCE_FILES_PROPERTIES(../../swiyap.i PROPERTIES SWIG_MODULE_NAME yap)
|
SET_SOURCE_FILES_PROPERTIES(../../swiyap.i PROPERTIES SWIG_MODULE_NAME yap)
|
||||||
#SET_SOURCE_FILES_PROPERTIES(../../swi/yap.i PROPERTIES OUTPUT_NAME yap)
|
#SET_SOURCE_FILES_PROPERTIES(../../swi/yap.i PROPERTIES OUTPUT_NAME yap)
|
||||||
|
|
||||||
SWIG_ADD_LIBRARY(Py2YAP LANGUAGE python SHARED SOURCES ../../swig/yap.i )
|
|
||||||
if (WIN32)
|
|
||||||
SWIG_LINK_LIBRARIES(Py2YAP YAPPython libYap ${PYTHON_LIBRARIES} )
|
|
||||||
else()
|
|
||||||
SWIG_LINK_LIBRARIES( Py2YAP libYap YAP++ YAPPython ${PYTHON_LIBRARIES} )
|
|
||||||
endif()
|
|
||||||
set_target_properties ( ${SWIG_MODULE_Py2YAP_REAL_NAME}
|
|
||||||
PROPERTIES
|
|
||||||
NO_SONAME ON
|
|
||||||
CXXFLAGS "-include cmath "
|
|
||||||
OUTPUT_NAME _yap
|
|
||||||
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
|
|
||||||
DEPENDS YAPPython YAPPython YAP++
|
|
||||||
)
|
|
||||||
|
|
||||||
SET( CMAKE_CXX_FLAGS " -include cmath ${CMAKE_CXX_FLAGS} " )
|
|
||||||
|
|
||||||
# inform we are compiling YAP
|
# inform we are compiling YAP
|
||||||
# s used in MSYS
|
# s used in MSYS
|
||||||
@ -66,7 +50,10 @@ endif()
|
|||||||
set (PL ${pl_library} ${PROLOG_SOURCES} )
|
set (PL ${pl_library} ${PROLOG_SOURCES} )
|
||||||
|
|
||||||
add_custom_target( YAP4PY_SETUP
|
add_custom_target( YAP4PY_SETUP
|
||||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/yap4py
|
COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/yap.py
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/packages/swig/yap.i ${CMAKE_CURRENT_BINARY_DIR}/yap.i
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/yap4py
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/yap4py
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy ${dlls} ${CMAKE_BINARY_DIR}/libYap${CMAKE_SHARED_LIBRARY_SUFFIX} ${CMAKE_BINARY_DIR}/${YAP_STARTUP} ${PYTHON_SOURCES} ${CMAKE_CURRENT_BINARY_DIR}/yap4py
|
COMMAND ${CMAKE_COMMAND} -E copy ${dlls} ${CMAKE_BINARY_DIR}/libYap${CMAKE_SHARED_LIBRARY_SUFFIX} ${CMAKE_BINARY_DIR}/${YAP_STARTUP} ${PYTHON_SOURCES} ${CMAKE_CURRENT_BINARY_DIR}/yap4py
|
||||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/yap4py/prolog
|
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/yap4py/prolog
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy ${PL} ${CMAKE_CURRENT_BINARY_DIR}/yap4py/prolog
|
COMMAND ${CMAKE_COMMAND} -E copy ${PL} ${CMAKE_CURRENT_BINARY_DIR}/yap4py/prolog
|
||||||
|
@ -1,3 +0,0 @@
|
|||||||
|
|
||||||
// make Python happy...
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
|||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
from setuptools import setup
|
from setuptools import setup
|
||||||
from setuptools.extension import Extension
|
from setuptools.extension import Extension
|
||||||
from codecs import open
|
from codecs import open
|
||||||
from os import path, makedirs, walk
|
from os import path, makedirs, walk
|
||||||
from shutil import copytree, rmtree, copy2, move
|
from shutil import copytree, rmtree, copy2, move
|
||||||
@ -18,23 +18,23 @@ import os.path
|
|||||||
# the name of the package
|
# the name of the package
|
||||||
name = 'YAP4PY'
|
name = 'YAP4PY'
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
# Minimal Python version sanity check
|
# Minimal Python version sanity check
|
||||||
#-----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
v = sys.version_info
|
v = sys.version_info
|
||||||
if v[:2] < (2,7) or (v[0] >= 3 and v[:2] < (3,3)):
|
if v[:2] < (2, 7) or (v[0] >= 3 and v[:2] < (3, 3)):
|
||||||
error = "ERROR: %s requires Python version 2.7 or 3.3 or above." % name
|
error = "ERROR: %s requires Python version 2.7 or 3.3 or above." % name
|
||||||
print(error, file=sys.stderr)
|
print(error, file=sys.stderr)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
PY3 = (sys.version_info[0] >= 3)
|
PY3 = (sys.version_info[0] >= 3)
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
# get on with it
|
# get on with it
|
||||||
#-----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
from codecs import open
|
from codecs import open
|
||||||
from os import path, makedirs, walk
|
from os import path, makedirs, walk
|
||||||
from shutil import copytree, rmtree, copy2, move
|
from shutil import copytree, rmtree, copy2, move
|
||||||
@ -53,85 +53,86 @@ pkg_root = pjoin(here, name)
|
|||||||
|
|
||||||
my_extra_link_args = []
|
my_extra_link_args = []
|
||||||
if platform.system() == 'Darwin':
|
if platform.system() == 'Darwin':
|
||||||
my_extra_link_args = ['-Wl,-rpath','-Wl,${_ABS_PYTHON_MODULE_PATH}']
|
my_extra_link_args = ['-Wl,-rpath', '-Wl,${_ABS_PYTHON_MODULE_PATH}']
|
||||||
so = 'dylib'
|
# or dll in glob('yap/dlls/*'):
|
||||||
#or dll in glob('yap/dlls/*'):
|
|
||||||
# move( dll ,'lib' )
|
# move( dll ,'lib' )
|
||||||
|
elif platform.system() == 'Windows':
|
||||||
|
my_extra_link_args = ['-Wl,-export-all-symbols','-Wl,-enable-auto-import','-Wl,-enable-runtime-pseudo-relocs']
|
||||||
|
|
||||||
|
cplus = ['']
|
||||||
|
bpy2yap = ['${CMAKE_SOURCE_DIR}/packages/python/python.c',
|
||||||
|
'${CMAKE_SOURCE_DIR}/packages/python/pl2py.c',
|
||||||
|
'${CMAKE_SOURCE_DIR}/packages/python/pybips.c',
|
||||||
|
'${CMAKE_SOURCE_DIR}/packages/python/py2pl.c',
|
||||||
|
'${CMAKE_SOURCE_DIR}/packages/python/pl2pl.c',
|
||||||
|
'${CMAKE_SOURCE_DIR}/packages/python/pypreds.c'
|
||||||
|
]
|
||||||
|
|
||||||
cplus=['${RELATIVE_SOURCE}CXX/yapi.cpp']
|
native_sources = ['yap.i']
|
||||||
|
|
||||||
py2yap=['${RELATIVE_SOURCE}packages/python/python.c',
|
|
||||||
'${RELATIVE_SOURCE}packages/python/pl2py.c',
|
|
||||||
'${RELATIVE_SOURCE}packages/python/pybips.c',
|
|
||||||
'${RELATIVE_SOURCE}packages/python/py2pl.c',
|
|
||||||
'${RELATIVE_SOURCE}packages/python/pl2pl.c',
|
|
||||||
'${RELATIVE_SOURCE}packages/python/pypreds.c'
|
|
||||||
]
|
|
||||||
|
|
||||||
native_sources = ['yapPYTHON_wrap.cxx']+py2yap+cplus
|
|
||||||
here = path.abspath(path.dirname(__file__))
|
here = path.abspath(path.dirname(__file__))
|
||||||
|
|
||||||
# Get the long description from the README file
|
# Get the long description from the README file
|
||||||
|
|
||||||
extensions=[Extension('_yap', native_sources,
|
extensions = [Extension('_yap', native_sources,
|
||||||
define_macros = [('MAJOR_VERSION', '1'),
|
define_macros=[('MAJOR_VERSION', '1'),
|
||||||
('MINOR_VERSION', '0'),
|
('MINOR_VERSION', '0'),
|
||||||
('_YAP_NOT_INSTALLED_', '1'),
|
('_YAP_NOT_INSTALLED_', '1'),
|
||||||
('_GNU_SOURCE', '1'),
|
('_GNU_SOURCE', '1'),
|
||||||
('YAP_PYTHON', '1')],
|
('YAP_PYTHON', '1')],
|
||||||
runtime_library_dirs=['yap4py','${libdir}','${bindir}'],
|
runtime_library_dirs=['yap4py', '${libdir}', '${bindir}'],
|
||||||
swig_opts=['-modern', '-c++', '-py3','-I${RELATIVE_SOURCE}/CXX'],
|
swig_opts=['-modern', '-c++', '-py3', '-I${CMAKE_SOURCE_DIR}/CXX', '-I${CMAKE_SOURCE_DIR}/include',
|
||||||
library_dirs=['../../..','../../../CXX','../../packages/python',"${dlls}","${bindir}", '.'],
|
'-I${CMAKE_SOURCE_DIR}/H', '-I${CMAKE_SOURCE_DIR}/H/generated',
|
||||||
extra_link_args=my_extra_link_args,
|
'-I${CMAKE_SOURCE_DIR}/os', '-I${CMAKE_SOURCE_DIR}/OPTYap', '-I../../..'],
|
||||||
extra_compile_args=['-std=c++11','-g3','-O0'],
|
library_dirs=['../../..', '../../../CXX', '../../packages/python', "${dlls}", "${bindir}", '.'],
|
||||||
libraries=['Yap','${GMP_LIBRARIES}'],
|
extra_link_args=my_extra_link_args,
|
||||||
include_dirs=['../../..',
|
libraries=['Yap', '${GMP_LIBRARIES}'],
|
||||||
'${GMP_INCLUDE_DIRS}',
|
include_dirs=['../../..',
|
||||||
'${RELATIVE_SOURCE}H',
|
'${GMP_INCLUDE_DIRS}',
|
||||||
'${RELATIVE_SOURCE}H/generated',
|
'${CMAKE_SOURCE_DIR}/H',
|
||||||
'${RELATIVE_SOURCE}OPTYap',
|
'${CMAKE_SOURCE_DIR}/H/generated',
|
||||||
'${RELATIVE_SOURCE}os',
|
'${CMAKE_SOURCE_DIR}/OPTYap',
|
||||||
'${RELATIVE_SOURCE}include',
|
'${CMAKE_SOURCE_DIR}/os',
|
||||||
'${RELATIVE_SOURCE}CXX', '.']
|
'${CMAKE_SOURCE_DIR}/include',
|
||||||
)]
|
'${CMAKE_SOURCE_DIR}/CXX', '.']
|
||||||
|
)]
|
||||||
|
|
||||||
packages = ['yap4py']
|
packages = ['yap4py']
|
||||||
|
|
||||||
|
|
||||||
def visit(d0, pls):
|
def visit(d0, pls):
|
||||||
for (r,ds,fs) in walk('.'):
|
for (r, ds, fs) in walk('.'):
|
||||||
for f in fs:
|
for f in fs:
|
||||||
f0,ext = os.path.splitext(f)
|
f0, ext = os.path.splitext(f)
|
||||||
if (ext == 'yap' or ext == 'pl' or ext == 'so' or ext == 'dll' or ext == 'yss'):
|
if (ext == 'yap' or ext == 'pl' or ext == 'so' or ext == 'dll' or ext == 'yss'):
|
||||||
pls += [os.path.join(r, f)]
|
pls += [os.path.join(r, f)]
|
||||||
for i in ds:
|
for i in ds:
|
||||||
pls = visit(os.path.join(d0, i), pls)
|
pls = visit(os.path.join(d0, i), pls)
|
||||||
return pls
|
return pls
|
||||||
|
|
||||||
|
|
||||||
package_data = {
|
package_data = {
|
||||||
'': visit('.',[])
|
'': visit('.', [])
|
||||||
}
|
}
|
||||||
|
|
||||||
version_ns = {'__version__':'6.3.5','minor-version':'6','minor-version':'3','patch':'5'}
|
version_ns = {'__version__': '6.3.5', 'minor-version': '6', 'minor-version': '3', 'patch': '5'}
|
||||||
|
|
||||||
|
|
||||||
setup_args = dict(
|
setup_args = dict(
|
||||||
name = name,
|
name=name,
|
||||||
version = version_ns['__version__'],
|
version=version_ns['__version__'],
|
||||||
scripts = glob(pjoin('scripts', '*')),
|
scripts=glob(pjoin('scripts', '*')),
|
||||||
packages = packages,
|
packages=packages,
|
||||||
py_modules = ['yap'],
|
py_modules=['yap'],
|
||||||
package_data = package_data,
|
package_data=package_data,
|
||||||
include_package_data = True,
|
include_package_data=True,
|
||||||
description = "YAP in Python",
|
description="YAP in Python",
|
||||||
author = 'YAP Development Team',
|
author='YAP Development Team',
|
||||||
author_email = 'ipython-dev@scipy.org',
|
author_email='ipython-dev@scipy.org',
|
||||||
url = 'http://ipython.org',
|
url='http://ipython.org',
|
||||||
license = 'BSD',
|
license='BSD',
|
||||||
ext_modules = extensions,
|
ext_modules=extensions,
|
||||||
platforms = "Linux, Mac OS X, Windows",
|
platforms="Linux, Mac OS X, Windows",
|
||||||
keywords = ['Interactive', 'Interpreter', 'Shell', 'Web'],
|
keywords=['Interactive', 'Interpreter', 'Shell', 'Web'],
|
||||||
classifiers = [
|
classifiers=[
|
||||||
'Intended Audience :: Developers',
|
'Intended Audience :: Developers',
|
||||||
'Intended Audience :: System Administrators',
|
'Intended Audience :: System Administrators',
|
||||||
'Intended Audience :: Science/Research',
|
'Intended Audience :: Science/Research',
|
||||||
|
@ -1,10 +0,0 @@
|
|||||||
Metadata-Version: 1.0
|
|
||||||
Name: yapex
|
|
||||||
Version: 0.1
|
|
||||||
Summary: UNKNOWN
|
|
||||||
Home-page: UNKNOWN
|
|
||||||
Author: UNKNOWN
|
|
||||||
Author-email: UNKNOWN
|
|
||||||
License: UNKNOWN
|
|
||||||
Description: UNKNOWN
|
|
||||||
Platform: UNKNOWN
|
|
@ -1,11 +0,0 @@
|
|||||||
setup.py
|
|
||||||
/Users/vsc/Yap/yap-6.3/packages/python/yapex.py
|
|
||||||
/Users/vsc/Yap/yap-6.3/packages/python/yapex.egg-info/PKG-INFO
|
|
||||||
/Users/vsc/Yap/yap-6.3/packages/python/yapex.egg-info/SOURCES.txt
|
|
||||||
/Users/vsc/Yap/yap-6.3/packages/python/yapex.egg-info/dependency_links.txt
|
|
||||||
/Users/vsc/Yap/yap-6.3/packages/python/yapex.egg-info/top_level.txt
|
|
||||||
/Users/vsc/github/yap-6.3/packages/python/yapex.py
|
|
||||||
/Users/vsc/github/yap-6.3/packages/python/yapex.egg-info/PKG-INFO
|
|
||||||
/Users/vsc/github/yap-6.3/packages/python/yapex.egg-info/SOURCES.txt
|
|
||||||
/Users/vsc/github/yap-6.3/packages/python/yapex.egg-info/dependency_links.txt
|
|
||||||
/Users/vsc/github/yap-6.3/packages/python/yapex.egg-info/top_level.txt
|
|
@ -1 +0,0 @@
|
|||||||
|
|
@ -1 +0,0 @@
|
|||||||
yapex
|
|
Reference in New Issue
Block a user