Merge branch 'master' of github.com:vscosta/yap-6.3

This commit is contained in:
Vitor Santos Costa 2018-03-20 12:11:44 +00:00
commit c2f2490fee
33 changed files with 139 additions and 119 deletions

View File

@ -1452,11 +1452,10 @@ X_API Term YAP_ReadBuffer(const char *s, Term *tp) {
if (*tp) if (*tp)
tv = *tp; tv = *tp;
else else
tv = 0; tv = (Term)0;
LOCAL_ErrorMessage = NULL; LOCAL_ErrorMessage = NULL;
const unsigned char *us = (const unsigned char *)s; const unsigned char *us = (const unsigned char *)s;
while (!(t = Yap_BufferToTermWithPrioBindings(us, strlen(s) + 1, TermNil, while (!(t = Yap_BufferToTermWithPrioBindings(us, TermNil, tv, strlen(s) + 1, GLOBAL_MaxPriority))) {
GLOBAL_MaxPriority, tv))) {
if (LOCAL_ErrorMessage) { if (LOCAL_ErrorMessage) {
if (!strcmp(LOCAL_ErrorMessage, "Stack Overflow")) { if (!strcmp(LOCAL_ErrorMessage, "Stack Overflow")) {
if (!Yap_dogc(0, NULL PASS_REGS)) { if (!Yap_dogc(0, NULL PASS_REGS)) {

View File

@ -36,6 +36,7 @@ static char SccsId[] = "@(#)cdmgr.c 1.1 05/02/98";
#include <assert.h> #include <assert.h>
#include <heapgc.h> #include <heapgc.h>
#include <iopreds.h> #include <iopreds.h>
#include <Yatom.h>
static void retract_all(PredEntry *, int); static void retract_all(PredEntry *, int);
static void add_first_static(PredEntry *, yamop *, 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 /* The only problem we have now is when we need to throw away
Indexing blocks Indexing blocks
*/ */
if (pflags & IndexedPredFlag) { if (pflags & IndexedPredFlag && p->cs.p_code.NOfClauses > 1) {
Yap_AddClauseToIndex(p, cp, mode == asserta); Yap_AddClauseToIndex(p, cp, mode == asserta);
} }
if (pflags & (SpiedPredFlag | CountPredFlag | ProfiledPredFlag)) { if (pflags & (SpiedPredFlag | CountPredFlag | ProfiledPredFlag)) {

View File

@ -1377,8 +1377,7 @@ static bool setInitialValue(bool bootstrap, flag_func f, const char *s,
} }
CACHE_REGS CACHE_REGS
const unsigned char *us = (const unsigned char *)s; const unsigned char *us = (const unsigned char *)s;
t0 = Yap_BufferToTermWithPrioBindings(us, strlen(s) + 1, TermNil, t0 = Yap_BufferToTermWithPrioBindings(us, TermNil, 0L, strlen(s) + 1, GLOBAL_MaxPriority);
GLOBAL_MaxPriority, 0L);
if (!t0) if (!t0)
return false; return false;
if (IsAtomTerm(t0) || IsIntTerm(t0)) { if (IsAtomTerm(t0) || IsIntTerm(t0)) {

View File

@ -45,6 +45,9 @@ Int p_load_foreign(USES_REGS1) {
StringList new; StringList new;
bool returncode = FALSE; bool returncode = FALSE;
yhandle_t CurSlot = Yap_StartSlots(); yhandle_t CurSlot = Yap_StartSlots();
#if __ANDROID__
return true;
#endif
// Yap_DebugPlWrite(ARG1); printf("%s\n", " \n"); // Yap_DebugPlWrite(ARG1); printf("%s\n", " \n");
// Yap_DebugPlWrite(ARG2); printf("%s\n", " \n"); // Yap_DebugPlWrite(ARG2); printf("%s\n", " \n");

View File

@ -455,7 +455,7 @@ bool low_level_trace__(yap_low_level_port port, PredEntry *pred, CELL *args) {
} }
UNLOCK(Yap_low_level_trace_lock); UNLOCK(Yap_low_level_trace_lock);
#if __ANDROID__ #if __ANDROID__
__android_log_print(ANDROID_LOG_DEBUG, "YAPDroid", "%s\n", buf); __android_log_print(ANDROID_LOG_ERROR, "YAPDroid", "%s\n", buf);
#else #else
*b++ = '\n'; *b++ = '\n';
*b = '\0'; *b = '\0';
@ -510,7 +510,7 @@ not being output.
static Int stop_low_level_trace(USES_REGS1) { static Int stop_low_level_trace(USES_REGS1) {
Yap_do_low_level_trace = FALSE; Yap_do_low_level_trace = FALSE;
LOCAL_do_trace_primitives = TRUE; LOCAL_do_trace_primitives = TRUE;
#if DEBUG_LOCKS #if DEBUG_LOCKS////
debug_locks = TRUE; debug_locks = TRUE;
#endif #endif
return (TRUE); return (TRUE);

View File

@ -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, 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; *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 /// DLLDIR: where libraries can find expicitely loaded DLLs
Yap_DLLDIR = sel(true, iap->DLLDIR != NULL, iap->DLLDIR, true, Yap_DLLDIR = sel(true, iap->DLLDIR != NULL, iap->DLLDIR, true,
#if __ANDROID__ #if __ANDROID__
NULL NULL,
#else #else
join(getenv("DESTDIR"), YAP_DLLDIR), join(getenv("DESTDIR"), YAP_DLLDIR),
#endif #endif
@ -315,12 +315,12 @@ static void Yap_set_locations(YAP_init_args *iap) {
/// BOOTPLDIR: where we can find Prolog bootstrap files /// BOOTPLDIR: where we can find Prolog bootstrap files
Yap_BOOTSTRAP = sel(true, iap->BOOTSTRAP != NULL, iap->BOOTSTRAP, true, Yap_BOOTSTRAP = sel(true, iap->BOOTSTRAP != NULL, iap->BOOTSTRAP, true,
#if __ANDROID__ #if __ANDROID__
"/assets/Yap/pl", "/assets/Yap/pl/boot,yap",
#else #else
join(getenv("DESTDIR"), YAP_BOOTSTRAP), join(getenv("DESTDIR"), YAP_BOOTSTRAP),
#endif #endif
false); 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, Yap_BOOTFILE = sel(false, iap->BOOTFILE != NULL, iap->BOOTFILE, true,
#if __ANDROID__ #if __ANDROID__
"/assets/Yap/pl/boot.yap", "/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)); memset(iap, 0, sizeof(YAP_init_args));
#if __ANDROID__ #if __ANDROID__
iap->boot_file_type = YAP_BOOT_PL; iap->boot_file_type = YAP_BOOT_PL;
iap->SavedState = NULL; iap->INPUT_STARTUP = NULL;
iap->assetManager = NULL; iap->assetManager = NULL;
#else #else
iap->boot_file_type = YAP_QLY; iap->boot_file_type = YAP_QLY;

View File

@ -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 () ENDIF ()

View File

@ -110,7 +110,7 @@ protected:
const unsigned char *us = (const unsigned char *)s0; const unsigned char *us = (const unsigned char *)s0;
tnames = MkVarTerm(); tnames = MkVarTerm();
tout = 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); // fprintf(stderr,"ap=%p arity=%d text=%s", ap, ap->ArityOfPE, s);
// Yap_DebugPlWrite(out); // Yap_DebugPlWrite(out);
if (tout == 0L) { if (tout == 0L) {

View File

@ -340,7 +340,7 @@ public:
/// current directory for the engine /// current directory for the engine
bool call(YAPPredicate ap, YAPTerm ts[]); bool call(YAPPredicate ap, YAPTerm ts[]);
/// current directory for the engine /// 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 /// current directory for the engine
bool mgoal(Term t, Term tmod); bool mgoal(Term t, Term tmod);
/// current directory for the engine /// current directory for the engine

View File

@ -76,7 +76,7 @@ public:
YAPTerm(void *ptr); YAPTerm(void *ptr);
/// parse string s and construct a term. /// parse string s and construct a term.
YAPTerm(char *s) { YAPTerm(char *s) {
Term tp; Term tp = 0;
mk(YAP_ReadBuffer(s, &tp)); mk(YAP_ReadBuffer(s, &tp));
} }
@ -322,6 +322,7 @@ public:
RECOVER_MACHINE_REGS(); RECOVER_MACHINE_REGS();
}; };
YAPApplTerm(YAPFunctor f, YAPTerm ts[]); YAPApplTerm(YAPFunctor f, 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(const std::string s, std::vector<YAPTerm> ts);
YAPApplTerm(YAPFunctor f); YAPApplTerm(YAPFunctor f);
inline Functor functor() { return FunctorOfTerm(gt()); } inline Functor functor() { return FunctorOfTerm(gt()); }
@ -335,6 +336,12 @@ public:
RECOVER_MACHINE_REGS(); RECOVER_MACHINE_REGS();
return tf; 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 isVar() { return false; } /// type check for unbound
virtual bool isAtom() { return false; } /// type check for atom virtual bool isAtom() { return false; } /// type check for atom
virtual bool isInteger() { return false; } /// type check for integer virtual bool isInteger() { return false; } /// type check for integer

View File

@ -263,6 +263,7 @@ extern size_t Yap_page_size;
#define M1 ((CELL)(1024 * 1024)) #define M1 ((CELL)(1024 * 1024))
#define M2 ((CELL)(2048 * 1024)) #define M2 ((CELL)(2048 * 1024))
typedef YAP_UInt CELL;
#if ALIGN_LONGS #if ALIGN_LONGS
typedef CELL SFLAGS; typedef CELL SFLAGS;
#else #else

View File

@ -226,8 +226,4 @@ atom_t ATOM_;
intptr_t system_thread_id(void); intptr_t system_thread_id(void);
#endif #endif
extern Term Yap_BufferToTermWithPrioBindings(const char *s, size_t len,
encoding_t enc, int prio,
Term *bindingsp);
#endif /* PL_YAP_H */ #endif /* PL_YAP_H */

View File

@ -2,6 +2,7 @@ set (YAPOS_HEADERS
getw.h getw.h
iopreds.h iopreds.h
yapio.h yapio.h
encoding.h
) )
set (YAPOS_SOURCES set (YAPOS_SOURCES

View File

@ -41,8 +41,8 @@ static char SccsId[] = "%W% %G%";
#include <android/native_activity.h> #include <android/native_activity.h>
extern void extern X_API void
Java_pt_up_yap_YAPIO_setAssetManager(JNIEnv *env, jclass clazz, jobject assetManager); Java_pt_up_yap_yapdroid_YAPDroid_loadAssetManager(JNIEnv *env, jclass clazz, jobject assetManager);
jobject *Yap_aref; jobject *Yap_aref;
JNIEnv *Yap_env; JNIEnv *Yap_env;
@ -52,8 +52,8 @@ AAssetManager *Yap_assetManager(void)
return AAssetManager_fromJava(Yap_env, Yap_aref); return AAssetManager_fromJava(Yap_env, Yap_aref);
} }
void X_API void
Java_pt_up_yap_YAPIO_setAssetManager(JNIEnv *env, jclass clazz, jobject assetManager) { Java_pt_up_yap_yapdroid_YAPDroid_loadAssetManager(JNIEnv *env, jclass clazz, jobject assetManager) {
Yap_aref = (*env)->NewGlobalRef(env,assetManager); Yap_aref = (*env)->NewGlobalRef(env,assetManager);
Yap_env = env; Yap_env = env;
} }

View File

@ -1386,9 +1386,8 @@ Term Yap_BufferToTerm(const unsigned char *s, Term opts) {
return rval; return rval;
} }
X_API Term Yap_BufferToTermWithPrioBindings(const unsigned char *s, size_t len, X_API Term Yap_BufferToTermWithPrioBindings(const unsigned char *s, Term opts, Term bindings, size_t len,
Term opts, int prio, int prio) {
Term bindings) {
CACHE_REGS CACHE_REGS
Term ctl; Term ctl;

View File

@ -117,9 +117,9 @@ extern int Yap_open_buf_read_stream(const char *buf, size_t nchars,
encoding_t *encp, memBufSource src); encoding_t *encp, memBufSource src);
extern int Yap_open_buf_write_stream(encoding_t enc, 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 Term Yap_BufferToTerm(const unsigned char *s, Term opts);
extern X_API Term Yap_BufferToTermWithPrioBindings(const unsigned char *s, extern X_API Term
size_t sz, Term opts, Yap_BufferToTermWithPrioBindings(const unsigned char *s, Term opts, Term bindings, size_t sz,
int prio, Term bindings); int prio);
extern FILE *Yap_GetInputStream(Term t, const char *m); extern FILE *Yap_GetInputStream(Term t, const char *m);
extern FILE *Yap_GetOutputStream(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); extern char *Yap_guessFileName(FILE *f, int sno, char *nameb, size_t max);

View File

@ -15,6 +15,7 @@
typedef struct myddas_global *MYDDAS_GLOBAL; typedef struct myddas_global *MYDDAS_GLOBAL;
#include "myddas_util.h" #include "myddas_util.h"
#ifdef MYDDAS_STATS #ifdef MYDDAS_STATS
typedef struct myddas_stats_time_struct *MYDDAS_STATS_TIME; typedef struct myddas_stats_time_struct *MYDDAS_STATS_TIME;
typedef struct myddas_global_stats *MYDDAS_GLOBAL_STATS; typedef struct myddas_global_stats *MYDDAS_GLOBAL_STATS;

View File

@ -99,6 +99,7 @@ static bool myddas_initialised;
/* Initialize all of the MYDDAS global structures */ /* Initialize all of the MYDDAS global structures */
static Int c_db_initialize_myddas(USES_REGS1) { static Int c_db_initialize_myddas(USES_REGS1) {
if (!myddas_initialised) { if (!myddas_initialised) {
myddas_initialised= true;
init_myddas(); init_myddas();
} }
Yap_REGS.MYDDAS_GLOBAL_POINTER = myddas_init_initialize_myddas(); Yap_REGS.MYDDAS_GLOBAL_POINTER = myddas_init_initialize_myddas();
@ -681,25 +682,16 @@ void init_myddas(void) {
CACHE_REGS CACHE_REGS
if (myddas_initialised) if (myddas_initialised)
return; return;
myddas_initialised = TRUE; #ifdef __ANDROID__
init_sqlite3();
#endif
#if defined MYDDAS_ODBC #if defined MYDDAS_ODBC
Yap_InitBackMYDDAS_ODBCPreds(); Yap_InitBackMYDDAS_ODBCPreds();
#endif #endif
#if WIN32
Yap_InitBackMYDDAS_SQLITE3Preds();
#endif
#if defined USE_MYDDAS
Yap_InitBackMYDDAS_SharedPreds();
#endif
#if defined MYDDAS_MYSQL
Yap_InitMYDDAS_MySQLPreds();
#endif #endif
#if defined MYDDAS_ODBC #if defined MYDDAS_ODBC
Yap_InitMYDDAS_ODBCPreds(); Yap_InitMYDDAS_ODBCPreds();
#endif #endif
#if WIN32
Yap_InitMYDDAS_SQLITE3Preds();
#endif
#if defined USE_MYDDAS #if defined USE_MYDDAS
Yap_InitMYDDAS_SharedPreds(); Yap_InitMYDDAS_SharedPreds();
#endif #endif
@ -720,6 +712,7 @@ void init_myddas(void) {
Yap_MYDDAS_delete_all_myddas_structs(); Yap_MYDDAS_delete_all_myddas_structs();
#endif #endif
c_db_initialize_myddas(PASS_REGS1); c_db_initialize_myddas(PASS_REGS1);
myddas_initialised = TRUE;
} }
#ifdef _WIN32 #ifdef _WIN32
@ -742,5 +735,3 @@ int WINAPI win_myddas(HANDLE hinst, DWORD reason, LPVOID reserved) {
return 1; return 1;
} }
#endif #endif
#endif /* USE_MYDDAS*/

View File

@ -72,6 +72,7 @@ foreach (driver ${MYDDAS_DBMS})
cpp_driver(MYDDAS_YAP ${driver} myddas_driver.ypp) cpp_driver(MYDDAS_YAP ${driver} myddas_driver.ypp)
endforeach () 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_to_group(MYDDAS_YAP pl_library )
add_custom_target(plmyddas ALL DEPENDS ${MYDDAS_YAP} ) add_custom_target(plmyddas ALL DEPENDS ${MYDDAS_YAP} )
@ -79,4 +80,3 @@ add_custom_target(plmyddas ALL DEPENDS ${MYDDAS_YAP} )
install(FILES ${MYDDAS_YAP} install(FILES ${MYDDAS_YAP}
DESTINATION ${libpl} DESTINATION ${libpl}
) )

View File

@ -243,8 +243,7 @@ db_open(odbc,Connection,ODBCEntry,User,Password) :-
%% sqlite3 %% sqlite3
db_open(sqlite3,Connection,File,User,Password) :- db_open(sqlite3,Connection,File,User,Password) :-
'$error_checks'(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(File,User,Password,Con),
c_sqlite3_connect(FullFile,User,Password,Con),
set_value(Connection,Con). set_value(Connection,Con).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

View File

@ -53,3 +53,6 @@ install(TARGETS sqlite4YAP
LIBRARY DESTINATION ${YAP_INSTALL_DLLDIR} LIBRARY DESTINATION ${YAP_INSTALL_DLLDIR}
) )
endif() endif()
# file (INSTALL chinook.db test.yap DESTINATION ${libpl})

View File

@ -77,7 +77,7 @@ static Int c_sqlite3_get_database(USES_REGS1);
static Int c_sqlite3_change_database(USES_REGS1); static Int c_sqlite3_change_database(USES_REGS1);
static Int c_sqlite3_connect(USES_REGS1) { static Int c_sqlite3_connect(USES_REGS1) {
printf("hello darkness\n");
Term arg_file = Deref(ARG1); Term arg_file = Deref(ARG1);
Term arg_db = ARG4; Term arg_db = ARG4;
@ -88,9 +88,9 @@ static Int c_sqlite3_connect(USES_REGS1) {
CALL_SQLITE(ARG1, open(file, &db)); CALL_SQLITE(ARG1, open(file, &db));
if (!Yap_unify(arg_db, MkAddressTerm(db))) if (!Yap_unify(arg_db, MkAddressTerm(db))) {
return FALSE; return FALSE;
else { } else {
/* Criar um novo no na lista de ligacoes*/ /* Criar um novo no na lista de ligacoes*/
new = myddas_util_add_connection(db, NULL, API_SQLITE3); 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) { X_API void init_sqlite3(void) {
Yap_InitMYDDAS_SQLITE3Preds(); Yap_InitMYDDAS_SQLITE3Preds();
Yap_InitBackMYDDAS_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 #ifdef _WIN32

View File

@ -1,21 +1,18 @@
:- [library(myddas)]. :- compile(library(myddas)).
:- initialization(main).
main :- main :-
setup_call_cleanup(
init, init,
main_ , main_,
(trace, close.
close)).
main_ :- main_ :-
go, go,
fail. fail.
main_ . main_ .
init :- 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('Artist', artist),
db_import('Album', album), db_import('Album', album),
db_import('Track', track). db_import('Track', track).
@ -25,26 +22,24 @@ init :-
db_get_attributes_types(track,Ts), db_get_attributes_types(track,Ts),
db_get_attributes_types(artist,As), db_get_attributes_types(artist,As),
writeln(As:Als:Ts). writeln(As:Als:Ts).
go :- go :-
db_number_of_fields(album,Als), db_number_of_fields(album,Als),
db_number_of_fields(track,Ts), db_number_of_fields(track,Ts),
db_number_of_fields(artist,As), db_number_of_fields(artist,As),
writeln(As:Als:Ts). writeln(As:Als:Ts).
go :- go :-
db_describe(album, Desc), writeln(Desc) ; db_describe(album, Desc), writeln(Desc) ;
db_describe(track, Desc), writeln(Desc) ; db_describe(track, Desc), writeln(Desc) ;
db_describe(artist, Desc), writeln(Desc). db_describe(artist, Desc), writeln(Desc).
go :-
go :-
db_show_tables(Desc), writeln(Desc). db_show_tables(Desc), writeln(Desc).
go :- go :-
db_show_tables(table(T)), db_show_tables(table(T)),
db_describe(T,tableinfo(FieldID,Type,Null,Primary,Default,'')), db_describe(T,tableinfo(FieldID,Type,Null,Primary,Default,'')),
writeln(T:tableinfo(FieldID,Type,Null,Primary,Default,'')). writeln(T:tableinfo(FieldID,Type,Null,Primary,Default,'')).
go :- go :-
go_cut0. go_cut0.
@ -79,3 +74,6 @@ go_cut1 :-
close :- close :-
db_close. db_close.
:- main.

View File

@ -19,7 +19,7 @@ file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/yap4py)
set(YAP4PY_PL prolog/yapi.yap) set(YAP4PY_PL prolog/yapi.yap)
set(YAP4PY_PY yap4py/__main__.py yap4py/yapi.py) 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("MANIFEST.in" ${CMAKE_CURRENT_BINARY_DIR}/MANIFEST.in)
configure_file("YAP4PY.md" README.md) configure_file("YAP4PY.md" README.md)
configure_file(yap4py/__init__.py.in yap4py/__init__.py) configure_file(yap4py/__init__.py.in yap4py/__init__.py)

View File

@ -69,7 +69,7 @@ elif platform.system() == 'Darwin':
win_libs = [] win_libs = []
local_libs = ['Py4YAP'] local_libs = ['Py4YAP']
elif platform.system() == 'Linux': 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 = [] win_libs = []
local_libs = ['Py4YAP'] local_libs = ['Py4YAP']

View File

@ -20,6 +20,7 @@ FILE( MAKE_DIRECTORY ${YAP_APP_DIR}/src/generated/jni)
add_custom_target (pllib add_custom_target (pllib
COMMAND ${CMAKE_COMMAND} -E make_directory ${pllib} COMMAND ${CMAKE_COMMAND} -E make_directory ${pllib}
COMMAND ${CMAKE_COMMAND} -E copy ${pl_library} ${pllib} COMMAND ${CMAKE_COMMAND} -E copy ${pl_library} ${pllib}
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/android.yap ${pllib}
DEPENDS ${pl_library} DEPENDS ${pl_library}
) )

View File

@ -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" #include "streamer.h"
extern "C" {
extern void Java_pt_up_yap_streamerJNI_swig_1module_1init(void);
}
static AndroidStreamer * streamerInstance = 0; static AndroidStreamer * streamerInstance = 0;
void setStreamer(AndroidStreamer* streamer) { void setStreamer(AndroidStreamer* streamer) {
streamerInstance = streamer; streamerInstance = streamer;
Java_pt_up_yap_streamerJNI_swig_1module_1init();
} }
AndroidStreamer& getStreamer() { AndroidStreamer& getStreamer() {
@ -25,13 +31,11 @@ extern "C" {
#include <yapio.h> #include <yapio.h>
#include <iopreds.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; static std::string buff0;
@ -83,21 +87,34 @@ streamerInstance->display(buff0);
} }
void
AndroidStreamer::bind() { extern "C" {
buff0 = *new std::string[256];
andstream.name = "/android/user_error";
andstream.vflags = VFS_CAN_WRITE | VFS_HAS_PREFIX; void Java_pt_up_yap_streamerJNI_swig_1module_1init(void) {
andstream.prefix = "/android"; if (andstream)
andstream.suffix = NULL; return;
andstream.open = and_open; andstream = new VFS_t();
andstream.close = and_close;
andstream.get_char = and_get; andstream->name = "android output window";
andstream.put_char = and_put; andstream->vflags = VFS_CAN_WRITE | VFS_HAS_PREFIX;
andstream.flush = and_flush; andstream->prefix = "/android";
andstream.seek = and_seek; andstream->suffix = NULL;
andstream.next = GLOBAL_VFS; andstream->open = and_open;
GLOBAL_VFS = &andstream; andstream->close = and_close;
Yap_InitStdStream(StdOutStream, Output_Stream_f | Append_Stream_f, NULL, &andstream); andstream->get_char = and_get;
Yap_InitStdStream(StdErrStream, Output_Stream_f | Append_Stream_f, NULL, &andstream); 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);
}
} }

View File

@ -9,10 +9,14 @@
#include <string> #include <string>
#include <sstream> #include <sstream>
struct AndroidStreamer { struct AndroidStreamer {
std::string *buff0;
virtual void display(std::string text) const = 0; virtual void display(std::string text) const = 0;
virtual ~AndroidStreamer() {} virtual ~AndroidStreamer() {}
void bind(); AndroidStreamer() { buff0 = new std::string[256];
};
}; };
void setStreamer(AndroidStreamer* streamer); void setStreamer(AndroidStreamer* streamer);
AndroidStreamer& getStreamer(); AndroidStreamer& getStreamer();

View File

@ -59,6 +59,10 @@ class YAPEngine;
// no way to translate // no way to translate
return NULL; return NULL;
} }
#endif
#ifdef SWIGJAVA0
%typemap(javapackage) std::vector<YAPTerm> "pt.up.yap.YAPTerm"
%template(VectorOfTerm) std::vector<YAPTerm>;
#endif #endif
} }
%} %}

View File

@ -8,6 +8,7 @@ set(PL_BOOT_SOURCES
boot.yap boot.yap
bootlists.yap bootlists.yap
bootutils.yap bootutils.yap
builtins.yap
callcount.yap callcount.yap
checker.yap checker.yap
consult.yap consult.yap
@ -26,6 +27,7 @@ set(PL_BOOT_SOURCES
grammar.yap grammar.yap
ground.yap ground.yap
hacks.yap hacks.yap
imports.yap
init.yap init.yap
listing.yap listing.yap
load_foreign.yap load_foreign.yap

View File

@ -342,7 +342,7 @@ expand_expr(Op, X, Y, O, Q, P) :-
%% contains_illegal_dcgnt(+Term) is semidet. %% contains_illegal_dcgnt(+Term) is semidet.
% %
% True if Term contains a non-terminal we cannot deal with using % 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) :- '$contains_illegal_dcgnt'(NT) :-
functor(NT, _, A), 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'(instantiation_error). % ex: phrase(([1],x:X,[3]),L)
'$harmless_dcgexception'(type_error(callable,_)). % ex: phrase(27,L) '$harmless_dcgexception'(type_error(callable,_)). % ex: phrase(27,L)
:- set_value('$c_arith',true). :- set_value('$c_arith',true).
/** /**
@} @}

View File

@ -291,7 +291,7 @@ initialize_prolog :-
'qly.yap', 'qly.yap',
'spy.yap', 'spy.yap',
'udi.yap']. 'udi.yap'].
:- stop_low_level_trace. %:- stop_low_level_trace.
:- meta_predicate(log_event(+,:)). :- 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'). :- ensure_loaded('../pl/pathconf.yap').
:- yap_flag(user:unknown,error). :- yap_flag(user:unknown,error).

View File

@ -1,5 +1,6 @@
:- '$mk_dynamic'('$parent_module'(_,_),prolog). :- '$mk_dynamic'('$parent_module'(_,_),prolog).
'$get_undefined_predicates'(G, ImportingMod, G0, ExportingMod) :- '$get_undefined_predicates'(G, ImportingMod, G0, ExportingMod) :-
recorded('$import','$import'(ExportingModI,ImportingMod,G0I,G,_,_),_), recorded('$import','$import'(ExportingModI,ImportingMod,G0I,G,_,_),_),
'$continue_imported'(ExportingMod, ExportingModI, G0, G0I). '$continue_imported'(ExportingMod, ExportingModI, G0, G0I).