This commit is contained in:
Vitor Santos Costa 2017-06-12 18:00:47 +01:00
parent c2f6d968c3
commit 0d96197ddf
47 changed files with 3580 additions and 3581 deletions

View File

@ -25,6 +25,7 @@
#ifndef C_INTERFACE_C
#define C_INTERFACE_C 1
#define _EXPORT_KERNEL 1
#include <stdlib.h>
#if HAVE_UNISTD_H
@ -1079,7 +1080,7 @@ static uintptr_t complete_exit(choiceptr ptr, int has_cp,
return TRUE;
}
Int YAP_Execute(PredEntry *pe, CPredicate exec_code) {
X_API Int YAP_Execute(PredEntry *pe, CPredicate exec_code) {
CACHE_REGS
Int ret;
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_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
CELL ocp = LCL0 - (CELL *)B;
/* 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) {
CACHE_REGS
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
/* for slots to work */
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;
}
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);
if (t == TermNil)
return 0L;
@ -2322,7 +2323,7 @@ bool Yap_embedded = true;
/* this routine is supposed to be called from an external program
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;
bool do_bootstrap = (restore_result & YAP_CONSULT_MODE);
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); }
/* yhandle_t YAP_VarSlotToNumber(yhandle_t) */
yhandle_t YAP_VarSlotToNumber(yhandle_t s) {
X_API yhandle_t YAP_VarSlotToNumber(yhandle_t s) {
CACHE_REGS
Term *t = (CELL *)Deref(Yap_GetFromSlot(s));
if (t < HR)
@ -3097,14 +3098,14 @@ yhandle_t YAP_VarSlotToNumber(yhandle_t s) {
}
/* Term YAP_ModuleUser() */
Term YAP_ModuleUser(void) { return MkAtomTerm(AtomUser); }
X_API Term YAP_ModuleUser(void) { return MkAtomTerm(AtomUser); }
/* int YAP_PredicateHasClauses() */
yhandle_t YAP_NumberOfClausesForPredicate(PredEntry *pe) {
X_API yhandle_t YAP_NumberOfClausesForPredicate(PredEntry *pe) {
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);
OpEntry *info;
WRITE_LOCK(ae->ARWLock);
@ -3122,7 +3123,7 @@ int YAP_MaxOpPriority(Atom at, Term module) {
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);
OpEntry *info;
int n;
@ -3184,14 +3185,14 @@ int YAP_OpInfo(Atom at, Term module, int opkind, int *yap_type, int *prio) {
return 1;
}
int YAP_Argv(char ***argvp) {
X_API int YAP_Argv(char ***argvp) {
if (argvp) {
*argvp = GLOBAL_argv;
}
return GLOBAL_argc;
}
YAP_tag_t YAP_TagOfTerm(Term t) {
X_API YAP_tag_t YAP_TagOfTerm(Term t) {
if (IsVarTerm(t)) {
CELL *pt = VarOfTerm(t);
if (IsUnboundVar(pt)) {
@ -3246,7 +3247,7 @@ Term YAP_BPROLOG_curr_toam_status;
*
* @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];
size_t sz = 0;
@ -3280,7 +3281,7 @@ size_t YAP_UTF8_TextLength(Term t) {
return sz;
}
Int YAP_ListLength(Term t) {
X_API Int YAP_ListLength(Term t) {
Term *aux;
Int n = Yap_SkipList(&t, &aux);
@ -3291,14 +3292,14 @@ Int YAP_ListLength(Term t) {
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 */
return Yap_UnNumberTerm(t, FALSE);
}
int YAP_IsNumberedVariable(Term t) {
X_API int YAP_IsNumberedVariable(Term t) {
return IsApplTerm(t) && FunctorOfTerm(t) == FunctorDollarVar &&
IsIntegerTerm(ArgOfTerm(1, t));
}

View File

@ -159,7 +159,7 @@ void jmp_deb2(void) { fprintf(stderr, "Here\n"); }
void jmp_deb(int i) {
if (i)
printf("Here we go %ld\n", old_value++);
printf("Here we go " Int_FORMAT "\n", old_value++);
if (old_value == 716)
jmp_deb2();
}
@ -354,8 +354,8 @@ bool low_level_trace__(yap_low_level_port port, PredEntry *pred, CELL *args) {
printf("\n");
}
#endif
b += snprintf(b, top - b, "%lld %ld ", 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 " "UInt_FORMAT " ", vsc_count, LCL0 - (CELL *)B);
b += snprintf(b, top - b, Int_FORMAT " ", LCL0 - (CELL *)Yap_REGS.CUT_C_TOP);
#if defined(THREADS) || defined(YAPOR)
b += snprintf(b, top - b, "(%d)", worker_id);
#endif
@ -482,7 +482,7 @@ static Int reset_total_choicepoints(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);
}

View File

@ -114,6 +114,9 @@ else()
List (APPEND YLIBS $<TARGET_OBJECTS:libswi> )
if (WIN32)
List (APPEND YLIBS $<TARGET_OBJECTS:YAP++> )
if (PYTHON_INCLUDE_DIRS AND PYTHON_LIBRARIES )
List (APPEND YLIBS $<TARGET_OBJECTS:YAPPython0> )
endif()
endif()
@ -132,6 +135,9 @@ add_library( # Sets the name of the library.
if (WIN32)
target_link_libraries(libYap ${WINDLLS})
if (PYTHON_INCLUDE_DIRS AND PYTHON_LIBRARIES )
target_link_libraries(libYap ${PYTHON_LIBRARIES})
endif()
endif (WIN32)
include(libYap NO_POLICY_SCOPE)

View File

@ -68,7 +68,7 @@ enum PropTag {
* predicates, operators, modules, almost everything.
*
*/
class YAPAtom {
class X_API YAPAtom {
friend class YAPEngine;
friend class YAPModuleProp;
friend class YAPPredicate;
@ -104,7 +104,7 @@ public:
* predicates, operators, modules, almost everything.
*
*/
class YAPProp {
class X_API YAPProp {
friend class YAPModuleProp;
friend class YAPFunctor;
/// does nothing, p is defined by the subclass

View File

@ -43,7 +43,7 @@ class YAPModule;
* Info about the module is in YAPModuleProp
*
*/
class YAPModule : protected YAPAtomTerm {
class X_API YAPModule : protected YAPAtomTerm {
friend class YAPPredicate;
friend class YAPModuleProp;
Term t() { return gt(); }
@ -61,7 +61,7 @@ public:
* A YAPModuleProp controls access to a module property.
*
*/
class YAPModuleProp : public YAPProp {
class X_API YAPModuleProp : public YAPProp {
friend class YAPPredicate;
ModEntry *m;
@ -77,7 +77,7 @@ public:
/**
* @brief YAPFunctor represents Prolog functors Name/Arity
*/
class YAPFunctor : public YAPProp {
class X_API YAPFunctor : public YAPProp {
friend class YAPApplTerm;
friend class YAPTerm;
friend class YAPPredicate;
@ -127,7 +127,7 @@ public:
*
* This class interfaces with PredEntry in Yatom.
*/
class YAPPredicate : public YAPModuleProp {
class X_API YAPPredicate : public YAPModuleProp {
friend class YAPQuery;
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.
*/
class YAPPrologPredicate : public YAPPredicate {
class X_API YAPPrologPredicate : public YAPPredicate {
public:
YAPPrologPredicate(YAPTerm t) : YAPPredicate(t){};
YAPPrologPredicate(const char *s, arity_t arity) : YAPPredicate(s, arity){};
@ -319,7 +319,7 @@ public:
*
* This class interfaces with Predicates Implemented in Prolog.
*/
class YAPFLIP : public YAPPredicate {
class X_API YAPFLIP : public YAPPredicate {
public:
YAPFLIP(CPredicate call, YAPAtom name, uintptr_t arity,
YAPModule module = YAPModule(), CPredicate retry = 0,

View File

@ -1,6 +1,6 @@
#define YAP_CPP_INTERFACE 1
#define _EXPORT_KERNEL 1
#include "yapi.hh"
extern "C" {
@ -1012,7 +1012,7 @@ YAPEngine::YAPEngine(int argc, char *argv[],
return ap;
}
X_API bool YAPPrologPredicate::assertClause(YAPTerm cl, bool last,
bool YAPPrologPredicate::assertClause(YAPTerm cl, bool last,
YAPTerm source)
{
CACHE_REGS

View File

@ -1,4 +1,4 @@
/**
/**
* @file yapie.hh
*
* @defgroup yap-cplus-error-hanadlinge Errir Handling in the YAP interface.
@ -23,11 +23,11 @@
#ifndef YAPIE_HH
#define YAPIE_HH
class YAPPPredicate;
class YAPTerm;
class X_API YAPPPredicate;
class X_API YAPTerm;
/// take information on a Prolog error:
class YAPError {
class X_API YAPError {
yap_error_number ID;
std::string goal, info;
int swigcode;

View File

@ -19,7 +19,7 @@
#ifndef YAPQ_HH
#define YAPQ_HH 1
class YAPPredicate;
class X_API YAPPredicate;
/**
Queries and engines
@ -31,7 +31,7 @@ class YAPPredicate;
* interface to a YAP Query;
* uses an SWI-like status info internally.
*/
class YAPQuery : public YAPPredicate
class X_API YAPQuery : public YAPPredicate
{
bool q_open;
int q_state;
@ -171,7 +171,7 @@ inline bool command()
/// This class implements a callback Prolog-side. It will be inherited by the
/// Java or Python
/// class that actually implements the callback.
class YAPCallback
class X_API YAPCallback
{
public:
virtual ~YAPCallback() {}
@ -181,7 +181,7 @@ public:
/// @brief Setup all arguments to a new engine
class YAPEngineArgs {
class X_API YAPEngineArgs {
public:

View File

@ -34,7 +34,7 @@ class YAPError;
/**
* @brief Generic Prolog Term
*/
class YAPTerm {
class X_API YAPTerm {
friend class YAPPredicate;
friend class YAPPrologPredicate;
friend class YAPQuery;
@ -254,39 +254,10 @@ public:
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
*/
class YAPApplTerm : public YAPTerm {
class X_API YAPApplTerm : public YAPTerm {
friend class YAPTerm;
public:
@ -324,7 +295,7 @@ public:
/**
* @brief List Constructor Term
*/
class YAPPairTerm : public YAPTerm {
class X_API YAPPairTerm : public YAPTerm {
friend class YAPTerm;
@ -362,7 +333,7 @@ public:
* @brief Number Term
*/
class YAPNumberTerm : public YAPTerm {
class X_API YAPNumberTerm : public YAPTerm {
public:
YAPNumberTerm(){};
bool isTagged() { return IsIntTerm(gt()); }
@ -372,7 +343,7 @@ public:
* @brief Integer Term
*/
class YAPIntegerTerm : public YAPNumberTerm {
class X_API YAPIntegerTerm : public YAPNumberTerm {
public:
YAPIntegerTerm(intptr_t i);
intptr_t getInteger() { return IntegerOfTerm(gt()); };
@ -382,14 +353,14 @@ public:
* @brief Floating Point Term
*/
class YAPFloatTerm : public YAPNumberTerm {
class X_API YAPFloatTerm : public YAPNumberTerm {
public:
YAPFloatTerm(double dbl) { mk(MkFloatTerm(dbl)); };
double getFl() { return FloatOfTerm(gt()); };
};
class YAPListTerm : public YAPTerm {
class X_API YAPListTerm : public YAPTerm {
public:
/// Create a list term out of a standard term. Check if a valid operation.
///
@ -447,7 +418,7 @@ public:
/**
* @brief String Term
*/
class YAPStringTerm : public YAPTerm {
class X_API YAPStringTerm : public YAPTerm {
public:
/// your standard constructor
YAPStringTerm(char *s);
@ -464,7 +435,7 @@ public:
* @brief Atom Term
* Term Representation of an Atom
*/
class YAPAtomTerm : public YAPTerm {
class X_API YAPAtomTerm : public YAPTerm {
friend class YAPModule;
// Constructor: receives a C-atom;
YAPAtomTerm(Term t) : YAPTerm(t) { IsAtomTerm(t); }
@ -498,4 +469,35 @@ public:
};
#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
};
/// @}

View File

@ -90,7 +90,6 @@ ATOMS
#ifdef EUROTRA
Term TermDollarU MkAT AtomDollarU
#endif
Term TermAnswer MkAT AtomAnswer
//modules
Term USER_MODULE MkAT AtomUser

View File

@ -83,7 +83,6 @@
#ifdef EUROTRA
#define TermDollarU Yap_heap_regs->TermDollarU_
#endif
#define TermAnswer Yap_heap_regs->TermAnswer_
#define USER_MODULE Yap_heap_regs->USER_MODULE_
#define IDB_MODULE Yap_heap_regs->IDB_MODULE_

View File

@ -87,7 +87,6 @@ EXTERNAL AtomHashEntry *HashChain;
#ifdef EUROTRA
EXTERNAL Term TermDollarU;
#endif
EXTERNAL Term TermAnswer;
//modules
EXTERNAL Term USER_MODULE;
EXTERNAL Term IDB_MODULE;

View File

@ -87,7 +87,6 @@
#ifdef EUROTRA
Term TermDollarU_;
#endif
Term TermAnswer_;
//modules
Term USER_MODULE_;
Term IDB_MODULE_;

View File

@ -83,7 +83,6 @@
#ifdef EUROTRA
TermDollarU = MkAtomTerm(AtomDollarU);
#endif
TermAnswer = MkAtomTerm(AtomAnswer);
USER_MODULE = MkAtomTerm(AtomUser);
IDB_MODULE = MkAtomTerm(AtomIDB);

View File

@ -83,7 +83,6 @@
#ifdef EUROTRA
TermDollarU = AtomTermAdjust(TermDollarU);
#endif
TermAnswer = AtomTermAdjust(TermAnswer);
USER_MODULE = AtomTermAdjust(USER_MODULE);
IDB_MODULE = AtomTermAdjust(IDB_MODULE);

View File

@ -1,6 +1,16 @@
set (Python_ADDITIONAL_VERSIONS 3.7 3.6 3.5 3.6 3.4 )
set (PythonInterp_FIND_VERSION 3)
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)
@ -29,6 +39,7 @@ ENDIF()
if (PYTHONLIBS_FOUND AND SWIG_FOUND)
add_subdirectory(packages/python/swig)
include(FindPythonModule)
find_python_module( jupyter )

View File

@ -2052,24 +2052,5 @@ calls it, or to nothing if 'inline' is not supported under any name. */
#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

View File

@ -81,7 +81,7 @@ typedef struct vfs {
/// in this space, usual w,r,a,b flags plus B (store in a buffer)
bool (*close)(int sno); /// close the object
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
int64_t (*seek)(int sno, int64_t offset,
int whence); /// jump around the stream

View File

@ -18,6 +18,36 @@
#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 <stdio.h>
#include <stdlib.h>

View File

@ -22,6 +22,7 @@
* @addtogroup swi-c-interface
*
*/
#define _EXPORT_KERNEL 1
#include <Yap.h>
#include <Yatom.h>
@ -44,7 +45,7 @@
static PL_blob_t unregistered_blob_atom = {
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
Term yt = Yap_GetFromSlot(t);
Atom a;

View File

@ -20,6 +20,7 @@ Moyle. All rights reserved.
*/
#define PL_KERNEL 1
#define _EXPORT_KERNEL 1
//=== includes ===============================================================
#include <assert.h>

View File

@ -7,7 +7,10 @@ set (PYTHON_HEADERS python.h)
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.
set_property(TARGET YAPPython PROPERTY CXX_STANDARD 11)

View File

@ -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,
term_t py) {

View File

@ -1,6 +1,6 @@
#include "python.h"
#include "py4yap.h"
extern PyObject *py_Local, *py_Global;

View File

@ -1,5 +1,5 @@
#include "python.h"
#include "py4yap.h"
static foreign_t repr_term(PyObject *pVal, term_t t) {
term_t to = PL_new_term_ref(), t1 = PL_new_term_ref();

View File

@ -23,6 +23,12 @@
#define EXTRA_MESSSAGES 1
#ifndef PYTHON_H
#define X_API
#define I_API
#define O_API
#define PYTHON_H 1
PyObject *find_obj(PyObject *ob, term_t lhs, bool eval);

View File

@ -1,4 +1,4 @@
#include "python.h"
#include "py4yap.h"
/**
*
@ -700,6 +700,7 @@ static PyObject *structseq_repr(PyObject *iobj) {
}
#endif
PyObject *term_to_nametuple(const char *s, arity_t arity, PyObject *tuple) {
PyObject *o;
#if PY_MAJOR_VERSION >= 3
@ -722,7 +723,7 @@ PyObject *term_to_nametuple(const char *s, arity_t arity, PyObject *tuple) {
return NULL;
typp->tp_flags &= ~Py_TPFLAGS_HEAPTYPE;
// typp->tp_str = structseq_str;
// typp->tp_repr = structseq_repr;
typp->tp_repr = structseq_repr;
// typp = PyStructSequence_NewType(desc);
// don't do this: we cannot add a type as an atribute.
//PyModule_AddObject(py_Main, s, (PyObject *)typp);

27
packages/python/pyload.c Normal file
View 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

View File

@ -1,5 +1,5 @@
#include "python.h"
#include "py4yap.h"
PyObject *py_Main;

View File

@ -1,6 +1,5 @@
#include "python.h"
#include <YapStreams.h>
#include "py4yap.h"
#include <VFS.h>
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;
}
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

View File

@ -1,7 +1,7 @@
# This is a CMake example for Python
INCLUDE(NewUseSWIG)
#INCLUDE(NewUseSWIG)
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(../../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
# s used in MSYS
@ -66,6 +50,9 @@ endif()
set (PL ${pl_library} ${PROLOG_SOURCES} )
add_custom_target( YAP4PY_SETUP
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 make_directory ${CMAKE_CURRENT_BINARY_DIR}/yap4py/prolog

View File

@ -1,3 +0,0 @@
// make Python happy...

View File

@ -18,23 +18,23 @@ import os.path
# the name of the package
name = 'YAP4PY'
#-----------------------------------------------------------------------------
# -----------------------------------------------------------------------------
# Minimal Python version sanity check
#-----------------------------------------------------------------------------
# -----------------------------------------------------------------------------
import sys
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
print(error, file=sys.stderr)
sys.exit(1)
PY3 = (sys.version_info[0] >= 3)
#-----------------------------------------------------------------------------
# -----------------------------------------------------------------------------
# get on with it
#-----------------------------------------------------------------------------
# -----------------------------------------------------------------------------
from codecs import open
from os import path, makedirs, walk
from shutil import copytree, rmtree, copy2, move
@ -53,85 +53,86 @@ pkg_root = pjoin(here, name)
my_extra_link_args = []
if platform.system() == 'Darwin':
my_extra_link_args = ['-Wl,-rpath','-Wl,${_ABS_PYTHON_MODULE_PATH}']
so = 'dylib'
#or dll in glob('yap/dlls/*'):
my_extra_link_args = ['-Wl,-rpath', '-Wl,${_ABS_PYTHON_MODULE_PATH}']
# or dll in glob('yap/dlls/*'):
# 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']
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
native_sources = ['yap.i']
here = path.abspath(path.dirname(__file__))
# Get the long description from the README file
extensions=[Extension('_yap', native_sources,
define_macros = [('MAJOR_VERSION', '1'),
extensions = [Extension('_yap', native_sources,
define_macros=[('MAJOR_VERSION', '1'),
('MINOR_VERSION', '0'),
('_YAP_NOT_INSTALLED_', '1'),
('_GNU_SOURCE', '1'),
('YAP_PYTHON', '1')],
runtime_library_dirs=['yap4py','${libdir}','${bindir}'],
swig_opts=['-modern', '-c++', '-py3','-I${RELATIVE_SOURCE}/CXX'],
library_dirs=['../../..','../../../CXX','../../packages/python',"${dlls}","${bindir}", '.'],
runtime_library_dirs=['yap4py', '${libdir}', '${bindir}'],
swig_opts=['-modern', '-c++', '-py3', '-I${CMAKE_SOURCE_DIR}/CXX', '-I${CMAKE_SOURCE_DIR}/include',
'-I${CMAKE_SOURCE_DIR}/H', '-I${CMAKE_SOURCE_DIR}/H/generated',
'-I${CMAKE_SOURCE_DIR}/os', '-I${CMAKE_SOURCE_DIR}/OPTYap', '-I../../..'],
library_dirs=['../../..', '../../../CXX', '../../packages/python', "${dlls}", "${bindir}", '.'],
extra_link_args=my_extra_link_args,
extra_compile_args=['-std=c++11','-g3','-O0'],
libraries=['Yap','${GMP_LIBRARIES}'],
libraries=['Yap', '${GMP_LIBRARIES}'],
include_dirs=['../../..',
'${GMP_INCLUDE_DIRS}',
'${RELATIVE_SOURCE}H',
'${RELATIVE_SOURCE}H/generated',
'${RELATIVE_SOURCE}OPTYap',
'${RELATIVE_SOURCE}os',
'${RELATIVE_SOURCE}include',
'${RELATIVE_SOURCE}CXX', '.']
)]
'${CMAKE_SOURCE_DIR}/H',
'${CMAKE_SOURCE_DIR}/H/generated',
'${CMAKE_SOURCE_DIR}/OPTYap',
'${CMAKE_SOURCE_DIR}/os',
'${CMAKE_SOURCE_DIR}/include',
'${CMAKE_SOURCE_DIR}/CXX', '.']
)]
packages = ['yap4py']
def visit(d0, pls):
for (r,ds,fs) in walk('.'):
for (r, ds, fs) in walk('.'):
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'):
pls += [os.path.join(r, f)]
for i in ds:
pls = visit(os.path.join(d0, i), pls)
return pls
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(
name = name,
version = version_ns['__version__'],
scripts = glob(pjoin('scripts', '*')),
packages = packages,
py_modules = ['yap'],
package_data = package_data,
include_package_data = True,
description = "YAP in Python",
author = 'YAP Development Team',
author_email = 'ipython-dev@scipy.org',
url = 'http://ipython.org',
license = 'BSD',
ext_modules = extensions,
platforms = "Linux, Mac OS X, Windows",
keywords = ['Interactive', 'Interpreter', 'Shell', 'Web'],
classifiers = [
name=name,
version=version_ns['__version__'],
scripts=glob(pjoin('scripts', '*')),
packages=packages,
py_modules=['yap'],
package_data=package_data,
include_package_data=True,
description="YAP in Python",
author='YAP Development Team',
author_email='ipython-dev@scipy.org',
url='http://ipython.org',
license='BSD',
ext_modules=extensions,
platforms="Linux, Mac OS X, Windows",
keywords=['Interactive', 'Interpreter', 'Shell', 'Web'],
classifiers=[
'Intended Audience :: Developers',
'Intended Audience :: System Administrators',
'Intended Audience :: Science/Research',

View File

@ -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

View File

@ -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

View File

@ -1 +0,0 @@
yapex