Merge branch 'master' of github.com:vscosta/yap-6.3
This commit is contained in:
commit
c2f2490fee
@ -1452,11 +1452,10 @@ X_API Term YAP_ReadBuffer(const char *s, Term *tp) {
|
||||
if (*tp)
|
||||
tv = *tp;
|
||||
else
|
||||
tv = 0;
|
||||
tv = (Term)0;
|
||||
LOCAL_ErrorMessage = NULL;
|
||||
const unsigned char *us = (const unsigned char *)s;
|
||||
while (!(t = Yap_BufferToTermWithPrioBindings(us, strlen(s) + 1, TermNil,
|
||||
GLOBAL_MaxPriority, tv))) {
|
||||
while (!(t = Yap_BufferToTermWithPrioBindings(us, TermNil, tv, strlen(s) + 1, GLOBAL_MaxPriority))) {
|
||||
if (LOCAL_ErrorMessage) {
|
||||
if (!strcmp(LOCAL_ErrorMessage, "Stack Overflow")) {
|
||||
if (!Yap_dogc(0, NULL PASS_REGS)) {
|
||||
|
@ -36,6 +36,7 @@ static char SccsId[] = "@(#)cdmgr.c 1.1 05/02/98";
|
||||
#include <assert.h>
|
||||
#include <heapgc.h>
|
||||
#include <iopreds.h>
|
||||
#include <Yatom.h>
|
||||
|
||||
static void retract_all(PredEntry *, int);
|
||||
static void add_first_static(PredEntry *, yamop *, int);
|
||||
@ -1741,7 +1742,7 @@ bool Yap_addclause(Term t, yamop *cp, Term tmode, Term mod, Term *t4ref)
|
||||
/* The only problem we have now is when we need to throw away
|
||||
Indexing blocks
|
||||
*/
|
||||
if (pflags & IndexedPredFlag) {
|
||||
if (pflags & IndexedPredFlag && p->cs.p_code.NOfClauses > 1) {
|
||||
Yap_AddClauseToIndex(p, cp, mode == asserta);
|
||||
}
|
||||
if (pflags & (SpiedPredFlag | CountPredFlag | ProfiledPredFlag)) {
|
||||
|
@ -1377,8 +1377,7 @@ static bool setInitialValue(bool bootstrap, flag_func f, const char *s,
|
||||
}
|
||||
CACHE_REGS
|
||||
const unsigned char *us = (const unsigned char *)s;
|
||||
t0 = Yap_BufferToTermWithPrioBindings(us, strlen(s) + 1, TermNil,
|
||||
GLOBAL_MaxPriority, 0L);
|
||||
t0 = Yap_BufferToTermWithPrioBindings(us, TermNil, 0L, strlen(s) + 1, GLOBAL_MaxPriority);
|
||||
if (!t0)
|
||||
return false;
|
||||
if (IsAtomTerm(t0) || IsIntTerm(t0)) {
|
||||
|
@ -45,6 +45,9 @@ Int p_load_foreign(USES_REGS1) {
|
||||
StringList new;
|
||||
bool returncode = FALSE;
|
||||
yhandle_t CurSlot = Yap_StartSlots();
|
||||
#if __ANDROID__
|
||||
return true;
|
||||
#endif
|
||||
|
||||
// Yap_DebugPlWrite(ARG1); printf("%s\n", " \n");
|
||||
// Yap_DebugPlWrite(ARG2); printf("%s\n", " \n");
|
||||
@ -94,7 +97,7 @@ Int p_load_foreign(USES_REGS1) {
|
||||
} else {
|
||||
f = RepAtom(libs->name)->StrOfAE;
|
||||
}
|
||||
Yap_Error(SYSTEM_ERROR_OPERATING_SYSTEM, ARG3,
|
||||
Yap_Error(SYSTEM_ERROR_OPERATING_SYSTEM, ARG3,
|
||||
"Foreign module %s does not have initialization function %s", f,
|
||||
InitProcName);
|
||||
return false;
|
||||
|
@ -455,7 +455,7 @@ bool low_level_trace__(yap_low_level_port port, PredEntry *pred, CELL *args) {
|
||||
}
|
||||
UNLOCK(Yap_low_level_trace_lock);
|
||||
#if __ANDROID__
|
||||
__android_log_print(ANDROID_LOG_DEBUG, "YAPDroid", "%s\n", buf);
|
||||
__android_log_print(ANDROID_LOG_ERROR, "YAPDroid", "%s\n", buf);
|
||||
#else
|
||||
*b++ = '\n';
|
||||
*b = '\0';
|
||||
@ -510,7 +510,7 @@ not being output.
|
||||
static Int stop_low_level_trace(USES_REGS1) {
|
||||
Yap_do_low_level_trace = FALSE;
|
||||
LOCAL_do_trace_primitives = TRUE;
|
||||
#if DEBUG_LOCKS
|
||||
#if DEBUG_LOCKS////
|
||||
debug_locks = TRUE;
|
||||
#endif
|
||||
return (TRUE);
|
||||
|
10
C/yap-args.c
10
C/yap-args.c
@ -146,7 +146,7 @@ static void init_globals(YAP_init_args *yap_init) {
|
||||
}
|
||||
|
||||
const char *Yap_BINDIR, *Yap_ROOTDIR, *Yap_SHAREDIR, *Yap_LIBDIR, *Yap_DLLDIR,
|
||||
*Yap_PLDIR, *Yap_BOOTSTRAP, *Yap_COMMONSDIR, *Yap_STARTUP,
|
||||
*Yap_PLDIR, *Yap_BOOTSTRAP, *Yap_COMMONSDIR,
|
||||
*Yap_INPUT_STARTUP, *Yap_OUTPUT_STARTUP, *Yap_BOOTFILE, *Yap_INCLUDEDIR;
|
||||
|
||||
/**
|
||||
@ -275,7 +275,7 @@ static void Yap_set_locations(YAP_init_args *iap) {
|
||||
/// DLLDIR: where libraries can find expicitely loaded DLLs
|
||||
Yap_DLLDIR = sel(true, iap->DLLDIR != NULL, iap->DLLDIR, true,
|
||||
#if __ANDROID__
|
||||
NULL
|
||||
NULL,
|
||||
#else
|
||||
join(getenv("DESTDIR"), YAP_DLLDIR),
|
||||
#endif
|
||||
@ -315,12 +315,12 @@ static void Yap_set_locations(YAP_init_args *iap) {
|
||||
/// BOOTPLDIR: where we can find Prolog bootstrap files
|
||||
Yap_BOOTSTRAP = sel(true, iap->BOOTSTRAP != NULL, iap->BOOTSTRAP, true,
|
||||
#if __ANDROID__
|
||||
"/assets/Yap/pl",
|
||||
"/assets/Yap/pl/boot,yap",
|
||||
#else
|
||||
join(getenv("DESTDIR"), YAP_BOOTSTRAP),
|
||||
#endif
|
||||
false);
|
||||
/// BOOTFILE: where we can find the core Prolog bootstrap file
|
||||
/// BOOTFILE: where we can find the core Prolog boot file
|
||||
Yap_BOOTFILE = sel(false, iap->BOOTFILE != NULL, iap->BOOTFILE, true,
|
||||
#if __ANDROID__
|
||||
"/assets/Yap/pl/boot.yap",
|
||||
@ -456,7 +456,7 @@ X_API YAP_file_type_t Yap_InitDefaults(void *x, char *saved_state, int argc,
|
||||
memset(iap, 0, sizeof(YAP_init_args));
|
||||
#if __ANDROID__
|
||||
iap->boot_file_type = YAP_BOOT_PL;
|
||||
iap->SavedState = NULL;
|
||||
iap->INPUT_STARTUP = NULL;
|
||||
iap->assetManager = NULL;
|
||||
#else
|
||||
iap->boot_file_type = YAP_QLY;
|
||||
|
@ -705,9 +705,8 @@ IF ( ANDROID)
|
||||
|
||||
|
||||
|
||||
#target_link_libraries(libYap ${CMAKE_SOURCE_DIR}/../sqlite-android/jni/${ANDROID_ABI}/libsqliteX.so android log )
|
||||
target_link_libraries(libYap ${CMAKE_SOURCE_DIR}/../sqlite-android/jni/${ANDROID_ABI}/libsqliteX.so android log )
|
||||
|
||||
target_link_libraries(libYap android log )
|
||||
ENDIF ()
|
||||
|
||||
|
||||
|
@ -110,7 +110,7 @@ protected:
|
||||
const unsigned char *us = (const unsigned char *)s0;
|
||||
tnames = MkVarTerm();
|
||||
tout =
|
||||
Yap_BufferToTermWithPrioBindings(us, strlen(s0), TermNil, 1200, tnames);
|
||||
Yap_BufferToTermWithPrioBindings(us, TermNil, tnames, strlen(s0), 1200);
|
||||
// fprintf(stderr,"ap=%p arity=%d text=%s", ap, ap->ArityOfPE, s);
|
||||
// Yap_DebugPlWrite(out);
|
||||
if (tout == 0L) {
|
||||
|
@ -340,7 +340,7 @@ public:
|
||||
/// current directory for the engine
|
||||
bool call(YAPPredicate ap, YAPTerm ts[]);
|
||||
/// current directory for the engine
|
||||
bool goalt(YAPTerm Yt) { return Yt.term(); };
|
||||
bool goal(YAPTerm Yt, YAPModule module) { return mgoal(Yt.term(),module.term()); };
|
||||
/// current directory for the engine
|
||||
bool mgoal(Term t, Term tmod);
|
||||
/// current directory for the engine
|
||||
|
29
CXX/yapt.hh
29
CXX/yapt.hh
@ -76,7 +76,7 @@ public:
|
||||
YAPTerm(void *ptr);
|
||||
/// parse string s and construct a term.
|
||||
YAPTerm(char *s) {
|
||||
Term tp;
|
||||
Term tp = 0;
|
||||
mk(YAP_ReadBuffer(s, &tp));
|
||||
}
|
||||
|
||||
@ -322,20 +322,27 @@ public:
|
||||
RECOVER_MACHINE_REGS();
|
||||
};
|
||||
YAPApplTerm(YAPFunctor f, YAPTerm ts[]);
|
||||
YAPApplTerm(const std::string s, std::vector<YAPTerm> ts);
|
||||
YAPApplTerm(const std::string s, unsigned int arity) { mk(Yap_MkNewApplTerm(Yap_MkFunctor(Yap_LookupAtom(s.c_str()), arity), arity)); };
|
||||
YAPApplTerm(const std::string s, std::vector<YAPTerm> ts);
|
||||
YAPApplTerm(YAPFunctor f);
|
||||
inline Functor functor() { return FunctorOfTerm(gt()); }
|
||||
inline YAPFunctor getFunctor() { return YAPFunctor(FunctorOfTerm(gt())); }
|
||||
|
||||
Term getArg(arity_t i) {
|
||||
BACKUP_MACHINE_REGS();
|
||||
Term t0 = gt();
|
||||
Term tf;
|
||||
tf = ArgOfTerm(i, t0);
|
||||
RECOVER_MACHINE_REGS();
|
||||
return tf;
|
||||
};
|
||||
virtual bool isVar() { return false; } /// type check for unbound
|
||||
Term getArg(arity_t i) {
|
||||
BACKUP_MACHINE_REGS();
|
||||
Term t0 = gt();
|
||||
Term tf;
|
||||
tf = ArgOfTerm(i, t0);
|
||||
RECOVER_MACHINE_REGS();
|
||||
return tf;
|
||||
};
|
||||
void putArg(int i, YAPTerm t) {
|
||||
BACKUP_MACHINE_REGS();
|
||||
Term t0 = gt();
|
||||
RepAppl(t0)[i] = t.term();
|
||||
RECOVER_MACHINE_REGS();
|
||||
};
|
||||
virtual bool isVar() { return false; } /// 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
|
||||
|
1
H/Yap.h
1
H/Yap.h
@ -263,6 +263,7 @@ extern size_t Yap_page_size;
|
||||
#define M1 ((CELL)(1024 * 1024))
|
||||
#define M2 ((CELL)(2048 * 1024))
|
||||
|
||||
typedef YAP_UInt CELL;
|
||||
#if ALIGN_LONGS
|
||||
typedef CELL SFLAGS;
|
||||
#else
|
||||
|
@ -226,8 +226,4 @@ atom_t ATOM_;
|
||||
intptr_t system_thread_id(void);
|
||||
#endif
|
||||
|
||||
extern Term Yap_BufferToTermWithPrioBindings(const char *s, size_t len,
|
||||
encoding_t enc, int prio,
|
||||
Term *bindingsp);
|
||||
|
||||
#endif /* PL_YAP_H */
|
||||
|
@ -2,6 +2,7 @@ set (YAPOS_HEADERS
|
||||
getw.h
|
||||
iopreds.h
|
||||
yapio.h
|
||||
encoding.h
|
||||
)
|
||||
|
||||
set (YAPOS_SOURCES
|
||||
|
@ -41,8 +41,8 @@ static char SccsId[] = "%W% %G%";
|
||||
#include <android/native_activity.h>
|
||||
|
||||
|
||||
extern void
|
||||
Java_pt_up_yap_YAPIO_setAssetManager(JNIEnv *env, jclass clazz, jobject assetManager);
|
||||
extern X_API void
|
||||
Java_pt_up_yap_yapdroid_YAPDroid_loadAssetManager(JNIEnv *env, jclass clazz, jobject assetManager);
|
||||
|
||||
jobject *Yap_aref;
|
||||
JNIEnv *Yap_env;
|
||||
@ -52,8 +52,8 @@ AAssetManager *Yap_assetManager(void)
|
||||
return AAssetManager_fromJava(Yap_env, Yap_aref);
|
||||
}
|
||||
|
||||
void
|
||||
Java_pt_up_yap_YAPIO_setAssetManager(JNIEnv *env, jclass clazz, jobject assetManager) {
|
||||
X_API void
|
||||
Java_pt_up_yap_yapdroid_YAPDroid_loadAssetManager(JNIEnv *env, jclass clazz, jobject assetManager) {
|
||||
Yap_aref = (*env)->NewGlobalRef(env,assetManager);
|
||||
Yap_env = env;
|
||||
}
|
||||
|
@ -1386,9 +1386,8 @@ Term Yap_BufferToTerm(const unsigned char *s, Term opts) {
|
||||
return rval;
|
||||
}
|
||||
|
||||
X_API Term Yap_BufferToTermWithPrioBindings(const unsigned char *s, size_t len,
|
||||
Term opts, int prio,
|
||||
Term bindings) {
|
||||
X_API Term Yap_BufferToTermWithPrioBindings(const unsigned char *s, Term opts, Term bindings, size_t len,
|
||||
int prio) {
|
||||
CACHE_REGS
|
||||
Term ctl;
|
||||
|
||||
|
@ -117,9 +117,9 @@ extern int Yap_open_buf_read_stream(const char *buf, size_t nchars,
|
||||
encoding_t *encp, memBufSource src);
|
||||
extern int Yap_open_buf_write_stream(encoding_t enc, memBufSource src);
|
||||
extern Term Yap_BufferToTerm(const unsigned char *s, Term opts);
|
||||
extern X_API Term Yap_BufferToTermWithPrioBindings(const unsigned char *s,
|
||||
size_t sz, Term opts,
|
||||
int prio, Term bindings);
|
||||
extern X_API Term
|
||||
Yap_BufferToTermWithPrioBindings(const unsigned char *s, Term opts, Term bindings, size_t sz,
|
||||
int prio);
|
||||
extern FILE *Yap_GetInputStream(Term t, const char *m);
|
||||
extern FILE *Yap_GetOutputStream(Term t, const char *m);
|
||||
extern char *Yap_guessFileName(FILE *f, int sno, char *nameb, size_t max);
|
||||
|
@ -15,6 +15,7 @@
|
||||
typedef struct myddas_global *MYDDAS_GLOBAL;
|
||||
#include "myddas_util.h"
|
||||
|
||||
|
||||
#ifdef MYDDAS_STATS
|
||||
typedef struct myddas_stats_time_struct *MYDDAS_STATS_TIME;
|
||||
typedef struct myddas_global_stats *MYDDAS_GLOBAL_STATS;
|
||||
|
@ -99,6 +99,7 @@ static bool myddas_initialised;
|
||||
/* Initialize all of the MYDDAS global structures */
|
||||
static Int c_db_initialize_myddas(USES_REGS1) {
|
||||
if (!myddas_initialised) {
|
||||
myddas_initialised= true;
|
||||
init_myddas();
|
||||
}
|
||||
Yap_REGS.MYDDAS_GLOBAL_POINTER = myddas_init_initialize_myddas();
|
||||
@ -680,26 +681,17 @@ void Yap_MYDDAS_delete_all_myddas_structs(void) {
|
||||
void init_myddas(void) {
|
||||
CACHE_REGS
|
||||
if (myddas_initialised)
|
||||
return;
|
||||
myddas_initialised = TRUE;
|
||||
return;
|
||||
#ifdef __ANDROID__
|
||||
init_sqlite3();
|
||||
#endif
|
||||
#if defined MYDDAS_ODBC
|
||||
Yap_InitBackMYDDAS_ODBCPreds();
|
||||
#endif
|
||||
#if WIN32
|
||||
Yap_InitBackMYDDAS_SQLITE3Preds();
|
||||
#endif
|
||||
#if defined USE_MYDDAS
|
||||
Yap_InitBackMYDDAS_SharedPreds();
|
||||
#endif
|
||||
#if defined MYDDAS_MYSQL
|
||||
Yap_InitMYDDAS_MySQLPreds();
|
||||
#endif
|
||||
#if defined MYDDAS_ODBC
|
||||
Yap_InitMYDDAS_ODBCPreds();
|
||||
#endif
|
||||
#if WIN32
|
||||
Yap_InitMYDDAS_SQLITE3Preds();
|
||||
#endif
|
||||
#if defined USE_MYDDAS
|
||||
Yap_InitMYDDAS_SharedPreds();
|
||||
#endif
|
||||
@ -720,6 +712,7 @@ void init_myddas(void) {
|
||||
Yap_MYDDAS_delete_all_myddas_structs();
|
||||
#endif
|
||||
c_db_initialize_myddas(PASS_REGS1);
|
||||
myddas_initialised = TRUE;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
@ -742,5 +735,3 @@ int WINAPI win_myddas(HANDLE hinst, DWORD reason, LPVOID reserved) {
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* USE_MYDDAS*/
|
||||
|
@ -72,6 +72,7 @@ foreach (driver ${MYDDAS_DBMS})
|
||||
cpp_driver(MYDDAS_YAP ${driver} myddas_driver.ypp)
|
||||
endforeach ()
|
||||
|
||||
#list (APPEND MYDDAS_YAP ${CMAKE_CURRENT_SOURCE_DIR}/../sqlite3/test.yap ${CMAKE_CURRENT_SOURCE_DIR}/../sqlite3/chinook.db)
|
||||
add_to_group(MYDDAS_YAP pl_library )
|
||||
|
||||
add_custom_target(plmyddas ALL DEPENDS ${MYDDAS_YAP} )
|
||||
@ -79,4 +80,3 @@ add_custom_target(plmyddas ALL DEPENDS ${MYDDAS_YAP} )
|
||||
install(FILES ${MYDDAS_YAP}
|
||||
DESTINATION ${libpl}
|
||||
)
|
||||
|
||||
|
@ -243,8 +243,7 @@ db_open(odbc,Connection,ODBCEntry,User,Password) :-
|
||||
%% sqlite3
|
||||
db_open(sqlite3,Connection,File,User,Password) :-
|
||||
'$error_checks'(db_open(sqlite3,Connection,File,User,Password)),
|
||||
absolute_file_name(File,FullFile,[access(exist),file_errors(error),expand(true)]),
|
||||
c_sqlite3_connect(FullFile,User,Password,Con),
|
||||
c_sqlite3_connect(File,User,Password,Con),
|
||||
set_value(Connection,Con).
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
|
@ -53,3 +53,6 @@ install(TARGETS sqlite4YAP
|
||||
LIBRARY DESTINATION ${YAP_INSTALL_DLLDIR}
|
||||
)
|
||||
endif()
|
||||
|
||||
|
||||
# file (INSTALL chinook.db test.yap DESTINATION ${libpl})
|
||||
|
@ -77,7 +77,7 @@ static Int c_sqlite3_get_database(USES_REGS1);
|
||||
static Int c_sqlite3_change_database(USES_REGS1);
|
||||
|
||||
static Int c_sqlite3_connect(USES_REGS1) {
|
||||
|
||||
printf("hello darkness\n");
|
||||
Term arg_file = Deref(ARG1);
|
||||
Term arg_db = ARG4;
|
||||
|
||||
@ -88,9 +88,9 @@ static Int c_sqlite3_connect(USES_REGS1) {
|
||||
|
||||
CALL_SQLITE(ARG1, open(file, &db));
|
||||
|
||||
if (!Yap_unify(arg_db, MkAddressTerm(db)))
|
||||
if (!Yap_unify(arg_db, MkAddressTerm(db))) {
|
||||
return FALSE;
|
||||
else {
|
||||
} else {
|
||||
/* Criar um novo no na lista de ligacoes*/
|
||||
new = myddas_util_add_connection(db, NULL, API_SQLITE3);
|
||||
|
||||
@ -665,17 +665,10 @@ static void Yap_InitBackMYDDAS_SQLITE3Preds(void) {
|
||||
|
||||
X_API void init_sqlite3(void) {
|
||||
Yap_InitMYDDAS_SQLITE3Preds();
|
||||
|
||||
Yap_InitBackMYDDAS_SQLITE3Preds();
|
||||
}
|
||||
|
||||
#if _ANDROID_
|
||||
//JNIEXPORT void JNICALL lib_yap_up_pt_init_sqlite(JNIEnv *env);
|
||||
|
||||
// JNIEXPORT void JNICALL lib_yap_up_pt_init_sqlite(JNIEnv *env) {
|
||||
// init_sqlite3();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
|
@ -1,21 +1,18 @@
|
||||
|
||||
:- [library(myddas)].
|
||||
|
||||
:- initialization(main).
|
||||
:- compile(library(myddas)).
|
||||
|
||||
main :-
|
||||
setup_call_cleanup(
|
||||
init,
|
||||
main_ ,
|
||||
(trace,
|
||||
close)).
|
||||
init,
|
||||
main_,
|
||||
close.
|
||||
main_ :-
|
||||
go,
|
||||
fail.
|
||||
main_ .
|
||||
|
||||
init :-
|
||||
db_open(sqlite3, '~/Yap/Chinook/Chinook_Sqlite.sqlite', _, _),
|
||||
db_open(sqlite3, '/data/user/0/pt.up.yap.yapdroid/files/Yap/chinook.db', _, _),
|
||||
writeln('chinook has landed'),
|
||||
db_import('Artist', artist),
|
||||
db_import('Album', album),
|
||||
db_import('Track', track).
|
||||
@ -25,26 +22,24 @@ init :-
|
||||
db_get_attributes_types(track,Ts),
|
||||
db_get_attributes_types(artist,As),
|
||||
writeln(As:Als:Ts).
|
||||
|
||||
go :-
|
||||
db_number_of_fields(album,Als),
|
||||
db_number_of_fields(track,Ts),
|
||||
db_number_of_fields(artist,As),
|
||||
writeln(As:Als:Ts).
|
||||
|
||||
go :-
|
||||
go :-
|
||||
db_describe(album, Desc), writeln(Desc) ;
|
||||
db_describe(track, Desc), writeln(Desc) ;
|
||||
db_describe(artist, Desc), writeln(Desc).
|
||||
|
||||
go :-
|
||||
go :-
|
||||
db_show_tables(Desc), writeln(Desc).
|
||||
go :-
|
||||
go :-
|
||||
db_show_tables(table(T)),
|
||||
db_describe(T,tableinfo(FieldID,Type,Null,Primary,Default,'')),
|
||||
writeln(T:tableinfo(FieldID,Type,Null,Primary,Default,'')).
|
||||
|
||||
go :-
|
||||
go :-
|
||||
go_cut0.
|
||||
|
||||
|
||||
@ -79,3 +74,6 @@ go_cut1 :-
|
||||
|
||||
close :-
|
||||
db_close.
|
||||
|
||||
:- main.
|
||||
|
||||
|
@ -19,7 +19,7 @@ file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/yap4py)
|
||||
set(YAP4PY_PL prolog/yapi.yap)
|
||||
set(YAP4PY_PY yap4py/__main__.py yap4py/yapi.py)
|
||||
|
||||
configure_file("setup.py.in" setup.py)
|
||||
configure_file("setup.py.in" ${CMAKE_CURRENT_BINARY_DIR}/setup.py)
|
||||
configure_file("MANIFEST.in" ${CMAKE_CURRENT_BINARY_DIR}/MANIFEST.in)
|
||||
configure_file("YAP4PY.md" README.md)
|
||||
configure_file(yap4py/__init__.py.in yap4py/__init__.py)
|
||||
|
@ -69,7 +69,7 @@ elif platform.system() == 'Darwin':
|
||||
win_libs = []
|
||||
local_libs = ['Py4YAP']
|
||||
elif platform.system() == 'Linux':
|
||||
my_extra_link_args = ['-L','..','-Wl,-rpath,'+abspath(join(sysconfig.get_path('platlib'),'yap4py')),'-Wl,-rpath,${CMAKE_INSTALL_FULL_LIBDIR}','-Wl,-rpath,../yap4py']
|
||||
my_extra_link_args = ['-L','..','-Wl,-rpath,'+abspath(join(sysconfig.get_path('platlib'),'yap4py')),'-Wl,-rpath,@CMAKE_INSTALL_FULL_LIBDIR@','-Wl,-rpath,'+join('@CMAKE_INSTALL_FULL_LIBDIR@','..'),'-Wl,-rpath,../yap4py']
|
||||
win_libs = []
|
||||
local_libs = ['Py4YAP']
|
||||
|
||||
|
@ -20,6 +20,7 @@ FILE( MAKE_DIRECTORY ${YAP_APP_DIR}/src/generated/jni)
|
||||
add_custom_target (pllib
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${pllib}
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${pl_library} ${pllib}
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/android.yap ${pllib}
|
||||
DEPENDS ${pl_library}
|
||||
)
|
||||
|
||||
|
@ -1,15 +1,21 @@
|
||||
//
|
||||
// Created by vsc on 7/6/17.
|
||||
// Created by vsc on 7/6/17->
|
||||
//
|
||||
/* File : example.cxx */
|
||||
/* File : example->cxx */
|
||||
|
||||
#include "streamer.h"
|
||||
|
||||
extern "C" {
|
||||
|
||||
extern void Java_pt_up_yap_streamerJNI_swig_1module_1init(void);
|
||||
|
||||
}
|
||||
|
||||
static AndroidStreamer * streamerInstance = 0;
|
||||
|
||||
void setStreamer(AndroidStreamer* streamer) {
|
||||
streamerInstance = streamer;
|
||||
Java_pt_up_yap_streamerJNI_swig_1module_1init();
|
||||
}
|
||||
|
||||
AndroidStreamer& getStreamer() {
|
||||
@ -25,13 +31,11 @@ extern "C" {
|
||||
#include <yapio.h>
|
||||
#include <iopreds.h>
|
||||
|
||||
extern void Java_pt_up_yap_streamerJNI_swig_1module_1init__(void);
|
||||
|
||||
static VFS_t andstream;
|
||||
|
||||
void Java_pt_up_yap_streamerJNI_swig_1module_1init__(void) {
|
||||
// streamerInstance = 0;
|
||||
} ;
|
||||
|
||||
static VFS_t *andstream;
|
||||
|
||||
|
||||
static std::string buff0;
|
||||
|
||||
@ -83,21 +87,34 @@ streamerInstance->display(buff0);
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
AndroidStreamer::bind() {
|
||||
buff0 = *new std::string[256];
|
||||
andstream.name = "/android/user_error";
|
||||
andstream.vflags = VFS_CAN_WRITE | VFS_HAS_PREFIX;
|
||||
andstream.prefix = "/android";
|
||||
andstream.suffix = NULL;
|
||||
andstream.open = and_open;
|
||||
andstream.close = and_close;
|
||||
andstream.get_char = and_get;
|
||||
andstream.put_char = and_put;
|
||||
andstream.flush = and_flush;
|
||||
andstream.seek = and_seek;
|
||||
andstream.next = GLOBAL_VFS;
|
||||
GLOBAL_VFS = &andstream;
|
||||
Yap_InitStdStream(StdOutStream, Output_Stream_f | Append_Stream_f, NULL, &andstream);
|
||||
Yap_InitStdStream(StdErrStream, Output_Stream_f | Append_Stream_f, NULL, &andstream);
|
||||
|
||||
extern "C" {
|
||||
|
||||
|
||||
void Java_pt_up_yap_streamerJNI_swig_1module_1init(void) {
|
||||
if (andstream)
|
||||
return;
|
||||
andstream = new VFS_t();
|
||||
|
||||
andstream->name = "android output window";
|
||||
andstream->vflags = VFS_CAN_WRITE | VFS_HAS_PREFIX;
|
||||
andstream->prefix = "/android";
|
||||
andstream->suffix = NULL;
|
||||
andstream->open = and_open;
|
||||
andstream->close = and_close;
|
||||
andstream->get_char = and_get;
|
||||
andstream->put_char = and_put;
|
||||
andstream->flush = and_flush;
|
||||
andstream->seek = and_seek;
|
||||
andstream->next = GLOBAL_VFS;
|
||||
GLOBAL_VFS = andstream;
|
||||
|
||||
YAP_Term ts[1], args[1], goal;
|
||||
ts[0] = MkAtomTerm(Yap_LookupAtom("android"));
|
||||
args[0] = Yap_MkApplTerm(Yap_MkFunctor(Yap_LookupAtom("library"),1), 1, ts);
|
||||
goal = Yap_MkApplTerm(Yap_MkFunctor(Yap_LookupAtom("compile"),1), 1, args);
|
||||
YAP_RunGoalOnce(goal);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -9,10 +9,14 @@
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
|
||||
|
||||
struct AndroidStreamer {
|
||||
std::string *buff0;
|
||||
|
||||
virtual void display(std::string text) const = 0;
|
||||
virtual ~AndroidStreamer() {}
|
||||
void bind();
|
||||
AndroidStreamer() { buff0 = new std::string[256];
|
||||
};
|
||||
};
|
||||
void setStreamer(AndroidStreamer* streamer);
|
||||
AndroidStreamer& getStreamer();
|
||||
|
@ -60,7 +60,11 @@ class YAPEngine;
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#ifdef SWIGJAVA0
|
||||
%typemap(javapackage) std::vector<YAPTerm> "pt.up.yap.YAPTerm"
|
||||
%template(VectorOfTerm) std::vector<YAPTerm>;
|
||||
#endif
|
||||
}
|
||||
%}
|
||||
|
||||
#ifdef SWIGPYTHON
|
||||
|
@ -8,6 +8,7 @@ set(PL_BOOT_SOURCES
|
||||
boot.yap
|
||||
bootlists.yap
|
||||
bootutils.yap
|
||||
builtins.yap
|
||||
callcount.yap
|
||||
checker.yap
|
||||
consult.yap
|
||||
@ -26,6 +27,7 @@ set(PL_BOOT_SOURCES
|
||||
grammar.yap
|
||||
ground.yap
|
||||
hacks.yap
|
||||
imports.yap
|
||||
init.yap
|
||||
listing.yap
|
||||
load_foreign.yap
|
||||
|
@ -342,7 +342,7 @@ expand_expr(Op, X, Y, O, Q, P) :-
|
||||
%% contains_illegal_dcgnt(+Term) is semidet.
|
||||
%
|
||||
% True if Term contains a non-terminal we cannot deal with using
|
||||
% goal-expansion. The test is too general approximation, but safe.
|
||||
% goal-expansion. The test is too general an approximation, but safe.
|
||||
|
||||
'$contains_illegal_dcgnt'(NT) :-
|
||||
functor(NT, _, A),
|
||||
@ -356,7 +356,6 @@ expand_expr(Op, X, Y, O, Q, P) :-
|
||||
'$harmless_dcgexception'(instantiation_error). % ex: phrase(([1],x:X,[3]),L)
|
||||
'$harmless_dcgexception'(type_error(callable,_)). % ex: phrase(27,L)
|
||||
|
||||
|
||||
:- set_value('$c_arith',true).
|
||||
/**
|
||||
@}
|
||||
|
@ -291,7 +291,7 @@ initialize_prolog :-
|
||||
'qly.yap',
|
||||
'spy.yap',
|
||||
'udi.yap'].
|
||||
:- stop_low_level_trace.
|
||||
%:- stop_low_level_trace.
|
||||
|
||||
|
||||
:- meta_predicate(log_event(+,:)).
|
||||
@ -461,3 +461,5 @@ If this hook preodicate succeeds it must instantiate the _Action_ argument to t
|
||||
:- ensure_loaded('../pl/pathconf.yap').
|
||||
|
||||
:- yap_flag(user:unknown,error).
|
||||
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
:- '$mk_dynamic'('$parent_module'(_,_),prolog).
|
||||
|
||||
|
||||
'$get_undefined_predicates'(G, ImportingMod, G0, ExportingMod) :-
|
||||
recorded('$import','$import'(ExportingModI,ImportingMod,G0I,G,_,_),_),
|
||||
'$continue_imported'(ExportingMod, ExportingModI, G0, G0I).
|
||||
|
Reference in New Issue
Block a user