swig
This commit is contained in:
parent
d05b1f4b2b
commit
dd48ba6f91
@ -28,7 +28,7 @@
|
||||
* mirroring
|
||||
*/
|
||||
|
||||
#include "../utf8proc/utf8proc.h"
|
||||
#include "utf8proc.h"
|
||||
#include "Yap.h"
|
||||
|
||||
/// allocate a temporary text block
|
||||
|
42
H/Yatom.h
42
H/Yatom.h
@ -443,28 +443,40 @@ don't forget to also add in qly.h
|
||||
*/
|
||||
/// Different predicate flags
|
||||
typedef uint64_t pred_flags_t;
|
||||
#define UndefPredFlag ((pred_flags_t)0x4000000000) //< Predicate not explicitely defined.
|
||||
#define UndefPredFlag \
|
||||
((pred_flags_t)0x4000000000) //< Predicate not explicitely defined.
|
||||
#define ProfiledPredFlag ((pred_flags_t)0x2000000000) //< pred is being profiled
|
||||
#define DiscontiguousPredFlag ((pred_flags_t)0x1000000000) //< predicates whose clauses may be all-over the place..
|
||||
#define SysExportPredFlag ((pred_flags_t)0x800000000) //< reuse export list to prolog module.
|
||||
#define NoTracePredFlag ((pred_flags_t)0x400000000) //< cannot trace this predicate
|
||||
#define DiscontiguousPredFlag \
|
||||
((pred_flags_t)0x1000000000) //< predicates whose clauses may be all-over the
|
||||
// place..
|
||||
#define SysExportPredFlag \
|
||||
((pred_flags_t)0x800000000) //< reuse export list to prolog module.
|
||||
#define NoTracePredFlag \
|
||||
((pred_flags_t)0x400000000) //< cannot trace this predicate
|
||||
#define NoSpyPredFlag ((pred_flags_t)0x200000000) //< cannot spy this predicate
|
||||
#define QuasiQuotationPredFlag ((pred_flags_t)0x100000000) //< SWI-like quasi quotations
|
||||
#define MegaClausePredFlag ((pred_flags_t)0x80000000) //< predicate is implemented as a mega-clause
|
||||
#define QuasiQuotationPredFlag \
|
||||
((pred_flags_t)0x100000000) //< SWI-like quasi quotations
|
||||
#define MegaClausePredFlag \
|
||||
((pred_flags_t)0x80000000) //< predicate is implemented as a mega-clause
|
||||
#define ThreadLocalPredFlag ((pred_flags_t)0x40000000) //< local to a thread
|
||||
#define MultiFileFlag ((pred_flags_t)0x20000000) //< is multi-file
|
||||
#define UserCPredFlag ((pred_flags_t)0x10000000) //< CPred defined by the user
|
||||
#define LogUpdatePredFlag ((pred_flags_t)0x08000000) //< dynamic predicate with log. upd. sem.
|
||||
#define LogUpdatePredFlag \
|
||||
((pred_flags_t)0x08000000) //< dynamic predicate with log. upd. sem.
|
||||
#define InUsePredFlag ((pred_flags_t)0x04000000) //< count calls to pred
|
||||
#define CountPredFlag ((pred_flags_t)0x02000000) //< count calls to pred
|
||||
#define HiddenPredFlag ((pred_flags_t)0x01000000) //< invisible predicate
|
||||
#define CArgsPredFlag ((pred_flags_t)0x00800000) //< SWI-like C-interface pred.
|
||||
#define SourcePredFlag ((pred_flags_t)0x00400000) //< static predicate with source declaration
|
||||
#define MetaPredFlag ((pred_flags_t)0x00200000) //< predicate subject to a meta declaration
|
||||
#define SyncPredFlag ((pred_flags_t)0x00100000) //< has to synch before it can execute
|
||||
#define SourcePredFlag \
|
||||
((pred_flags_t)0x00400000) //< static predicate with source declaration
|
||||
#define MetaPredFlag \
|
||||
((pred_flags_t)0x00200000) //< predicate subject to a meta declaration
|
||||
#define SyncPredFlag \
|
||||
((pred_flags_t)0x00100000) //< has to synch before it can execute
|
||||
#define NumberDBPredFlag ((pred_flags_t)0x00080000) //< entry for an atom key
|
||||
#define AtomDBPredFlag ((pred_flags_t)0x00040000) //< entry for a number key
|
||||
// #define GoalExPredFlag ((pred_flags_t)0x00020000) /// predicate that is called by goal_expand
|
||||
// #define GoalExPredFlag ((pred_flags_t)0x00020000) /// predicate that is
|
||||
// called by goal_expand
|
||||
#define TestPredFlag ((pred_flags_t)0x00010000) //< is a test (optim. comit)
|
||||
#define AsmPredFlag ((pred_flags_t)0x00008000) //< inline
|
||||
#define StandardPredFlag ((pred_flags_t)0x00004000) //< system predicate
|
||||
@ -476,7 +488,8 @@ typedef uint64_t pred_flags_t;
|
||||
#define SpiedPredFlag ((pred_flags_t)0x00000100) //< is a spy point
|
||||
#define BinaryPredFlag ((pred_flags_t)0x00000080) //< test predicate
|
||||
#define TabledPredFlag ((pred_flags_t)0x00000040) //< is tabled
|
||||
#define SequentialPredFlag ((pred_flags_t)0x00000020) //< may not create parallel choice points!
|
||||
#define SequentialPredFlag \
|
||||
((pred_flags_t)0x00000020) //< may not create parallel choice points!
|
||||
#define BackCPredFlag ((pred_flags_t)0x00000008) //< Myddas Imported pred
|
||||
#define ModuleTransparentPredFlag ((pred_flags_t)0x00000004)
|
||||
#define SWIEnvPredFlag ((pred_flags_t)0x00000002) //< new SWI interface
|
||||
@ -1178,7 +1191,7 @@ INLINE_ONLY inline EXTERN bool IsArrayProperty(PropFlags flags) {
|
||||
typedef struct YAP_blob_prop_entry {
|
||||
Prop NextOfPE; /* used to chain properties */
|
||||
PropFlags KindOfPE; /* kind of property */
|
||||
struct YAP_blob_t *blob_type; /* type of blob */
|
||||
struct _PL_blob_t *blob_type; /* type of blob */
|
||||
} YAP_BlobPropEntry;
|
||||
|
||||
#if USE_OFFSETS_IN_PROPS
|
||||
@ -1501,7 +1514,8 @@ INLINE_ONLY EXTERN inline Prop PredPropByAtomAndMod(Atom at, Term cur_mod)
|
||||
p0 = ae->PropsOfAE;
|
||||
while (p0) {
|
||||
PredEntry *pe = RepPredProp(p0);
|
||||
if (pe->KindOfPE == PEProp && (pe->ModuleOfPred == cur_mod || pe->ModuleOfPred == 0)) {
|
||||
if (pe->KindOfPE == PEProp &&
|
||||
(pe->ModuleOfPred == cur_mod || pe->ModuleOfPred == 0)) {
|
||||
#ifdef THREADS
|
||||
/* Thread Local Predicates */
|
||||
if (pe->PredFlags & ThreadLocalPredFlag) {
|
||||
|
81
H/blobs.h
81
H/blobs.h
@ -1,81 +0,0 @@
|
||||
//
|
||||
// blobs.h
|
||||
// yap
|
||||
//
|
||||
// Created by VITOR SANTOS COSTA on 09/05/15.
|
||||
// Copyright (c) 2015 VITOR SANTOS COSTA. All rights reserved.
|
||||
//
|
||||
|
||||
// based on the SWI Blob implementation, an extension of atoms for SWI-Prolog
|
||||
|
||||
#ifndef BLOBS_H
|
||||
#define BLOBS_H
|
||||
|
||||
#if !defined(X_API) && !defined(SWIGYAP)
|
||||
#if (defined(_MSC_VER) || defined(__MINGW32__)) && defined(PL_KERNEL)
|
||||
#define X_API __declspec(dllexport)
|
||||
#else
|
||||
#define X_API
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*******************************
|
||||
* BLOBS *
|
||||
*******************************/
|
||||
|
||||
#define YAP_BLOB_MAGIC_B 0x75293a00 /* Magic to validate a blob-type */
|
||||
#define PL_BLOB_VERSION (YAP_BLOB_MAGIC_B|PL_BLOB_VERSION)
|
||||
|
||||
#define PL_BLOB_UNIQUE 0x01 /* Blob content is unique */
|
||||
#define PL_BLOB_TEXT 0x02 /* blob contains text */
|
||||
#define PL_BLOB_NOCOPY 0x04 /* do not copy the data */
|
||||
#define PL_BLOB_WCHAR 0x08 /* wide character string */
|
||||
|
||||
typedef struct YAP_blob_t
|
||||
{ uintptr_t magic; /* YAP_BLOB_MAGIC */
|
||||
uintptr_t flags; /* YAP_BLOB_* */
|
||||
char * name; /* name of the type */
|
||||
int (*release)(Atom a);
|
||||
int (*compare)(Atom a, Atom b);
|
||||
#ifdef SIO_MAGIC
|
||||
int (*write)(FILE *s, Atom a, int flags);
|
||||
#else
|
||||
int (*write)(void *s, Atom a, int flags);
|
||||
#endif
|
||||
void (*acquire)(Atom a);
|
||||
#ifdef SIO_MAGIC
|
||||
int (*save)(Atom a, FILE *s);
|
||||
Atom (*load)(FILE *s);
|
||||
#else
|
||||
int (*save)(Atom a, void*);
|
||||
Atom (*load)(void *s);
|
||||
#endif
|
||||
/* private */
|
||||
void * reserved[10]; /* for future extension */
|
||||
int registered; /* Already registered? */
|
||||
int rank; /* Rank for ordering atoms */
|
||||
struct YAP_blob_t * next; /* next in registered type-chain */
|
||||
Atom atom_name; /* Name as atom */
|
||||
} blob_type_t;
|
||||
|
||||
int Yap_write_blob(AtomEntry *ref, FILE *stream);
|
||||
char * Yap_blob_to_string(AtomEntry *ref, const char *s, size_t sz);
|
||||
X_API bool YAP_is_blob(YAP_Term t, blob_type_t **type);
|
||||
X_API bool YAP_unify_blob(YAP_Term *t, void *blob, size_t len,
|
||||
blob_type_t *type);
|
||||
X_API bool YAP_put_blob(YAP_Term *t, void *blob, size_t len,
|
||||
blob_type_t *type);
|
||||
X_API bool YAP_get_blob(YAP_Term t, void **blob, size_t *len,
|
||||
blob_type_t **type);
|
||||
|
||||
X_API void* YAP_blob_data(Atom a,
|
||||
size_t *len,
|
||||
struct YAP_blob_t **type);
|
||||
|
||||
X_API void YAP_register_blob_type(blob_type_t *type);
|
||||
X_API blob_type_t* YAP_find_blob_type(const char* name);
|
||||
//YAP_blob_type_t* YAP_find_blob_type(Atom at);
|
||||
X_API bool YAP_unregister_blob_type(blob_type_t *type);
|
||||
|
||||
|
||||
#endif
|
@ -25,7 +25,6 @@ extern "C" {
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#if USE_GMP
|
||||
#if defined(__cplusplus)
|
||||
#include <gmpxx.h>
|
||||
@ -41,11 +40,11 @@ extern "C" {
|
||||
#include "YapInterface.h"
|
||||
#else
|
||||
#if _YAP_NOT_INSTALLED_
|
||||
#include <config.h>
|
||||
#include <YapInterface.h>
|
||||
#include <config.h>
|
||||
#else
|
||||
#include <Yap/pl/config.h>
|
||||
#include <Yap/YapInterface.h>
|
||||
#include <Yap/pl/config.h>
|
||||
#endif
|
||||
#endif
|
||||
#include <stdarg.h>
|
||||
@ -76,12 +75,8 @@ typedef int _Bool;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#include "pl-types.h"
|
||||
|
||||
|
||||
|
||||
|
||||
/*******************************
|
||||
* EXPORT *
|
||||
*******************************/
|
||||
@ -105,10 +100,9 @@ stuff.
|
||||
#define WUNUSED
|
||||
#endif
|
||||
|
||||
|
||||
#include "pl-types.h"
|
||||
typedef struct _PL_extension
|
||||
{ const char *predicate_name; /* Name of the predicate */
|
||||
typedef struct _PL_extension {
|
||||
const char *predicate_name; /* Name of the predicate */
|
||||
short arity; /* Arity of the predicate */
|
||||
pl_function_t function; /* Implementing functions */
|
||||
short flags; /* Or of PL_FA_... */
|
||||
@ -116,8 +110,8 @@ typedef struct _PL_extension
|
||||
|
||||
#define PL_THREAD_NO_DEBUG 0x01 /* Start thread in nodebug mode */
|
||||
|
||||
typedef struct
|
||||
{ unsigned long local_size; /* Stack sizes */
|
||||
typedef struct {
|
||||
unsigned long local_size; /* Stack sizes */
|
||||
unsigned long global_size;
|
||||
unsigned long trail_size;
|
||||
unsigned long argument_size;
|
||||
@ -129,7 +123,6 @@ typedef struct
|
||||
|
||||
typedef void *PL_engine_t;
|
||||
|
||||
|
||||
#define PL_FA_NOTRACE (0x01) /* foreign cannot be traced */
|
||||
#define PL_FA_TRANSPARENT (0x02) /* foreign is module transparent */
|
||||
#define PL_FA_NONDETERMINISTIC (0x04) /* foreign is non-deterministic */
|
||||
@ -185,12 +178,12 @@ typedef void *PL_engine_t;
|
||||
/* Or'ed flags for PL_set_prolog_flag() */
|
||||
/* MUST fit in a short int! */
|
||||
#define FF_READONLY 0x1000 /* Read-only prolog flag */
|
||||
#define FF_KEEP 0x2000 /* keep prolog flag if already se
|
||||
#define FF_KEEP \
|
||||
0x2000 /* keep prolog flag if already se \
|
||||
t */
|
||||
#define FF_NOCREATE 0x4000 /* Fail if flag is non-existent */
|
||||
#define FF_MASK 0xf000
|
||||
|
||||
|
||||
#define CVT_ATOM 0x0001
|
||||
#define CVT_STRING 0x0002
|
||||
#define CVT_LIST 0x0004
|
||||
@ -231,15 +224,14 @@ t */
|
||||
#define PL_ACTION_GUIAPP 10 /* Win32: set when this is a gui */
|
||||
#define PL_ACTION_ATTACH_CONSOLE 11 /* MT: Attach a console */
|
||||
|
||||
|
||||
typedef enum
|
||||
{ FRG_FIRST_CALL = 0, /* Initial call */
|
||||
typedef enum {
|
||||
FRG_FIRST_CALL = 0, /* Initial call */
|
||||
FRG_CUTTED = 1, /* Context was cutted */
|
||||
FRG_REDO = 2 /* Normal redo */
|
||||
} frg_code;
|
||||
|
||||
struct foreign_context
|
||||
{ uintptr_t context; /* context value */
|
||||
struct foreign_context {
|
||||
uintptr_t context; /* context value */
|
||||
frg_code control; /* FRG_* action */
|
||||
struct PL_local_data *engine; /* invoking engine */
|
||||
};
|
||||
@ -247,21 +239,20 @@ struct foreign_context
|
||||
typedef struct foreign_context *control_t;
|
||||
|
||||
#define PRED_IMPL(name, arity, fname, flags) \
|
||||
foreign_t \
|
||||
pl_ ## fname ## arity ## _va(term_t PL__t0, int PL__ac, control_t PL__ctx)
|
||||
foreign_t pl_##fname##arity##_va(term_t PL__t0, int PL__ac, control_t PL__ctx)
|
||||
|
||||
#define CTX_CNTRL ForeignControl(PL__ctx)
|
||||
#define CTX_PTR ForeignContextPtr(PL__ctx)
|
||||
#define CTX_INT ForeignContextInt(PL__ctx)
|
||||
#define CTX_ARITY PL__ac
|
||||
|
||||
#define BeginPredDefs(id) \
|
||||
const PL_extension PL_predicates_from_ ## id[] = {
|
||||
#define BeginPredDefs(id) const PL_extension PL_predicates_from_##id[] = {
|
||||
#define PRED_DEF(name, arity, fname, flags) \
|
||||
{name, arity, pl_##fname##arity##_va, (flags) | PL_FA_VARARGS},
|
||||
#define EndPredDefs \
|
||||
{ NULL, 0, NULL, 0 } \
|
||||
};
|
||||
} \
|
||||
;
|
||||
|
||||
#define FRG_REDO_MASK 0x00000003L
|
||||
#define FRG_REDO_BITS 2
|
||||
@ -279,8 +270,10 @@ typedef struct foreign_context *control_t;
|
||||
#define ForeignContextPtr(h) ((void *)(h)->context)
|
||||
#define ForeignEngine(h) ((h)->engine)
|
||||
|
||||
#define FRG(n, a, f, flags) { n, a, f, flags }
|
||||
#define LFRG(n, a, f, flags) { n, a, f, flags }
|
||||
#define FRG(n, a, f, flags) \
|
||||
{ n, a, f, flags }
|
||||
#define LFRG(n, a, f, flags) \
|
||||
{ n, a, f, flags }
|
||||
|
||||
/* end from pl-itf.h */
|
||||
|
||||
@ -313,9 +306,8 @@ UNICODE file functions.
|
||||
PL_EXPORT(int) PL_unify_stream(term_t t, IOSTREAM *s);
|
||||
PL_EXPORT(int) PL_get_stream_handle(term_t t, IOSTREAM **s);
|
||||
PL_EXPORT(int) PL_release_stream(IOSTREAM *s);
|
||||
PL_EXPORT(IOSTREAM *) PL_open_resource(module_t m,
|
||||
const char *name,
|
||||
const char *rc_class,
|
||||
PL_EXPORT(IOSTREAM *)
|
||||
PL_open_resource(module_t m, const char *name, const char *rc_class,
|
||||
const char *mode);
|
||||
|
||||
PL_EXPORT(IOSTREAM *) * _PL_streams(void); /* base of streams */
|
||||
@ -337,9 +329,7 @@ PL_EXPORT(IOSTREAM *)*_PL_streams(void); /* base of streams */
|
||||
#define PL_WRT_ATTVAR_WRITE 0x100 /* Write as Var{Attributes} */
|
||||
#define PL_WRT_ATTVAR_PORTRAY 0x200 /* Use Module:portray_attrs/2 */
|
||||
#define PL_WRT_ATTVAR_MASK \
|
||||
(PL_WRT_ATTVAR_IGNORE | \
|
||||
PL_WRT_ATTVAR_DOTS | \
|
||||
PL_WRT_ATTVAR_WRITE | \
|
||||
(PL_WRT_ATTVAR_IGNORE | PL_WRT_ATTVAR_DOTS | PL_WRT_ATTVAR_WRITE | \
|
||||
PL_WRT_ATTVAR_PORTRAY)
|
||||
#define PL_WRT_BLOB_PORTRAY 0x400 /* Use portray to emit non-text blobs */
|
||||
#define PL_WRT_NO_CYCLES 0x800 /* Never emit @(Template,Subst) */
|
||||
@ -347,10 +337,8 @@ PL_EXPORT(IOSTREAM *)*_PL_streams(void); /* base of streams */
|
||||
#define PL_WRT_NEWLINE 0x2000 /* Add a newline */
|
||||
#define PL_WRT_VARNAMES 0x4000 /* Internal: variable_names(List) */
|
||||
|
||||
PL_EXPORT(int) PL_write_term(IOSTREAM *s,
|
||||
term_t term,
|
||||
int precedence,
|
||||
int flags);
|
||||
PL_EXPORT(int)
|
||||
PL_write_term(IOSTREAM *s, term_t term, int precedence, int flags);
|
||||
|
||||
/* PL_ttymode() results */
|
||||
#define PL_NOTTY 0 /* -tty in effect */
|
||||
@ -361,9 +349,7 @@ PL_EXPORT(int) PL_ttymode(IOSTREAM *s);
|
||||
|
||||
#endif /*SIO_MAGIC*/
|
||||
|
||||
PL_EXPORT(int) PL_chars_to_term(const char *chars,
|
||||
term_t term);
|
||||
|
||||
PL_EXPORT(int) PL_chars_to_term(const char *chars, term_t term);
|
||||
|
||||
/*******************************
|
||||
* CALL-BACK *
|
||||
@ -484,9 +470,9 @@ PL_EXPORT(int) PL_chars_to_term(const char *chars,
|
||||
|
||||
PL_EXPORT(int) PL_skip_list(term_t list, term_t tail, size_t *len);
|
||||
|
||||
|
||||
PL_EXPORT(int) PL_unify_wchars(term_t, int, size_t, const pl_wchar_t *);
|
||||
PL_EXPORT( int ) PL_unify_wchars_diff(term_t, term_t, int, size_t, const pl_wchar_t *);
|
||||
PL_EXPORT(int)
|
||||
PL_unify_wchars_diff(term_t, term_t, int, size_t, const pl_wchar_t *);
|
||||
PL_EXPORT(int) PL_chars_to_term(const char *, term_t);
|
||||
/* begin PL_is_* functions =============================*/
|
||||
PL_EXPORT(int) PL_is_atom(term_t);
|
||||
@ -534,9 +520,12 @@ PL_EXPORT(int) PL_skip_list(term_t list, term_t tail, size_t *len);
|
||||
PL_EXPORT(int) PL_call_predicate(module_t, int, predicate_t, term_t);
|
||||
PL_EXPORT(int) PL_call(term_t, module_t);
|
||||
PL_EXPORT(void) PL_register_foreign(const char *, int, pl_function_t, int);
|
||||
PL_EXPORT( void ) PL_register_foreign_in_module(const char *, const char *, int, pl_function_t, int);
|
||||
PL_EXPORT(void)
|
||||
PL_register_foreign_in_module(const char *, const char *, int, pl_function_t,
|
||||
int);
|
||||
PL_EXPORT(void) PL_register_extensions(const PL_extension *);
|
||||
PL_EXPORT( void ) PL_register_extensions_in_module(const char *module, const PL_extension *);
|
||||
PL_EXPORT(void)
|
||||
PL_register_extensions_in_module(const char *module, const PL_extension *);
|
||||
PL_EXPORT(void) PL_load_extensions(const PL_extension *);
|
||||
PL_EXPORT(int) PL_handle_signals(void);
|
||||
PL_EXPORT(int) PL_thread_self(void);
|
||||
@ -554,7 +543,8 @@ PL_EXPORT(int) PL_skip_list(term_t list, term_t tail, size_t *len);
|
||||
PL_EXPORT(int) PL_recorded(record_t, term_t);
|
||||
PL_EXPORT(record_t) PL_duplicate_record(record_t);
|
||||
PL_EXPORT(void) PL_erase(record_t);
|
||||
/* only partial implementation, does not guarantee export between different architectures and versions of YAP */
|
||||
/* only partial implementation, does not guarantee export between different
|
||||
* architectures and versions of YAP */
|
||||
PL_EXPORT(char *) PL_record_external(term_t, size_t *);
|
||||
PL_EXPORT(int) PL_recorded_external(const char *, term_t);
|
||||
PL_EXPORT(int) PL_erase_external(char *);
|
||||
@ -572,9 +562,6 @@ PL_EXPORT(int) PL_skip_list(term_t list, term_t tail, size_t *len);
|
||||
|
||||
PL_EXPORT(int) PL_unify_list_codes(term_t l, const char *chas);
|
||||
|
||||
|
||||
|
||||
|
||||
PL_EXPORT(void) PL_add_to_protocol(const char *buf, size_t count);
|
||||
|
||||
#define PL_SIGSYNC 0x00010000 /* call handler synchronously */
|
||||
@ -623,9 +610,8 @@ PL_EXPORT(char *) PL_prompt_string(int fd);
|
||||
PL_EXPORT(void) PL_write_prompt(int dowrite);
|
||||
PL_EXPORT(void) PL_prompt_next(int fd);
|
||||
PL_EXPORT(char *) PL_atom_generator(const char *prefix, int state);
|
||||
PL_EXPORT(pl_wchar_t*) PL_atom_generator_w(const pl_wchar_t *pref,
|
||||
pl_wchar_t *buffer,
|
||||
size_t buflen,
|
||||
PL_EXPORT(pl_wchar_t *)
|
||||
PL_atom_generator_w(const pl_wchar_t *pref, pl_wchar_t *buffer, size_t buflen,
|
||||
int state);
|
||||
|
||||
/*******************************
|
||||
@ -642,13 +628,12 @@ PL_EXPORT(pl_wchar_t*) PL_atom_generator_w(const pl_wchar_t *pref,
|
||||
#endif
|
||||
#include <windows.h>
|
||||
|
||||
PL_EXPORT(LRESULT) PL_win_message_proc(HWND hwnd,
|
||||
UINT message,
|
||||
PL_EXPORT(LRESULT)
|
||||
PL_win_message_proc(HWND hwnd, UINT message,
|
||||
// WPARAM wParam,
|
||||
LPARAM lParam);
|
||||
#endif /*_WINDOWS_*/
|
||||
|
||||
|
||||
/********************************
|
||||
* QUERY PROLOG *
|
||||
*********************************/
|
||||
@ -696,11 +681,10 @@ PL_EXPORT(int) PL_representation_error(const char *resource);
|
||||
PL_EXPORT(int) PL_type_error(const char *expected, term_t culprit);
|
||||
PL_EXPORT(int) PL_domain_error(const char *expected, term_t culprit);
|
||||
PL_EXPORT(int) PL_existence_error(const char *type, term_t culprit);
|
||||
PL_EXPORT(int) PL_permission_error(const char *operation,
|
||||
const char *type, term_t culprit);
|
||||
PL_EXPORT(int)
|
||||
PL_permission_error(const char *operation, const char *type, term_t culprit);
|
||||
PL_EXPORT(int) PL_resource_error(const char *resource);
|
||||
|
||||
|
||||
/*******************************
|
||||
* PROLOG FLAGS *
|
||||
*******************************/
|
||||
@ -708,66 +692,8 @@ PL_EXPORT(int) PL_resource_error(const char *resource);
|
||||
#define PL_set_feature PL_set_prolog_flag /* compatibility */
|
||||
PL_EXPORT(int) PL_set_prolog_flag(const char *name, int type, ...);
|
||||
|
||||
#include <blobs.h>
|
||||
|
||||
/*******************************
|
||||
* BLOBS *
|
||||
*******************************/
|
||||
#ifndef BLOBS_H
|
||||
#define PL_BLOB_MAGIC_B 0x75293a00 /* Magic to validate a blob-type */
|
||||
#define PL_BLOB_VERSION 1 /* Current version */
|
||||
#define PL_BLOB_MAGIC (PL_BLOB_MAGIC_B|PL_BLOB_VERSION)
|
||||
|
||||
#define PL_BLOB_UNIQUE 0x01 /* Blob content is unique */
|
||||
#define PL_BLOB_TEXT 0x02 /* blob contains text */
|
||||
#define PL_BLOB_NOCOPY 0x04 /* do not copy the data */
|
||||
#define PL_BLOB_WCHAR 0x08 /* wide character string */
|
||||
|
||||
typedef struct PL_blob_t
|
||||
{ uintptr_t magic; /* PL_BLOB_MAGIC */
|
||||
uintptr_t flags; /* PL_BLOB_* */
|
||||
char * name; /* name of the type */
|
||||
int (*release)(atom_t a);
|
||||
int (*compare)(atom_t a, atom_t b);
|
||||
#ifdef SIO_MAGIC
|
||||
int (*write)(IOSTREAM *s, atom_t a, int flags);
|
||||
#else
|
||||
int (*write)(void *s, atom_t a, int flags);
|
||||
#endif
|
||||
void (*acquire)(atom_t a);
|
||||
#ifdef SIO_MAGIC
|
||||
int (*save)(atom_t a, IOSTREAM *s);
|
||||
atom_t (*load)(IOSTREAM *s);
|
||||
#else
|
||||
int (*save)(atom_t a, void*);
|
||||
atom_t (*load)(void *s);
|
||||
#endif
|
||||
/* private */
|
||||
void * reserved[10]; /* for future extension */
|
||||
int registered; /* Already registered? */
|
||||
int rank; /* Rank for ordering atoms */
|
||||
struct PL_blob_t * next; /* next in registered type-chain */
|
||||
atom_t atom_name; /* Name as atom */
|
||||
} PL_blob_t;
|
||||
|
||||
PL_EXPORT(int) PL_is_blob(term_t t, PL_blob_t **type);
|
||||
PL_EXPORT(int) PL_unify_blob(term_t t, void *blob, size_t len,
|
||||
PL_blob_t *type);
|
||||
PL_EXPORT(int) PL_put_blob(term_t t, void *blob, size_t len,
|
||||
PL_blob_t *type);
|
||||
PL_EXPORT(int) PL_get_blob(term_t t, void **blob, size_t *len,
|
||||
PL_blob_t **type);
|
||||
|
||||
PL_EXPORT(void*) PL_blob_data(atom_t a,
|
||||
size_t *len,
|
||||
struct PL_blob_t **type);
|
||||
|
||||
PL_EXPORT(void) PL_register_blob_type(PL_blob_t *type);
|
||||
PL_EXPORT(PL_blob_t*) PL_find_blob_type(const char* name);
|
||||
PL_EXPORT(PL_blob_t*) YAP_find_blob_type(YAP_Atom at);
|
||||
PL_EXPORT(int) PL_unr1egister_blob_type(PL_blob_t *type);
|
||||
PL_EXPORT(int) PL_raise(int sig);
|
||||
|
||||
#endif
|
||||
#if USE_GMP && !defined(__cplusplus)
|
||||
|
||||
#include <gmp.h>
|
||||
@ -785,7 +711,6 @@ void swi_install(void);
|
||||
|
||||
X_API int PL_warning(const char *msg, ...);
|
||||
|
||||
|
||||
/********************************
|
||||
* NON-DETERMINISTIC CALL/RETURN *
|
||||
*********************************/
|
||||
|
95
include/blobs.h
Normal file
95
include/blobs.h
Normal file
@ -0,0 +1,95 @@
|
||||
//
|
||||
// blobs.h
|
||||
// yap
|
||||
//
|
||||
// Created by VITOR SANTOS COSTA on 09/05/15.
|
||||
// Copyright (c) 2015 VITOR SANTOS COSTA. All rights reserved.
|
||||
//
|
||||
|
||||
// based on the SWI Blob implementation, an extension of atoms for SWI-Prolog
|
||||
|
||||
#ifndef BLOBS_H
|
||||
#define BLOBS_H
|
||||
|
||||
/*******************************
|
||||
* BLOBS *
|
||||
*******************************/
|
||||
|
||||
#define PL_BLOB_MAGIC_B 0x75293a00 /* Magic to validate a blob-type */
|
||||
#define PL_BLOB_VERSION 1
|
||||
#define PL_BLOB_MAGIC (PL_BLOB_MAGIC_B | PL_BLOB_VERSION)
|
||||
|
||||
#define PL_BLOB_UNIQUE 0x01 /* Blob content is unique */
|
||||
#define PL_BLOB_TEXT 0x02 /* blob contains text */
|
||||
#define PL_BLOB_NOCOPY 0x04 /* do not copy the data */
|
||||
#define PL_BLOB_WCHAR 0x08 /* wide character string */
|
||||
|
||||
typedef struct _PL_blob_t {
|
||||
uintptr_t magic; /* YAP_BLOB_MAGIC */
|
||||
uintptr_t flags; /* YAP_BLOB_* */
|
||||
char *name; /* name of the type */
|
||||
int (*release)(YAP_Atom a);
|
||||
int (*compare)(YAP_Atom a, YAP_Atom b);
|
||||
#ifdef SIO_MAGIC
|
||||
int (*write)(FILE *s, YAP_Atom a, int flags);
|
||||
#else
|
||||
int (*write)(void *s, YAP_Atom a, int flags);
|
||||
#endif
|
||||
void (*acquire)(YAP_Atom a);
|
||||
#ifdef SIO_MAGIC
|
||||
int (*save)(YAP_Atom a, FILE *s);
|
||||
YAP_Atom (*load)(FILE *s);
|
||||
#else
|
||||
int (*save)(YAP_Atom a, void *);
|
||||
YAP_Atom (*load)(void *s);
|
||||
#endif
|
||||
/* private */
|
||||
void *reserved[10]; /* for future extension */
|
||||
int registered; /* Already registered? */
|
||||
int rank; /* Rank for ordering atoms */
|
||||
struct _PL_blob_t *next; /* next in registered type-chain */
|
||||
YAP_Atom atom_name; /* Name as atom */
|
||||
} blob_type_t;
|
||||
|
||||
// typedef struct _PL_blob_t PL_blob_t;
|
||||
#define YAP_BLOB_MAGIC_B PL_BLOB_MAGIC_B
|
||||
#define YAP_blob_t blob_type_t
|
||||
#define PL_blob_t blob_type_t
|
||||
|
||||
#ifdef SWI_PROLOG_H
|
||||
|
||||
PL_EXPORT(int) PL_is_blob(term_t t, PL_blob_t **type);
|
||||
PL_EXPORT(int) PL_unify_blob(term_t t, void *blob, size_t len, PL_blob_t *type);
|
||||
PL_EXPORT(int) PL_put_blob(term_t t, void *blob, size_t len, PL_blob_t *type);
|
||||
PL_EXPORT(int)
|
||||
PL_get_blob(term_t t, void **blob, size_t *len, PL_blob_t **type);
|
||||
|
||||
PL_EXPORT(void *) PL_blob_data(atom_t a, size_t *len, PL_blob_t **type);
|
||||
|
||||
PL_EXPORT(void) PL_register_blob_type(PL_blob_t *type);
|
||||
PL_EXPORT(PL_blob_t *) PL_find_blob_type(const char *name);
|
||||
PL_EXPORT(int) PL_unregister_blob_type(PL_blob_t *type);
|
||||
PL_EXPORT(int) PL_raise(int sig);
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef YATOM_H
|
||||
extern int Yap_write_blob(AtomEntry *ref, FILE *stream);
|
||||
extern char *Yap_blob_to_string(AtomEntry *ref, const char *s, size_t sz);
|
||||
#endif
|
||||
extern X_API bool YAP_is_blob(YAP_Term t, YAP_blob_t **type);
|
||||
extern X_API bool YAP_unify_blob(YAP_Term *t, void *blob, size_t len,
|
||||
YAP_blob_t *type);
|
||||
extern X_API bool YAP_put_blob(YAP_Term *t, void *blob, size_t len,
|
||||
YAP_blob_t *type);
|
||||
extern X_API bool YAP_get_blob(YAP_Term t, void **blob, size_t *len,
|
||||
YAP_blob_t **type);
|
||||
|
||||
extern X_API void *YAP_blob_data(YAP_Atom a, size_t *len, YAP_blob_t **type);
|
||||
|
||||
extern X_API void YAP_register_blob_type(YAP_blob_t *type);
|
||||
extern X_API YAP_blob_t *YAP_find_blob_type(const char *name);
|
||||
// extern X_API YAP_blob_t *YAP_find_blob_type(YAP_Atom at);
|
||||
extern X_API bool YAP_unregister_blob_type(YAP_blob_t *type);
|
||||
|
||||
#endif
|
@ -59,7 +59,7 @@ X_API int PL_is_blob(term_t t, PL_blob_t **type) {
|
||||
if (!IsBlob(a))
|
||||
return FALSE;
|
||||
b = RepBlobProp(a->PropsOfAE);
|
||||
*type = (struct PL_blob_t *)b->blob_type;
|
||||
*type = (PL_blob_t *)b->blob_type;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -77,7 +77,7 @@ PL_unify_blob(term_t t, void *blob, size_t len, PL_blob_t *type) {
|
||||
return FALSE;
|
||||
}
|
||||
if (type->acquire) {
|
||||
type->acquire(AtomToSWIAtom(AbsAtom(ae)));
|
||||
type->acquire((AbsAtom(ae)));
|
||||
}
|
||||
return Yap_unify(Yap_GetFromSlot(t), MkAtomTerm(AbsAtom(ae)));
|
||||
}
|
||||
@ -95,7 +95,7 @@ PL_put_blob(term_t t, void *blob, size_t len, PL_blob_t *type) {
|
||||
return FALSE;
|
||||
}
|
||||
if (type->acquire) {
|
||||
type->acquire(AtomToSWIAtom(AbsAtom(ae)));
|
||||
type->acquire((AbsAtom(ae)));
|
||||
}
|
||||
Yap_PutInSlot(t, MkAtomTerm(AbsAtom(ae)));
|
||||
return ret;
|
||||
@ -118,7 +118,7 @@ PL_get_blob(term_t t, void **blob, size_t *len, PL_blob_t **type) {
|
||||
return FALSE;
|
||||
ae = RepAtom(a);
|
||||
if (type)
|
||||
*type = (struct PL_blob_t *)RepBlobProp(ae->PropsOfAE)->blob_type;
|
||||
*type = (PL_blob_t *)RepBlobProp(ae->PropsOfAE)->blob_type;
|
||||
if (len)
|
||||
*len = ae->rep.blob[0].length;
|
||||
if (blob)
|
||||
@ -127,7 +127,7 @@ PL_get_blob(term_t t, void **blob, size_t *len, PL_blob_t **type) {
|
||||
}
|
||||
|
||||
PL_EXPORT(void *)
|
||||
PL_blob_data(atom_t a, size_t *len, struct PL_blob_t **type) {
|
||||
PL_blob_data(atom_t a, size_t *len, PL_blob_t **type) {
|
||||
Atom x = SWIAtomToAtom(a);
|
||||
|
||||
if (!IsBlob(x)) {
|
||||
@ -140,22 +140,22 @@ PL_blob_data(atom_t a, size_t *len, struct PL_blob_t **type) {
|
||||
if (len)
|
||||
*len = x->rep.blob[0].length;
|
||||
if (type)
|
||||
*type = (struct PL_blob_t *)RepBlobProp(x->PropsOfAE)->blob_type;
|
||||
*type = (PL_blob_t *)RepBlobProp(x->PropsOfAE)->blob_type;
|
||||
|
||||
return x->rep.blob[0].data;
|
||||
}
|
||||
|
||||
PL_EXPORT(void)
|
||||
PL_register_blob_type(PL_blob_t *type) {
|
||||
type->next = (PL_blob_t *)BlobTypes;
|
||||
BlobTypes = (struct YAP_blob_t *)type;
|
||||
type->next = BlobTypes;
|
||||
BlobTypes = type;
|
||||
}
|
||||
|
||||
PL_EXPORT(PL_blob_t *)
|
||||
PL_find_blob_type(const char *name) {
|
||||
Atom at = Yap_LookupAtom((char *)name);
|
||||
|
||||
return YAP_find_blob_type((YAP_Atom)at);
|
||||
return YAP_find_blob_type(RepAtom(at)->StrOfAE);
|
||||
}
|
||||
|
||||
PL_EXPORT(int)
|
||||
|
@ -48,11 +48,13 @@ else()
|
||||
# )
|
||||
|
||||
|
||||
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/yap4py)
|
||||
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/yap4y)
|
||||
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/yap4py/include)
|
||||
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/yap4py/prolog)
|
||||
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/yap4py/prolog/os)
|
||||
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/yap4py/prolog/pl)
|
||||
|
||||
|
||||
add_custom_target( YAP4PY ALL
|
||||
# COMMAND ${CMAKE_COMMAND} -E copy ${YAP_DLLS} ${CMAKE_BINARY_DIR}/startup.yss ${CMAKE_CURRENT_BINARY_DIR}/yap4py
|
||||
COMMAND ${PYTHON_EXECUTABLE} setup.py sdist bdist_wheel
|
||||
@ -71,8 +73,7 @@ function(f_copy filename output )
|
||||
set_source_files_properties(${outfile} PROPERTIES GENERATED TRUE)
|
||||
endfunction()
|
||||
|
||||
|
||||
install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} -m pip install --no-index -f dist yap4py
|
||||
install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} -m pip install .
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})"
|
||||
DEPENDS Py4YAP ${CMAKE_BINARY_DIR}/${YAP_STARTUP} ${dlls} )
|
||||
|
||||
|
@ -11,6 +11,7 @@ from setuptools.extension import Extension
|
||||
from codecs import open
|
||||
from os import path, makedirs, walk
|
||||
from shutil import copytree, rmtree, copy2, move
|
||||
import sysconfig
|
||||
from glob import glob
|
||||
from pathlib import Path
|
||||
import platform
|
||||
@ -42,15 +43,16 @@ from shutil import copytree, rmtree, copy2, move
|
||||
from glob import glob
|
||||
from pathlib import Path
|
||||
import platform
|
||||
import os.path
|
||||
from os.path import dirname, join,abspath
|
||||
import os
|
||||
import shutil
|
||||
|
||||
from distutils.core import setup
|
||||
|
||||
pjoin = os.path.join
|
||||
here = os.path.abspath(os.path.dirname(__file__))
|
||||
#pkg_root = pjoin(here, name)
|
||||
here = abspath(dirname(__file__))
|
||||
libpydir = abspath(dirname(os.path.dirname('stdlib')))
|
||||
libpyauxdir = abspath(os.path.dirname('stdlib'))
|
||||
#pkg_root = join(here, name)
|
||||
|
||||
sys.path.insert(0, "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
|
||||
@ -61,13 +63,13 @@ if platform.system() == 'Windows':
|
||||
my_extra_link_args = ['-Wl,-export-all-symbols']
|
||||
else:
|
||||
# if platform.system() == 'Darwin':
|
||||
my_extra_link_args = ['-Wl,-rpath', '-Wl,${_ABS_PYTHON_MODULE_PATH}']
|
||||
my_extra_link_args = ['-Wl,-rpath', '-Wl,'+libpydir,'-Wl,-rpath', '-Wl,'+libpyauxdir, ]
|
||||
win_libs = []
|
||||
local_libs = ['YAP++','Py4YAP']
|
||||
local_libs = ['Py4YAP']
|
||||
# or dll in glob('yap/dlls/*'):
|
||||
# move( dll ,'lib' )
|
||||
|
||||
native_sources = ["yap.i"]
|
||||
native_sources = ["yap.i",'yapi.cpp']
|
||||
|
||||
for i in '${PYTHON_SOURCES}'.split(";"):
|
||||
copy2(i, 'yap4py')
|
||||
@ -83,7 +85,16 @@ for i in my_libs0:
|
||||
my_libs = glob(i) + my_libs
|
||||
for i in my_libs:
|
||||
copy2(i, 'yap4py')
|
||||
bpy2yap = []
|
||||
my_includes = ['${CMAKE_SOURCE_DIR}/CXX', '${CMAKE_SOURCE_DIR}/include',
|
||||
'${CMAKE_SOURCE_DIR}/H', '${CMAKE_SOURCE_DIR}/H/generated',
|
||||
'${CMAKE_SOURCE_DIR}/os', '${CMAKE_SOURCE_DIR}/OPTYap',
|
||||
'${CMAKE_SOURCE_DIR}/utf8proc',
|
||||
'${CMAKE_SOURCE_DIR}/packages/python',
|
||||
'${CMAKE_BINARY_DIR}']
|
||||
for i in my_includes:
|
||||
includes = glob(i+"/*.??h")
|
||||
for j in includes:
|
||||
copy2(j, 'yap4py/include')
|
||||
here = path.abspath(path.dirname(__file__))
|
||||
#gmp_dir = path.abspath(path.dirname("${GMP_LIBRARIES}"))
|
||||
#python_libdir = path.abspath(path.dirname("${PYTHON_LIBRARIES}")
|
||||
@ -99,25 +110,14 @@ extensions = [Extension('_yap', native_sources,
|
||||
('_GNU_SOURCE', '1')],
|
||||
runtime_library_dirs=['yap4py', '${libdir}', '${bindir}', '${gmp_dir}', '${python_libdir}'],
|
||||
swig_opts=['-modern', '-c++', '-py3',
|
||||
'-DX_API', '-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${CMAKE_SOURCE_DIR}/packages/python'],
|
||||
library_dirs=['../../..', '../../../CXX', '..', "${bindir}"],
|
||||
'-DX_API', '-Iyap4py/include' ],
|
||||
library_dirs=['../../..', '../../../CXX', 'yap4py/include', '..', "${bindir}"],
|
||||
extra_link_args=my_extra_link_args,
|
||||
libraries=['Yap','gmp']+win_libs+local_libs,
|
||||
include_dirs=['../../..',
|
||||
'${GMP_INCLUDE_DIRS}',
|
||||
'${CMAKE_SOURCE_DIR}/H',
|
||||
'${CMAKE_SOURCE_DIR}/H/generated',
|
||||
'${CMAKE_SOURCE_DIR}/OPTYap',
|
||||
'${CMAKE_SOURCE_DIR}/os',
|
||||
'${CMAKE_SOURCE_DIR}/packages/python',
|
||||
'${CMAKE_SOURCE_DIR}/include',
|
||||
'${CMAKE_SOURCE_DIR}/CXX', '.']
|
||||
)]#
|
||||
include_dirs=['yap4py/include']
|
||||
)]
|
||||
|
||||
packages = packages = setuptools.find_packages('${CMAKE_CURRENT_SOURCE_DIR}')
|
||||
packages = setuptools.find_packages('${CMAKE_CURRENT_SOURCE_DIR}')
|
||||
|
||||
|
||||
|
||||
@ -131,21 +131,21 @@ version_ns = {'__version__': '6.3.5', 'minor-version': '6', 'minor-version': '3'
|
||||
setup_args = dict(
|
||||
name=name,
|
||||
version=version_ns['__version__'],
|
||||
scripts=glob(pjoin('scripts', '*')),
|
||||
scripts=glob(join('scripts', '*')),
|
||||
packages=packages,
|
||||
py_modules=['yap','yap4py'],
|
||||
package_data=package_data,
|
||||
include_package_data=True,
|
||||
requirements=[
|
||||
'm2w64-gmp',
|
||||
'm2-msys2-keyring',
|
||||
'm2-msys2-launcher-git',
|
||||
'm2-msys2-runtime',
|
||||
],
|
||||
# requirements=[
|
||||
# 'm2w64-gmp',
|
||||
# 'm2-msys2-keyring',
|
||||
# 'm2-msys2-launcher-git',
|
||||
# 'm2-msys2-runtime',
|
||||
# ],
|
||||
description="YAP in Python",
|
||||
author='YAP Development Team',
|
||||
author_email='ipython-dev@scipy.org',
|
||||
url='http://ipython.org',
|
||||
author_email='vsc@dcc.fc.up.pt',
|
||||
url='http://www.dcc.fc.up/~vsc/yap',
|
||||
license='BSD',
|
||||
ext_modules=extensions,
|
||||
platforms="Linux, Mac OS X, Windows",
|
||||
|
@ -659,8 +659,9 @@ class YAPEngine;
|
||||
|
||||
//%template(YAPTermVector) vector<YAPTerm>;
|
||||
//%feature("novaluewrapper") vector<YAPTerm>;
|
||||
};
|
||||
|
||||
|
||||
};
|
||||
|
||||
%init %{
|
||||
%}
|
||||
|
Reference in New Issue
Block a user