Merge 192.168.1.103:github/yap-6.3
This commit is contained in:
commit
55f4767621
@ -134,11 +134,12 @@ inline static Atom SearchInInvisible(const unsigned char *atom) {
|
|||||||
|
|
||||||
static inline Atom SearchAtom(const unsigned char *p, Atom a) {
|
static inline Atom SearchAtom(const unsigned char *p, Atom a) {
|
||||||
AtomEntry *ae;
|
AtomEntry *ae;
|
||||||
|
const char *ps = (const char *)p;
|
||||||
|
|
||||||
/* search atom in chain */
|
/* search atom in chain */
|
||||||
while (a != NIL) {
|
while (a != NIL) {
|
||||||
ae = RepAtom(a);
|
ae = RepAtom(a);
|
||||||
if (strcmp(ae->UStrOfAE, p) == 0) {
|
if (strcmp(ae->StrOfAE, ps) == 0) {
|
||||||
return (a);
|
return (a);
|
||||||
}
|
}
|
||||||
a = ae->NextOfAE;
|
a = ae->NextOfAE;
|
||||||
|
@ -77,10 +77,11 @@ void *my_malloc(size_t sz) {
|
|||||||
p = malloc(sz);
|
p = malloc(sz);
|
||||||
// Yap_DebugPuts(stderr,"gof\n");
|
// Yap_DebugPuts(stderr,"gof\n");
|
||||||
if (Yap_do_low_level_trace)
|
if (Yap_do_low_level_trace)
|
||||||
|
#if __ANDROID__
|
||||||
|
__android_log_print(ANDROID_LOG_ERROR, "YAPDroid ", "+ %d %p", write_malloc,p);
|
||||||
|
#else
|
||||||
fprintf(stderr, "+s %p\n @%p %ld\n", p, TR, LCL0 - (CELL *)LCL0);
|
fprintf(stderr, "+s %p\n @%p %ld\n", p, TR, LCL0 - (CELL *)LCL0);
|
||||||
if (sz > 500 && write_malloc++ > 0)
|
#endif
|
||||||
__android_log_print(ANDROID_LOG_ERROR, "YAPDroid ", "+ %d %p", write_malloc,
|
|
||||||
p);
|
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,7 +101,7 @@ void *my_realloc(void *ptr, size_t sz) {
|
|||||||
void my_free(void *p) {
|
void my_free(void *p) {
|
||||||
// printf("f %p\n",p);
|
// printf("f %p\n",p);
|
||||||
if (Yap_do_low_level_trace)
|
if (Yap_do_low_level_trace)
|
||||||
fprintf(stderr, "- %p\n @%p %ld\n", p, TR, LCL0 - (CELL *)LCL0);
|
fprintf(stderr, "- %p\n @%p %ld\n", p, TR, (long int)(LCL0 - (CELL *)B) );
|
||||||
if (write_malloc && write_malloc++ > 0)
|
if (write_malloc && write_malloc++ > 0)
|
||||||
__android_log_print(ANDROID_LOG_ERROR, "YAPDroid ", "- %d %p", write_malloc,
|
__android_log_print(ANDROID_LOG_ERROR, "YAPDroid ", "- %d %p", write_malloc,
|
||||||
p);
|
p);
|
||||||
|
@ -2112,38 +2112,39 @@ X_API void YAP_ClearExceptions(void) {
|
|||||||
Yap_ResetException(worker_id);
|
Yap_ResetException(worker_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
X_API int YAP_InitConsult(int mode, const char *filename, char *full,
|
X_API int YAP_InitConsult(int mode, const char *fname, char *full,
|
||||||
int *osnop) {
|
int *osnop) {
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
FILE *f = NULL;
|
|
||||||
int sno;
|
int sno;
|
||||||
BACKUP_MACHINE_REGS();
|
BACKUP_MACHINE_REGS();
|
||||||
|
int lvl = push_text_stack();
|
||||||
if (mode == YAP_BOOT_MODE) {
|
if (mode == YAP_BOOT_MODE) {
|
||||||
mode = YAP_CONSULT_MODE;
|
mode = YAP_CONSULT_MODE;
|
||||||
}
|
}
|
||||||
|
char *bfp = Malloc(YAP_FILENAME_MAX+1);
|
||||||
|
bfp[0] = '\0';
|
||||||
|
if(fname != NULL && fname[0] != 0 )
|
||||||
|
strcpy( bfp, fname );
|
||||||
bool consulted = (mode == YAP_CONSULT_MODE);
|
bool consulted = (mode == YAP_CONSULT_MODE);
|
||||||
Yap_init_consult(consulted, filename);
|
const char *fl = Yap_findFile(bfp, NULL, NULL, full, true,
|
||||||
const char *fl = Yap_findFile(filename, NULL, BootFilePath, full, true,
|
|
||||||
YAP_BOOT_PL, true, true);
|
YAP_BOOT_PL, true, true);
|
||||||
if (!fl)
|
if (!fl || !fl[0]) {
|
||||||
return -1;
|
pop_text_stack(lvl);
|
||||||
f = fopen(fl, "r");
|
|
||||||
if (!f)
|
|
||||||
return -1;
|
|
||||||
if (!f) {
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
sno = Yap_OpenStream(f, NULL, TermNil, Input_Stream_f);
|
Yap_init_consult(consulted,bfp);
|
||||||
|
sno = Yap_OpenStream(fl, "r" );
|
||||||
*osnop = Yap_CheckAlias(AtomLoopStream);
|
*osnop = Yap_CheckAlias(AtomLoopStream);
|
||||||
if (!Yap_AddAlias(AtomLoopStream, sno)) {
|
if (!Yap_AddAlias(AtomLoopStream, sno)) {
|
||||||
Yap_CloseStream(sno);
|
Yap_CloseStream(sno);
|
||||||
sno = -1;
|
pop_text_stack(lvl);
|
||||||
|
sno = -1;
|
||||||
}
|
}
|
||||||
GLOBAL_Stream[sno].name = Yap_LookupAtom(fl);
|
GLOBAL_Stream[sno].name = Yap_LookupAtom(fl);
|
||||||
GLOBAL_Stream[sno].user_name = MkAtomTerm(Yap_LookupAtom(filename));
|
GLOBAL_Stream[sno].user_name = MkAtomTerm(Yap_LookupAtom(fname));
|
||||||
GLOBAL_Stream[sno].encoding = ENC_ISO_UTF8;
|
GLOBAL_Stream[sno].encoding = LOCAL_encoding;
|
||||||
RECOVER_MACHINE_REGS();
|
pop_text_stack(lvl);
|
||||||
|
RECOVER_MACHINE_REGS();
|
||||||
UNLOCK(GLOBAL_Stream[sno].streamlock);
|
UNLOCK(GLOBAL_Stream[sno].streamlock);
|
||||||
return sno;
|
return sno;
|
||||||
}
|
}
|
||||||
@ -2181,7 +2182,7 @@ X_API void YAP_EndConsult(int sno, int *osnop) {
|
|||||||
|
|
||||||
X_API Term YAP_Read(FILE *f) {
|
X_API Term YAP_Read(FILE *f) {
|
||||||
Term o;
|
Term o;
|
||||||
int sno = Yap_OpenStream(f, NULL, TermNil, Input_Stream_f);
|
int sno = Yap_FileStream(f, NULL, TermNil, Input_Stream_f);
|
||||||
|
|
||||||
BACKUP_MACHINE_REGS();
|
BACKUP_MACHINE_REGS();
|
||||||
o = Yap_read_term(sno, TermNil, 1);
|
o = Yap_read_term(sno, TermNil, 1);
|
||||||
@ -2210,7 +2211,7 @@ X_API Term YAP_ReadClauseFromStream(int sno) {
|
|||||||
|
|
||||||
X_API void YAP_Write(Term t, FILE *f, int flags) {
|
X_API void YAP_Write(Term t, FILE *f, int flags) {
|
||||||
BACKUP_MACHINE_REGS();
|
BACKUP_MACHINE_REGS();
|
||||||
int sno = Yap_OpenStream(f, NULL, TermNil, Output_Stream_f);
|
int sno = Yap_FileStream(f, NULL, TermNil, Output_Stream_f);
|
||||||
|
|
||||||
Yap_plwrite(t, GLOBAL_Stream + sno, 0, flags, GLOBAL_MaxPriority);
|
Yap_plwrite(t, GLOBAL_Stream + sno, 0, flags, GLOBAL_MaxPriority);
|
||||||
Yap_ReleaseStream(sno);
|
Yap_ReleaseStream(sno);
|
||||||
@ -2304,21 +2305,23 @@ X_API char *YAP_CompileClause(Term t) {
|
|||||||
static int yap_lineno = 0;
|
static int yap_lineno = 0;
|
||||||
|
|
||||||
/* do initial boot by consulting the file boot.yap */
|
/* do initial boot by consulting the file boot.yap */
|
||||||
static void do_bootfile(const char *bootfilename USES_REGS) {
|
static void do_bootfile(const char *b_file USES_REGS) {
|
||||||
Term t;
|
Term t;
|
||||||
int bootfile, osno;
|
int bootfile, osno;
|
||||||
Functor functor_query = Yap_MkFunctor(Yap_LookupAtom("?-"), 1);
|
Functor functor_query = Yap_MkFunctor(Yap_LookupAtom("?-"), 1);
|
||||||
Functor functor_command1 = Yap_MkFunctor(Yap_LookupAtom(":-"), 1);
|
Functor functor_command1 = Yap_MkFunctor(Yap_LookupAtom(":-"), 1);
|
||||||
char full[YAP_FILENAME_MAX + 1];
|
|
||||||
|
|
||||||
/* consult boot.pl */
|
/* consult boot.pl */
|
||||||
|
char *full = malloc(YAP_FILENAME_MAX + 1);
|
||||||
|
full[0] = '\0';
|
||||||
/* the consult mode does not matter here, really */
|
/* the consult mode does not matter here, really */
|
||||||
bootfile = YAP_InitConsult(YAP_BOOT_MODE, bootfilename, full, &osno);
|
bootfile = YAP_InitConsult(YAP_BOOT_MODE, b_file, full, &osno);
|
||||||
if (bootfile < 0) {
|
if (bootfile < 0) {
|
||||||
fprintf(stderr, "[ FATAL ERROR: could not open bootfile %s ]\n",
|
fprintf(stderr, "[ FATAL ERROR: could not open bootfile %s ]\n",
|
||||||
bootfilename);
|
b_file);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
free(full);
|
||||||
do {
|
do {
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
YAP_Reset(YAP_FULL_RESET);
|
YAP_Reset(YAP_FULL_RESET);
|
||||||
@ -2329,7 +2332,7 @@ static void do_bootfile(const char *bootfilename USES_REGS) {
|
|||||||
if (t == 0) {
|
if (t == 0) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"[ SYNTAX ERROR: while parsing bootfile %s at line %d ]\n",
|
"[ SYNTAX ERROR: while parsing bootfile %s at line %d ]\n",
|
||||||
bootfilename, yap_lineno);
|
b_file, yap_lineno);
|
||||||
} else if (YAP_IsVarTerm(t) || t == TermNil) {
|
} else if (YAP_IsVarTerm(t) || t == TermNil) {
|
||||||
fprintf(stderr, "[ line %d: term cannot be compiled ]", yap_lineno);
|
fprintf(stderr, "[ line %d: term cannot be compiled ]", yap_lineno);
|
||||||
} else if (YAP_IsPairTerm(t)) {
|
} else if (YAP_IsPairTerm(t)) {
|
||||||
@ -2420,10 +2423,11 @@ static void do_bootfile(const char *bootfilename USES_REGS) {
|
|||||||
YAP_file_type_t restore_result = yap_init->boot_file_type;
|
YAP_file_type_t restore_result = yap_init->boot_file_type;
|
||||||
bool do_bootstrap = (restore_result & YAP_CONSULT_MODE);
|
bool do_bootstrap = (restore_result & YAP_CONSULT_MODE);
|
||||||
CELL Trail = 0, Stack = 0, Heap = 0, Atts = 0;
|
CELL Trail = 0, Stack = 0, Heap = 0, Atts = 0;
|
||||||
char boot_file[YAP_FILENAME_MAX + 1];
|
char *boot_file;
|
||||||
Int rc;
|
Int rc;
|
||||||
const char *yroot;
|
const char *yroot;
|
||||||
|
|
||||||
|
boot_file = calloc(YAP_FILENAME_MAX + 1, 1);
|
||||||
/* ignore repeated calls to YAP_Init */
|
/* ignore repeated calls to YAP_Init */
|
||||||
if (YAP_initialized)
|
if (YAP_initialized)
|
||||||
return YAP_FOUND_BOOT_ERROR;
|
return YAP_FOUND_BOOT_ERROR;
|
||||||
@ -2450,7 +2454,12 @@ static void do_bootfile(const char *bootfilename USES_REGS) {
|
|||||||
if (yap_init->SavedState == NULL) {
|
if (yap_init->SavedState == NULL) {
|
||||||
yap_init->SavedState = YAP_STARTUP;
|
yap_init->SavedState = YAP_STARTUP;
|
||||||
}
|
}
|
||||||
|
if (!LOCAL_TextBuffer)
|
||||||
|
LOCAL_TextBuffer = Yap_InitTextAllocator();
|
||||||
|
#if __ANDROID__
|
||||||
|
//if (yap_init->assetManager)
|
||||||
|
Yap_InitAssetManager( );
|
||||||
|
#endif
|
||||||
#if USE_DL_MALLOC
|
#if USE_DL_MALLOC
|
||||||
if (yap_init->SavedState == NULL)
|
if (yap_init->SavedState == NULL)
|
||||||
yap_init->SavedState = YAP_STARTUP;
|
yap_init->SavedState = YAP_STARTUP;
|
||||||
@ -2467,9 +2476,10 @@ static void do_bootfile(const char *bootfilename USES_REGS) {
|
|||||||
if (yap_init->YapPrologBootFile == NULL)
|
if (yap_init->YapPrologBootFile == NULL)
|
||||||
yap_init->YapPrologBootFile = BootFile;
|
yap_init->YapPrologBootFile = BootFile;
|
||||||
#else
|
#else
|
||||||
yap_init->YapPrologBootFile =
|
|
||||||
Yap_findFile(yap_init->YapPrologBootFile, BootFile, yroot, boot_file,
|
const char *s = Yap_findFile(yap_init->YapPrologBootFile, BootFile, yroot, boot_file,
|
||||||
true, YAP_BOOT_PL, true, true);
|
true, YAP_BOOT_PL, true, true);
|
||||||
|
if (s && s[0] != '\0') strcpy(boot_file, s);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2619,18 +2629,17 @@ static void do_bootfile(const char *bootfilename USES_REGS) {
|
|||||||
setBooleanGlobalPrologFlag(SAVED_PROGRAM_FLAG, true);
|
setBooleanGlobalPrologFlag(SAVED_PROGRAM_FLAG, true);
|
||||||
rc = YAP_QLY;
|
rc = YAP_QLY;
|
||||||
} else {
|
} else {
|
||||||
if (!yap_init->YapPrologBootFile)
|
if (boot_file[0] == '\0')
|
||||||
yap_init->YapPrologBootFile = BootFile;
|
strcpy(boot_file, BootFile);
|
||||||
rc = YAP_BOOT_PL;
|
do_bootfile(boot_file PASS_REGS);
|
||||||
do_bootfile(yap_init->YapPrologBootFile);
|
|
||||||
setAtomicGlobalPrologFlag(
|
setAtomicGlobalPrologFlag(
|
||||||
RESOURCE_DATABASE_FLAG,
|
RESOURCE_DATABASE_FLAG,
|
||||||
MkAtomTerm(Yap_LookupAtom(yap_init->YapPrologBootFile)));
|
MkAtomTerm(Yap_LookupAtom(boot_file)));
|
||||||
setBooleanGlobalPrologFlag(SAVED_PROGRAM_FLAG, false);
|
setBooleanGlobalPrologFlag(SAVED_PROGRAM_FLAG, false);
|
||||||
}
|
}
|
||||||
start_modules();
|
start_modules();
|
||||||
YAP_initialized = true;
|
YAP_initialized = true;
|
||||||
return rc;
|
return YAP_BOOT_PL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (DefTrailSpace < MinTrailSpace)
|
#if (DefTrailSpace < MinTrailSpace)
|
||||||
@ -2652,7 +2661,7 @@ static void do_bootfile(const char *bootfilename USES_REGS) {
|
|||||||
#define DEFAULT_SCHEDULERLOOP 10
|
#define DEFAULT_SCHEDULERLOOP 10
|
||||||
#define DEFAULT_DELAYEDRELEASELOAD 3
|
#define DEFAULT_DELAYEDRELEASELOAD 3
|
||||||
|
|
||||||
X_API YAP_file_type_t YAP_FastInit(char saved_state[], int argc, char *argv[]) {
|
X_API YAP_file_type_t YAP_FastInit(char *saved_state, int argc, char *argv[]) {
|
||||||
YAP_init_args init_args;
|
YAP_init_args init_args;
|
||||||
YAP_file_type_t out;
|
YAP_file_type_t out;
|
||||||
|
|
||||||
|
43
C/cdmgr.c
43
C/cdmgr.c
@ -1873,8 +1873,6 @@ bool Yap_addclause(Term t, yamop *cp, Term tmode, Term mod, Term *t4ref)
|
|||||||
} else {
|
} else {
|
||||||
tf = Yap_MkStaticRefTerm(ClauseCodeToStaticClause(cp), p);
|
tf = Yap_MkStaticRefTerm(ClauseCodeToStaticClause(cp), p);
|
||||||
}
|
}
|
||||||
__android_log_print(ANDROID_LOG_INFO, "YAPDroid", "add %s/%ld %p",
|
|
||||||
RepAtom(at)->StrOfAE, Arity);
|
|
||||||
if (mod == PROLOG_MODULE)
|
if (mod == PROLOG_MODULE)
|
||||||
mod = TermProlog;
|
mod = TermProlog;
|
||||||
if (pflags & MultiFileFlag) {
|
if (pflags & MultiFileFlag) {
|
||||||
@ -2059,36 +2057,33 @@ Atom Yap_ConsultingFile(USES_REGS1) {
|
|||||||
if (LOCAL_consult_level == 0) {
|
if (LOCAL_consult_level == 0) {
|
||||||
return (AtomUser);
|
return (AtomUser);
|
||||||
} else {
|
} else {
|
||||||
return (Yap_ULookupAtom(LOCAL_ConsultBase[2].filename));
|
return (Yap_ULookupAtom(LOCAL_ConsultBase[2].f_name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* consult file *file*, *mode* may be one of either consult or reconsult */
|
/* consult file *file*, *mode* may be one of either consult or reconsult */
|
||||||
static void init_consult(int mode, const unsigned char *file) {
|
void Yap_init_consult(int mode, const char *filenam) {
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
if (!LOCAL_ConsultSp) {
|
if (!LOCAL_ConsultSp) {
|
||||||
InitConsultStack();
|
InitConsultStack();
|
||||||
}
|
}
|
||||||
if (LOCAL_ConsultSp >= LOCAL_ConsultLow + 6) {
|
if (LOCAL_ConsultSp >= LOCAL_ConsultLow + 6) {
|
||||||
expand_consult();
|
expand_consult();
|
||||||
}
|
}
|
||||||
LOCAL_ConsultSp--;
|
LOCAL_ConsultSp--;
|
||||||
LOCAL_ConsultSp->filename = file;
|
LOCAL_ConsultSp->f_name = (const unsigned char *)filenam;
|
||||||
LOCAL_ConsultSp--;
|
LOCAL_ConsultSp--;
|
||||||
LOCAL_ConsultSp->mode = mode;
|
LOCAL_ConsultSp->mode = mode;
|
||||||
LOCAL_ConsultSp--;
|
LOCAL_ConsultSp--;
|
||||||
LOCAL_ConsultSp->c = (LOCAL_ConsultBase - LOCAL_ConsultSp);
|
LOCAL_ConsultSp->c = (LOCAL_ConsultBase - LOCAL_ConsultSp);
|
||||||
LOCAL_ConsultBase = LOCAL_ConsultSp;
|
LOCAL_ConsultBase = LOCAL_ConsultSp;
|
||||||
#if !defined(YAPOR) && !defined(YAPOR_SBA)
|
#if !defined(YAPOR) && !defined(YAPOR_SBA)
|
||||||
/* if (LOCAL_consult_level == 0)
|
/* if (LOCAL_consult_level == 0)
|
||||||
do_toggle_static_predicates_in_use(TRUE); */
|
do_toggle_static_predicates_in_use(TRUE); */
|
||||||
#endif
|
#endif
|
||||||
LOCAL_consult_level++;
|
LOCAL_consult_level++;
|
||||||
LOCAL_LastAssertedPred = NULL;
|
LOCAL_LastAssertedPred = NULL;
|
||||||
}
|
|
||||||
|
|
||||||
void Yap_init_consult(int mode, const char *file) {
|
|
||||||
init_consult(mode, (const unsigned char *)file);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int p_startconsult(USES_REGS1) { /* '$start_consult'(+Mode) */
|
static Int p_startconsult(USES_REGS1) { /* '$start_consult'(+Mode) */
|
||||||
@ -2097,7 +2092,7 @@ static Int p_startconsult(USES_REGS1) { /* '$start_consult'(+Mode) */
|
|||||||
int mode;
|
int mode;
|
||||||
|
|
||||||
mode = strcmp("consult", (char *)smode);
|
mode = strcmp("consult", (char *)smode);
|
||||||
init_consult(mode, RepAtom(AtomOfTerm(Deref(ARG2)))->UStrOfAE);
|
Yap_init_consult(mode, RepAtom(AtomOfTerm(Deref(ARG2)))->StrOfAE);
|
||||||
t = MkIntTerm(LOCAL_consult_level);
|
t = MkIntTerm(LOCAL_consult_level);
|
||||||
return (Yap_unify_constant(ARG3, t));
|
return (Yap_unify_constant(ARG3, t));
|
||||||
}
|
}
|
||||||
|
40
C/text.c
40
C/text.c
@ -31,6 +31,11 @@ inline static size_t min_size(size_t i, size_t j) { return (i < j ? i : j); }
|
|||||||
#define wcsnlen(S, N) min_size(N, wcslen(S))
|
#define wcsnlen(S, N) min_size(N, wcslen(S))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef HAVE_STPCPY
|
||||||
|
inline static void* __stpcpy(void * i, const void * j) { return strcpy(i,j)+strlen(j);}
|
||||||
|
#define stpcpy __stpcpy
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef NAN
|
#ifndef NAN
|
||||||
#define NAN (0.0 / 0.0)
|
#define NAN (0.0 / 0.0)
|
||||||
#endif
|
#endif
|
||||||
@ -77,7 +82,7 @@ int pop_text_stack__(int i) {
|
|||||||
return lvl;
|
return lvl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *pop_output_text_stack__(int i, void *export) {
|
void *pop_output_text_stack__(int i, const void *export) {
|
||||||
int lvl = LOCAL_TextBuffer->lvl;
|
int lvl = LOCAL_TextBuffer->lvl;
|
||||||
while (lvl >= i) {
|
while (lvl >= i) {
|
||||||
struct mblock *p = LOCAL_TextBuffer->first[lvl];
|
struct mblock *p = LOCAL_TextBuffer->first[lvl];
|
||||||
@ -993,7 +998,7 @@ bool Yap_Splice_Text(int n, size_t cuts[], seq_tv_t *inp,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
b_l0 = strlen((const char *)buf0);
|
b_l0 = strlen((const char *)buf0);
|
||||||
if (bcmp(buf, buf0, b_l0) != 0) {
|
if (memcmp(buf, buf0, b_l0) != 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
u_l0 = strlen_utf8(buf0);
|
u_l0 = strlen_utf8(buf0);
|
||||||
@ -1016,7 +1021,7 @@ bool Yap_Splice_Text(int n, size_t cuts[], seq_tv_t *inp,
|
|||||||
u_l1 = strlen_utf8(buf1);
|
u_l1 = strlen_utf8(buf1);
|
||||||
b_l0 = b_l - b_l1;
|
b_l0 = b_l - b_l1;
|
||||||
u_l0 = u_l - u_l1;
|
u_l0 = u_l - u_l1;
|
||||||
if (bcmp(skip_utf8((const unsigned char *)buf, b_l0), buf1, b_l1) !=
|
if (memcmp(skip_utf8((const unsigned char *)buf, b_l0), buf1, b_l1) !=
|
||||||
0) {
|
0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1043,35 +1048,6 @@ bool Yap_Splice_Text(int n, size_t cuts[], seq_tv_t *inp,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Function to convert a generic text term (string, atom, list of codes, list
|
|
||||||
of<
|
|
||||||
atoms) into a buff
|
|
||||||
er.
|
|
||||||
*
|
|
||||||
* @param t the term
|
|
||||||
* @param buf the buffer, if NULL a buffer is malloced, and the user should
|
|
||||||
reclai it
|
|
||||||
* @param len buffer size
|
|
||||||
* @param enc encoding (UTF-8 is strongly recommended)
|
|
||||||
*
|
|
||||||
* @return the buffer, or NULL in case of failure. If so, Yap_Error may be
|
|
||||||
called.
|
|
||||||
*/
|
|
||||||
const char *Yap_TextTermToText(Term t USES_REGS) {
|
|
||||||
seq_tv_t inp, out;
|
|
||||||
inp.val.t = t;
|
|
||||||
inp.type = Yap_TextType(t);
|
|
||||||
inp.type = YAP_STRING_ATOM | YAP_STRING_STRING | YAP_STRING_ATOMS_CODES |
|
|
||||||
YAP_STRING_TERM;
|
|
||||||
inp.enc = ENC_ISO_UTF8;
|
|
||||||
out.enc = ENC_ISO_UTF8;
|
|
||||||
out.type = YAP_STRING_CHARS;
|
|
||||||
out.val.c = NULL;
|
|
||||||
if (!Yap_CVT_Text(&inp, &out PASS_REGS))
|
|
||||||
return NULL;
|
|
||||||
return out.val.c;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert from a predicate structure to an UTF-8 string of the form
|
* Convert from a predicate structure to an UTF-8 string of the form
|
||||||
|
12
C/yap-args.c
12
C/yap-args.c
@ -147,12 +147,14 @@ static int dump_runtime_variables(void) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
YAP_file_type_t Yap_InitDefaults(YAP_init_args *iap, char saved_state[],
|
YAP_file_type_t Yap_InitDefaults(YAP_init_args *iap, char *saved_state,
|
||||||
int argc, char *argv[]) {
|
int argc, char *argv[]) {
|
||||||
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->SavedState = malloc(strlen(saved_state)+1);
|
||||||
|
strcpy(iap->SavedState, saved_state);
|
||||||
|
iap->assetManager = true;
|
||||||
#else
|
#else
|
||||||
iap->boot_file_type = YAP_QLY;
|
iap->boot_file_type = YAP_QLY;
|
||||||
iap->SavedState = saved_state;
|
iap->SavedState = saved_state;
|
||||||
@ -496,11 +498,7 @@ X_API YAP_file_type_t YAP_parse_yap_arguments(int argc, char *argv[],
|
|||||||
} else if (!strncmp("-home=", p, strlen("-home="))) {
|
} else if (!strncmp("-home=", p, strlen("-home="))) {
|
||||||
GLOBAL_Home = p + strlen("-home=");
|
GLOBAL_Home = p + strlen("-home=");
|
||||||
} else if (!strncmp("-cwd=", p, strlen("-cwd="))) {
|
} else if (!strncmp("-cwd=", p, strlen("-cwd="))) {
|
||||||
#if __WINDOWS__
|
if (!ChDir(p + strlen("-cwd=")) ) {
|
||||||
if (_chdir(p + strlen("-cwd=")) < 0) {
|
|
||||||
#else
|
|
||||||
if (chdir(p + strlen("-cwd=")) < 0) {
|
|
||||||
#endif
|
|
||||||
fprintf(stderr, " [ YAP unrecoverable error in setting cwd: %s ]\n",
|
fprintf(stderr, " [ YAP unrecoverable error in setting cwd: %s ]\n",
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
}
|
}
|
||||||
|
@ -249,9 +249,6 @@ if (APPLE)
|
|||||||
endif ()
|
endif ()
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
if (ANDROID)
|
|
||||||
set(datarootdir /assets)
|
|
||||||
endif ()
|
|
||||||
set(prefix ${CMAKE_INSTALL_PREFIX}) #BINDIR})
|
set(prefix ${CMAKE_INSTALL_PREFIX}) #BINDIR})
|
||||||
set(bindir ${CMAKE_INSTALL_PREFIX}/bin) #BINDIR})
|
set(bindir ${CMAKE_INSTALL_PREFIX}/bin) #BINDIR})
|
||||||
set(includedir ${CMAKE_INSTALL_PREFIX}/include) #INCLUDEDIR})
|
set(includedir ${CMAKE_INSTALL_PREFIX}/include) #INCLUDEDIR})
|
||||||
@ -259,6 +256,10 @@ set(libdir ${CMAKE_INSTALL_PREFIX}/lib) #LIBDIR})
|
|||||||
set(exec_prefix ${CMAKE_INSTALL_PREFIX}/libexec) #LIBEXECDIR})
|
set(exec_prefix ${CMAKE_INSTALL_PREFIX}/libexec) #LIBEXECDIR})
|
||||||
set(datarootdir ${CMAKE_INSTALL_PREFIX}/share) #DATAROOTDIR})
|
set(datarootdir ${CMAKE_INSTALL_PREFIX}/share) #DATAROOTDIR})
|
||||||
set(datadir ${CMAKE_INSTALL_PREFIX}/share) #DATADIR})
|
set(datadir ${CMAKE_INSTALL_PREFIX}/share) #DATADIR})
|
||||||
|
if (ANDROID)
|
||||||
|
set(datarootdir ${YAP_APP_DIR}/src/generated/assets)
|
||||||
|
set(datadir ${YAP_APP_DIR}/src/generated/assets)
|
||||||
|
endif ()
|
||||||
set(mandir ${CMAKE_INSTALL_PREFIX}/share/man) #MANDIR})
|
set(mandir ${CMAKE_INSTALL_PREFIX}/share/man) #MANDIR})
|
||||||
set(docdir ${CMAKE_INSTALL_PREFIX}/share/docs) #MANDIR})
|
set(docdir ${CMAKE_INSTALL_PREFIX}/share/docs) #MANDIR})
|
||||||
|
|
||||||
@ -458,12 +459,12 @@ endif ()
|
|||||||
|
|
||||||
OPTION(WITH_SWIG " Enable SWIG interfaces to foreign languages" ON)
|
OPTION(WITH_SWIG " Enable SWIG interfaces to foreign languages" ON)
|
||||||
|
|
||||||
IF (WITH_SWIG OR ANDROID)
|
IF (WITH_SWIG)
|
||||||
find_host_package(SWIG)
|
find_host_package(SWIG)
|
||||||
# macro_log_feature (SWIG_FOUND "Swig"
|
# macro_log_feature (SWIG_FOUND "Swig"
|
||||||
# "Use SWIG Interface Generator "
|
# "Use SWIG Interface Generator "
|
||||||
# "http://www.swig.org" ON)
|
# "http://www.swig.org" ON)
|
||||||
ENDIF (WITH_SWIG OR ANDROID)
|
ENDIF (WITH_SWIG)
|
||||||
|
|
||||||
|
|
||||||
option(WITH_PYTHON
|
option(WITH_PYTHON
|
||||||
@ -614,11 +615,6 @@ ADD_SUBDIRECTORY(library)
|
|||||||
|
|
||||||
ADD_SUBDIRECTORY(swi/library "swiLibrary")
|
ADD_SUBDIRECTORY(swi/library "swiLibrary")
|
||||||
|
|
||||||
if (ANDROID)
|
|
||||||
target_link_libraries(libYap android log)
|
|
||||||
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
set_target_properties(libYap
|
set_target_properties(libYap
|
||||||
PROPERTIES OUTPUT_NAME Yap
|
PROPERTIES OUTPUT_NAME Yap
|
||||||
)
|
)
|
||||||
@ -638,8 +634,9 @@ if (PYTHONLIBS_FOUND AND SWIG_FOUND)
|
|||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
|
||||||
IF (SWIG_FOUND OR ANDROID)
|
IF ( ANDROID)
|
||||||
add_subDIRECTORY(packages/swig NO_POLICY_SCOPE)
|
add_subDIRECTORY(packages/swig )
|
||||||
|
target_link_libraries(libYap android log)
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
|
|
||||||
|
|
||||||
@ -801,9 +798,11 @@ CMAKE_DEPENDENT_OPTION(WITH_SYSTEM_MMAP "Use MMAP for shared memory allocation"
|
|||||||
CMAKE_DEPENDENT_OPTION(WITH_SYSTEM_SHM "Use SHM for shared memory allocation" ON
|
CMAKE_DEPENDENT_OPTION(WITH_SYSTEM_SHM "Use SHM for shared memory allocation" ON
|
||||||
"NOT WITH_YAPOR_THOR; NOT WITH_SYSTEM_MMAP" OFF)
|
"NOT WITH_YAPOR_THOR; NOT WITH_SYSTEM_MMAP" OFF)
|
||||||
|
|
||||||
|
if (NOT ANDROID)
|
||||||
|
|
||||||
add_subDIRECTORY(library/lammpi)
|
add_subDIRECTORY(library/lammpi)
|
||||||
|
|
||||||
if (MPI_C_FOUND)
|
if (MPI_C_FOUND\D)
|
||||||
|
|
||||||
CMAKE_DEPENDENT_OPTION(WITH_MPI ON "Interface to OpenMPI/MPICH"
|
CMAKE_DEPENDENT_OPTION(WITH_MPI ON "Interface to OpenMPI/MPICH"
|
||||||
"MPI_C_FOUND" OFF)
|
"MPI_C_FOUND" OFF)
|
||||||
@ -822,6 +821,8 @@ if (MPI_C_FOUND)
|
|||||||
endif ()
|
endif ()
|
||||||
endif (MPI_C_FOUND)
|
endif (MPI_C_FOUND)
|
||||||
|
|
||||||
|
endif(NOT ANDROID)
|
||||||
|
|
||||||
## add_subDIRECTORY(utils)
|
## add_subDIRECTORY(utils)
|
||||||
|
|
||||||
#
|
#
|
||||||
|
24
CXX/yapi.cpp
24
CXX/yapi.cpp
@ -625,7 +625,7 @@ Term YAPEngine::fun(Term t)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
DBTerm *pt = Yap_StoreTermInDB(Yap_GetFromSlot(o), arity);
|
DBTerm *pt = Yap_StoreTermInDB(Yap_GetFromSlot(o), arity);
|
||||||
__android_log_print(ANDROID_LOG_INFO, "YAPDroid", "out %ld", o);
|
__android_log_print(ANDROID_LOG_INFO, "YAPDroid", "out %d", o);
|
||||||
YAP_LeaveGoal(false, &q);
|
YAP_LeaveGoal(false, &q);
|
||||||
Yap_CloseHandles(q.CurSlot);
|
Yap_CloseHandles(q.CurSlot);
|
||||||
Term rc = Yap_PopTermFromDB(pt);
|
Term rc = Yap_PopTermFromDB(pt);
|
||||||
@ -751,8 +751,8 @@ bool YAPQuery::next()
|
|||||||
}
|
}
|
||||||
if (result)
|
if (result)
|
||||||
{
|
{
|
||||||
__android_log_print(ANDROID_LOG_INFO, "YAPDroid", "vnames %d %s %ld",
|
__android_log_print(ANDROID_LOG_INFO, "YAPDroid", "vnames %d %s %d",
|
||||||
q_state, vnames.text(), LOCAL_CurSlot);
|
q_state, names.text(), LOCAL_CurSlot);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -892,6 +892,8 @@ static size_t Yap_AndroidMax, Yap_AndroidSz;
|
|||||||
|
|
||||||
extern void (*Yap_DisplayWithJava)(int c);
|
extern void (*Yap_DisplayWithJava)(int c);
|
||||||
|
|
||||||
|
static YAPCallback *cb = new YAPCallback();
|
||||||
|
|
||||||
void Yap_displayWithJava(int c)
|
void Yap_displayWithJava(int c)
|
||||||
{
|
{
|
||||||
char *ptr = Yap_AndroidBufp;
|
char *ptr = Yap_AndroidBufp;
|
||||||
@ -914,17 +916,18 @@ void Yap_displayWithJava(int c)
|
|||||||
if (c == '\n')
|
if (c == '\n')
|
||||||
{
|
{
|
||||||
Yap_AndroidBufp[Yap_AndroidSz] = '\0';
|
Yap_AndroidBufp[Yap_AndroidSz] = '\0';
|
||||||
curren->run(Yap_AndroidBufp);
|
cb->run(Yap_AndroidBufp);
|
||||||
Yap_AndroidSz = 0;
|
Yap_AndroidSz = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
void YAPEngine::doInit(YAP_file_type_t BootMode)
|
void YAPEngine::doInit(YAP_file_type_t BootMode)
|
||||||
{
|
{
|
||||||
if ((BootMode = YAP_Init(&engine_args->init_args)) == YAP_FOUND_BOOT_ERROR)
|
if ((BootMode = YAP_Init(engine_args)) == YAP_FOUND_BOOT_ERROR)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
throw YAPError();
|
throw YAPError();
|
||||||
@ -945,26 +948,29 @@ void YAPEngine::doInit(YAP_file_type_t BootMode)
|
|||||||
YAPQuery initq = YAPQuery(YAPPredicate(p), nullptr);
|
YAPQuery initq = YAPQuery(YAPPredicate(p), nullptr);
|
||||||
if (initq.next())
|
if (initq.next())
|
||||||
{
|
{
|
||||||
initq.cut();
|
initq.cut();
|
||||||
}
|
}
|
||||||
CurrentModule = TermUser;
|
CurrentModule = TermUser;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
YAPEngine::YAPEngine(int argc, char *argv[],
|
YAPEngine::YAPEngine(int argc, char *argv[],
|
||||||
YAPCallback *cb)
|
YAPCallback *cb)
|
||||||
: _callback(0) { // a single engine can be active
|
: _callback(0) { // a single engine can be active
|
||||||
|
|
||||||
YAP_file_type_t BootMode;
|
YAP_file_type_t BootMode;
|
||||||
engine_args = new YAPEngineArgs();
|
engine_args = new YAPEngineArgs();
|
||||||
BootMode = YAP_parse_yap_arguments(argc, argv, &engine_args->init_args);
|
BootMode = YAP_parse_yap_arguments(argc, argv, engine_args);
|
||||||
// delYAPCallback()b
|
// delYAPCallback()b
|
||||||
// if (cb)
|
// if (cb)
|
||||||
// setYAPCallback(cb);
|
// setYAPCallback(cb);
|
||||||
doInit(BootMode);
|
|
||||||
|
doInit(BootMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
YAPPredicate::YAPPredicate(YAPAtom at)
|
YAPPredicate::YAPPredicate(YAPAtom at)
|
||||||
{
|
{
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
|
112
CXX/yapq.hh
112
CXX/yapq.hh
@ -25,6 +25,10 @@ class X_API YAPPredicate;
|
|||||||
Queries and engines
|
Queries and engines
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#if __ANDROID__
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Queries
|
* @brief Queries
|
||||||
*
|
*
|
||||||
@ -94,11 +98,11 @@ YAPQuery() {
|
|||||||
inline YAPQuery(const char *s) : YAPPredicate(s, tgoal, tnames)
|
inline YAPQuery(const char *s) : YAPPredicate(s, tgoal, tnames)
|
||||||
{
|
{
|
||||||
CELL *qt = nullptr;
|
CELL *qt = nullptr;
|
||||||
__android_log_print(ANDROID_LOG_INFO, "YAPDroid", "got game %ld",
|
__android_log_print(ANDROID_LOG_INFO, "YAPDroid", "got game %d",
|
||||||
LOCAL_CurSlot);
|
LOCAL_CurSlot);
|
||||||
if (!ap)
|
if (!ap)
|
||||||
return;
|
return;
|
||||||
__android_log_print(ANDROID_LOG_INFO, "YAPDroid", "%s", vnames.text());
|
__android_log_print(ANDROID_LOG_INFO, "YAPDroid", "%s", names.text());
|
||||||
goal = YAPTerm(tgoal);
|
goal = YAPTerm(tgoal);
|
||||||
if (IsPairTerm(tgoal)) {
|
if (IsPairTerm(tgoal)) {
|
||||||
qt = RepPair(tgoal);
|
qt = RepPair(tgoal);
|
||||||
@ -151,6 +155,7 @@ void close();
|
|||||||
/// query variables.
|
/// query variables.
|
||||||
void cut();
|
void cut();
|
||||||
Term namedVars() {return names.term(); };
|
Term namedVars() {return names.term(); };
|
||||||
|
YAPPairTerm namedVarTerms() {return names; };
|
||||||
/// query variables, but copied out
|
/// query variables, but copied out
|
||||||
std::vector<Term> namedVarsVector() {
|
std::vector<Term> namedVarsVector() {
|
||||||
return names.listToArray(); };
|
return names.listToArray(); };
|
||||||
@ -180,170 +185,179 @@ public:
|
|||||||
virtual void run(char *s) {}
|
virtual void run(char *s) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void YAP_init_args::YAP_init_args()
|
||||||
|
{
|
||||||
|
Yap_InitDefaults(this, NULL, 0, NULL);
|
||||||
|
} ;
|
||||||
|
|
||||||
/// @brief Setup all arguments to a new engine
|
/// @brief Setup all arguments to a new engine
|
||||||
class X_API YAPEngineArgs {
|
struct X_API YAPEngineArgs: YAP_init_args {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
YAP_init_args init_args;
|
YAPEngineArgs(): yap_boot_params() {
|
||||||
|
#if YAP_PYTHON
|
||||||
|
Embedded = true;
|
||||||
|
python_in_python = Py_IsInitialized();
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
inline void setEmbedded( bool fl )
|
inline void setEmbedded( bool fl )
|
||||||
{
|
{
|
||||||
init_args.Embedded = fl;
|
Embedded = fl;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline bool getEmbedded( )
|
inline bool getEmbedded( )
|
||||||
{
|
{
|
||||||
return init_args.Embedded;
|
return Embedded;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline void setStackSize( bool fl )
|
inline void setStackSize( bool fl )
|
||||||
{
|
{
|
||||||
init_args.StackSize = fl;
|
StackSize = fl;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline bool getStackSize( )
|
inline bool getStackSize( )
|
||||||
{
|
{
|
||||||
return init_args.StackSize;
|
return StackSize;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline void setTrailSize( bool fl )
|
inline void setTrailSize( bool fl )
|
||||||
{
|
{
|
||||||
init_args.TrailSize = fl;
|
TrailSize = fl;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline bool getTrailSize( )
|
inline bool getTrailSize( )
|
||||||
{
|
{
|
||||||
return init_args.TrailSize;
|
return TrailSize;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline bool getMStackSize( )
|
inline bool getMStackSize( )
|
||||||
{
|
{
|
||||||
return init_args.StackSize;
|
return StackSize;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline void setMaxTrailSize( bool fl )
|
inline void setMaxTrailSize( bool fl )
|
||||||
{
|
{
|
||||||
init_args.MaxTrailSize = fl;
|
MaxTrailSize = fl;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline bool getMaxTrailSize( )
|
inline bool getMaxTrailSize( )
|
||||||
{
|
{
|
||||||
return init_args.MaxTrailSize;
|
return MaxTrailSize;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline void setYapLibDir( const char * fl )
|
inline void setYapLibDir( const char * fl )
|
||||||
{
|
{
|
||||||
init_args.YapLibDir = (const char *)malloc(strlen(fl)+1);
|
YapLibDir = (const char *)malloc(strlen(fl)+1);
|
||||||
strcpy((char *)init_args.YapLibDir, fl);
|
strcpy((char *)YapLibDir, fl);
|
||||||
};
|
};
|
||||||
|
|
||||||
inline const char * getYapLibDir( )
|
inline const char * getYapLibDir( )
|
||||||
{
|
{
|
||||||
return init_args.YapLibDir;
|
return YapLibDir;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline void setYapShareDir( const char * fl )
|
inline void setYapShareDir( const char * fl )
|
||||||
{
|
{
|
||||||
init_args.YapShareDir = (const char *)malloc(strlen(fl)+1);
|
YapShareDir = (const char *)malloc(strlen(fl)+1);
|
||||||
strcpy((char *)init_args.YapShareDir, fl);
|
strcpy((char *)YapShareDir, fl);
|
||||||
};
|
};
|
||||||
|
|
||||||
inline const char * getYapShareDir( )
|
inline const char * getYapShareDir( )
|
||||||
{
|
{
|
||||||
return init_args.YapShareDir;
|
return YapShareDir;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline void setSavedState( const char * fl )
|
inline void setSavedState( const char * fl )
|
||||||
{
|
{
|
||||||
init_args.SavedState = (const char *)malloc(strlen(fl)+1);
|
SavedState = (const char *)malloc(strlen(fl)+1);
|
||||||
strcpy((char *)init_args.SavedState, fl);
|
strcpy((char *)SavedState, fl);
|
||||||
};
|
};
|
||||||
|
|
||||||
inline const char * getSavedState( )
|
inline const char * getSavedState( )
|
||||||
{
|
{
|
||||||
return init_args.SavedState;
|
return SavedState;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline void setYapPrologBootFile( const char * fl )
|
inline void setYapPrologBootFile( const char * fl )
|
||||||
{
|
{
|
||||||
init_args.YapPrologBootFile = (const char *)malloc(strlen(fl)+1);
|
YapPrologBootFile = (const char *)malloc(strlen(fl)+1);
|
||||||
strcpy((char *)init_args.YapPrologBootFile, fl);
|
strcpy((char *)YapPrologBootFile, fl);
|
||||||
};
|
};
|
||||||
|
|
||||||
inline const char * getYapPrologBootFile( )
|
inline const char * getYapPrologBootFile( )
|
||||||
{
|
{
|
||||||
return init_args.YapPrologBootFile;
|
return YapPrologBootFile;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline void setYapPrologGoal( const char * fl )
|
inline void setYapPrologGoal( const char * fl )
|
||||||
{
|
{
|
||||||
init_args.YapPrologGoal = fl;
|
YapPrologGoal = fl;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline const char * getYapPrologGoal( )
|
inline const char * getYapPrologGoal( )
|
||||||
{
|
{
|
||||||
return init_args.YapPrologGoal;
|
return YapPrologGoal;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline void setYapPrologTopLevelGoal( const char * fl )
|
inline void setYapPrologTopLevelGoal( const char * fl )
|
||||||
{
|
{
|
||||||
init_args.YapPrologTopLevelGoal = fl;
|
YapPrologTopLevelGoal = fl;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline const char * getYapPrologTopLevelGoal( )
|
inline const char * getYapPrologTopLevelGoal( )
|
||||||
{
|
{
|
||||||
return init_args.YapPrologTopLevelGoal;
|
return YapPrologTopLevelGoal;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline void setHaltAfterConsult( bool fl )
|
inline void setHaltAfterConsult( bool fl )
|
||||||
{
|
{
|
||||||
init_args.HaltAfterConsult = fl;
|
HaltAfterConsult = fl;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline bool getHaltAfterConsult( )
|
inline bool getHaltAfterConsult( )
|
||||||
{
|
{
|
||||||
return init_args.HaltAfterConsult;
|
return HaltAfterConsult;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline void setFastBoot( bool fl )
|
inline void setFastBoot( bool fl )
|
||||||
{
|
{
|
||||||
init_args.FastBoot = fl;
|
FastBoot = fl;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline bool getFastBoot( )
|
inline bool getFastBoot( )
|
||||||
{
|
{
|
||||||
return init_args.FastBoot;
|
return FastBoot;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if __ANDROID__
|
||||||
|
//> export ResoourceManager
|
||||||
|
inline void setAssetManager( AAssetManager *mgr )
|
||||||
|
{
|
||||||
|
assetManager = mgr;
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
inline void setArgc( int fl )
|
inline void setArgc( int fl )
|
||||||
{
|
{
|
||||||
init_args.Argc = fl;
|
Argc = fl;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline int getArgc( )
|
inline int getArgc( )
|
||||||
{
|
{
|
||||||
return init_args.Argc;
|
return Argc;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline void setArgv( char ** fl )
|
inline void setArgv( char ** fl )
|
||||||
{
|
{
|
||||||
init_args.Argv = fl;
|
Argv = fl;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline char ** getArgv( )
|
inline char ** getArgv( )
|
||||||
{
|
{
|
||||||
return init_args.Argv;
|
return Argv;
|
||||||
};
|
};
|
||||||
|
|
||||||
YAPEngineArgs() {
|
|
||||||
Yap_InitDefaults(&init_args, NULL, 0, NULL);
|
|
||||||
#if YAP_PYTHON
|
|
||||||
init_args.Embedded = true;
|
|
||||||
python_in_python = Py_IsInitialized();
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -368,7 +382,7 @@ private:
|
|||||||
YAPEngine(YAPEngineArgs *cargs)
|
YAPEngine(YAPEngineArgs *cargs)
|
||||||
{
|
{
|
||||||
engine_args = cargs;
|
engine_args = cargs;
|
||||||
//doInit(cargs->init_args.boot_file_type);
|
//doInit(cargs->boot_file_type);
|
||||||
doInit(YAP_QLY);
|
doInit(YAP_QLY);
|
||||||
}; /// construct a new engine, including aaccess to callbacks
|
}; /// construct a new engine, including aaccess to callbacks
|
||||||
/// construct a new engine using argc/argv list of arguments
|
/// construct a new engine using argc/argv list of arguments
|
||||||
|
18
CXX/yapt.hh
18
CXX/yapt.hh
@ -112,7 +112,18 @@ public:
|
|||||||
inline Term term() {
|
inline Term term() {
|
||||||
return gt();
|
return gt();
|
||||||
} /// from YAPTerm to Term (internal YAP representation)
|
} /// from YAPTerm to Term (internal YAP representation)
|
||||||
inline void bind(Term b) { LOCAL_HandleBase[t] = b; }
|
YAPTerm arg(int i) {
|
||||||
|
BACKUP_MACHINE_REGS();
|
||||||
|
Term t0 = gt();
|
||||||
|
YAPTerm tf;
|
||||||
|
if (!IsApplTerm(t0) && !IsPairTerm(t))
|
||||||
|
return (Term)0;
|
||||||
|
tf = YAPTerm(ArgOfTerm(i, t0) );
|
||||||
|
RECOVER_MACHINE_REGS();
|
||||||
|
return tf;
|
||||||
|
};
|
||||||
|
|
||||||
|
inline void bind(Term b) { LOCAL_HandleBase[t] = b; }
|
||||||
inline void bind(YAPTerm *b) { LOCAL_HandleBase[t] = b->term(); }
|
inline void bind(YAPTerm *b) { LOCAL_HandleBase[t] = b->term(); }
|
||||||
/// from YAPTerm to Term (internal YAP representation)
|
/// from YAPTerm to Term (internal YAP representation)
|
||||||
/// fetch a sub-term
|
/// fetch a sub-term
|
||||||
@ -324,7 +335,7 @@ public:
|
|||||||
RECOVER_MACHINE_REGS();
|
RECOVER_MACHINE_REGS();
|
||||||
return tf;
|
return tf;
|
||||||
};
|
};
|
||||||
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
|
||||||
virtual bool isFloat() { return false; } /// type check for floating-point
|
virtual bool isFloat() { return false; } /// type check for floating-point
|
||||||
@ -354,6 +365,9 @@ public:
|
|||||||
YAPPairTerm();
|
YAPPairTerm();
|
||||||
Term getHead() { return (HeadOfTerm(gt())); }
|
Term getHead() { return (HeadOfTerm(gt())); }
|
||||||
Term getTail() { return (TailOfTerm(gt())); }
|
Term getTail() { return (TailOfTerm(gt())); }
|
||||||
|
YAPTerm car() { return YAPTerm(HeadOfTerm(gt())); }
|
||||||
|
bool nil() { return gt() == TermNil; }
|
||||||
|
YAPPairTerm cdr() { return YAPPairTerm(TailOfTerm(gt())); }
|
||||||
std::vector<Term> listToArray() {
|
std::vector<Term> listToArray() {
|
||||||
Term *tailp;
|
Term *tailp;
|
||||||
Term t1 = gt();
|
Term t1 = gt();
|
||||||
|
37
H/YapText.h
37
H/YapText.h
@ -67,7 +67,7 @@ extern int pop_text_stack__(int lvl USES_REGS);
|
|||||||
(/*fprintf(stderr, "v %*c %s:%s:%d\n", AllocLevel(), ' ', __FILE__, \
|
(/*fprintf(stderr, "v %*c %s:%s:%d\n", AllocLevel(), ' ', __FILE__, \
|
||||||
__FUNCTION__, __LINE__),*/ \
|
__FUNCTION__, __LINE__),*/ \
|
||||||
pop_output_text_stack__(lvl,p))
|
pop_output_text_stack__(lvl,p))
|
||||||
extern void *pop_output_text_stack__(int lvl, void *ox USES_REGS);
|
extern void *pop_output_text_stack__(int lvl, const void *ox USES_REGS);
|
||||||
|
|
||||||
/****************** character definition table **************************/
|
/****************** character definition table **************************/
|
||||||
|
|
||||||
@ -1433,6 +1433,38 @@ static inline void Yap_OverwriteUTF8BufferToLowCase(void *buf USES_REGS) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function to convert a generic text term (string, atom, list of codes, list
|
||||||
|
of<
|
||||||
|
atoms) into a buff
|
||||||
|
er.
|
||||||
|
*
|
||||||
|
* @param t the term
|
||||||
|
* @param buf the buffer, if NULL a buffer is malloced, and the user should
|
||||||
|
reclai it
|
||||||
|
* @param len buffer size
|
||||||
|
* @param enc encoding (UTF-8 is strongly recommended)
|
||||||
|
*
|
||||||
|
* @return the buffer, or NULL in case of failure. If so, Yap_Error may be
|
||||||
|
called.
|
||||||
|
*
|
||||||
|
* notice that it must be called from a push memory.
|
||||||
|
*/
|
||||||
|
static inline const char *Yap_TextTermToText(Term t0 USES_REGS) {
|
||||||
|
seq_tv_t inp, out;
|
||||||
|
|
||||||
|
inp.val.t = t0;
|
||||||
|
inp.type = YAP_STRING_ATOM | YAP_STRING_STRING | YAP_STRING_CODES |
|
||||||
|
YAP_STRING_ATOMS_CODES | YAP_STRING_MALLOC;
|
||||||
|
out.val.uc = NULL;
|
||||||
|
out.type = YAP_STRING_CHARS;
|
||||||
|
out.enc = ENC_ISO_UTF8;
|
||||||
|
|
||||||
|
if (!Yap_CVT_Text(&inp, &out PASS_REGS))
|
||||||
|
return NULL;
|
||||||
|
return out.val.c0;
|
||||||
|
}
|
||||||
|
|
||||||
static inline const unsigned char *Yap_TextToUTF8Buffer(Term t0 USES_REGS) {
|
static inline const unsigned char *Yap_TextToUTF8Buffer(Term t0 USES_REGS) {
|
||||||
seq_tv_t inp, out;
|
seq_tv_t inp, out;
|
||||||
|
|
||||||
@ -1444,7 +1476,7 @@ static inline const unsigned char *Yap_TextToUTF8Buffer(Term t0 USES_REGS) {
|
|||||||
out.enc = ENC_ISO_UTF8;
|
out.enc = ENC_ISO_UTF8;
|
||||||
|
|
||||||
if (!Yap_CVT_Text(&inp, &out PASS_REGS))
|
if (!Yap_CVT_Text(&inp, &out PASS_REGS))
|
||||||
return 0L;
|
return NULL;
|
||||||
return out.val.uc0;
|
return out.val.uc0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1642,5 +1674,4 @@ static inline Term Yap_SubtractTailString(Term t1, Term th USES_REGS) {
|
|||||||
|
|
||||||
#endif // ≈YAP_TEXT_H
|
#endif // ≈YAP_TEXT_H
|
||||||
|
|
||||||
extern const char *Yap_TextTermToText(Term t USES_REGS);
|
|
||||||
extern Term Yap_MkTextTerm(const char *s, int guide USES_REGS);
|
extern Term Yap_MkTextTerm(const char *s, int guide USES_REGS);
|
||||||
|
@ -306,7 +306,6 @@ extern void Yap_CloseReadline(void);
|
|||||||
extern bool Yap_InitReadline(Term t);
|
extern bool Yap_InitReadline(Term t);
|
||||||
extern void Yap_InitItDeepenPreds(void);
|
extern void Yap_InitItDeepenPreds(void);
|
||||||
extern struct AliasDescS *Yap_InitStandardAliases(void);
|
extern struct AliasDescS *Yap_InitStandardAliases(void);
|
||||||
extern struct vfs *Yap_InitAssetManager(void);
|
|
||||||
|
|
||||||
/* load_foreign.c */
|
/* load_foreign.c */
|
||||||
extern void Yap_InitLoadForeign(void);
|
extern void Yap_InitLoadForeign(void);
|
||||||
@ -436,6 +435,8 @@ extern const char *Yap_AbsoluteFileInBuffer(const char *spec, char *outp, size_t
|
|||||||
extern const char *Yap_findFile(const char *isource, const char *idef,
|
extern const char *Yap_findFile(const char *isource, const char *idef,
|
||||||
const char *root, char *result, bool access,
|
const char *root, char *result, bool access,
|
||||||
YAP_file_type_t ftype, bool expand_root, bool in_lib);
|
YAP_file_type_t ftype, bool expand_root, bool in_lib);
|
||||||
|
extern bool ChDir(const char *path);
|
||||||
|
|
||||||
/* threads.c */
|
/* threads.c */
|
||||||
extern void Yap_InitThreadPreds(void);
|
extern void Yap_InitThreadPreds(void);
|
||||||
extern void Yap_InitFirstWorkerThreadHandle(void);
|
extern void Yap_InitFirstWorkerThreadHandle(void);
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
/* consulting files */
|
/* consulting files */
|
||||||
|
|
||||||
typedef union CONSULT_OBJ {
|
typedef union CONSULT_OBJ {
|
||||||
const unsigned char *filename;
|
const unsigned char *f_name;
|
||||||
int mode;
|
int mode;
|
||||||
Prop p;
|
Prop p;
|
||||||
UInt c;
|
UInt c;
|
||||||
|
@ -10,12 +10,27 @@
|
|||||||
|
|
||||||
|
|
||||||
if (ANDROID)
|
if (ANDROID)
|
||||||
set( GMP_ROOT ${CMAKE_SOURCE_DIR}/../gmp/${ANDROID_ABI} )
|
|
||||||
set (GMP_INCLUDE_DIRS ${GMP_ROOT})
|
set( GMP_LOC ${CMAKE_SOURCE_DIR}/../gmp/${ANDROID_ABI} )
|
||||||
set (GMP_LIBRARIES ${GMP_ROOT}/libgmp.so)
|
if (EXISTS ${GMP_LOC} )
|
||||||
set (GMP_FOUND ON)
|
message("Looking good for ${GMP_LOC}")
|
||||||
set (GMP_LIBRARIES_DIR ${GMP_ROOT})
|
set(GMP_INCLUDE_DIRS ${GMP_LOC} CACHE PATH "include search path")
|
||||||
elif(MSVC)
|
set(GMP_LIBRARIES ${GMP_LOC}/libgmp.so CACHE FILEPATH "include search path")
|
||||||
|
set(GMP_LIBRARIES_DIR ${GMP_LOC} CACHE PATH "include search path")
|
||||||
|
else()
|
||||||
|
message("Bad call: ${GMP_LOC} does not exist")
|
||||||
|
endif()
|
||||||
|
find_path(GMP_INCLUDE_DIRS
|
||||||
|
NAMES gmp.h
|
||||||
|
HINTS ${GMP_LOC}
|
||||||
|
NO_SYSTEM_ENVIRONMENT_PATH)
|
||||||
|
find_library(GMP_LIBRARIES NAMES gmp
|
||||||
|
PATHS
|
||||||
|
${GMP_ROOT}
|
||||||
|
NO_SYSTEM_ENVIRONMENT_PATH)
|
||||||
|
|
||||||
|
|
||||||
|
elseif(MSVC)
|
||||||
find_library(GMP_LIBRARIES NAMES mpir mpird
|
find_library(GMP_LIBRARIES NAMES mpir mpird
|
||||||
PATHS
|
PATHS
|
||||||
$ENV{GMP_ROOT}
|
$ENV{GMP_ROOT}
|
||||||
@ -84,6 +99,7 @@ else()
|
|||||||
${GMP_LIBRARIES_DIR}/../include
|
${GMP_LIBRARIES_DIR}/../include
|
||||||
${GMP_LIBRARIES_DIR}
|
${GMP_LIBRARIES_DIR}
|
||||||
)
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
get_filename_component(GMP_LIBRARIES_DIR "${GMP_LIBRARIES}" PATH CACHE)
|
get_filename_component(GMP_LIBRARIES_DIR "${GMP_LIBRARIES}" PATH CACHE)
|
||||||
|
|
||||||
@ -101,5 +117,4 @@ endif()
|
|||||||
|
|
||||||
mark_as_advanced(GMP_LIBRARIES GMP_LIBRARIES_DIR GMP_INCLUDE_DIRS)
|
mark_as_advanced(GMP_LIBRARIES GMP_LIBRARIES_DIR GMP_INCLUDE_DIRS)
|
||||||
|
|
||||||
endif()
|
|
||||||
|
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
|
|
||||||
#include <encoding.h>
|
#include <encoding.h>
|
||||||
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
dev_t st_dev; /* ID of device containing file */
|
dev_t st_dev; /* ID of device containing file */
|
||||||
mode_t st_mode; /* Mode of file (see below) */
|
mode_t st_mode; /* Mode of file (see below) */
|
||||||
@ -77,10 +78,9 @@ typedef struct vfs {
|
|||||||
/// a way to identify a file in this VFS: two special cases, prefix and suffix
|
/// a way to identify a file in this VFS: two special cases, prefix and suffix
|
||||||
const char *prefix;
|
const char *prefix;
|
||||||
const char *suffix;
|
const char *suffix;
|
||||||
bool (*id)(struct vfs *me, const char *s);
|
bool (*chDir)(struct vfs *me, const char *s);
|
||||||
/** operations */
|
/** operations */
|
||||||
void *(*open)(const char *s,
|
void *(*open)(int sno, const char *fname, const char *io_mode); /// open an object
|
||||||
const char *io_mode); /// open an object
|
|
||||||
/// in this space, usual w,r,a,b flags plus B (store in a buffer)
|
/// in this space, usual w,r,a,b flags plus B (store in a buffer)
|
||||||
bool (*close)(int sno); /// close the object
|
bool (*close)(int sno); /// close the object
|
||||||
int (*get_char)(int sno); /// get an octet to the stream
|
int (*get_char)(int sno); /// get an octet to the stream
|
||||||
@ -88,15 +88,15 @@ typedef struct vfs {
|
|||||||
void (*flush)(int sno); /// flush a stream
|
void (*flush)(int sno); /// flush a stream
|
||||||
int64_t (*seek)(int sno, int64_t offset,
|
int64_t (*seek)(int sno, int64_t offset,
|
||||||
int whence); /// jump around the stream
|
int whence); /// jump around the stream
|
||||||
void *(*opendir)(const char *s); /// open a directory object, if one exists
|
void *(*opendir)(struct vfs *,const char *s); /// open a directory object, if one exists
|
||||||
const char *(*nextdir)(void *d); /// walk to the next entry in a directory object
|
const char *(*nextdir)(void *d); /// walk to the next entry in a directory object
|
||||||
void (*closedir)(void *d);
|
bool (*closedir)(void *d);
|
||||||
; /// close access a directory object
|
; /// close access a directory object
|
||||||
bool (*stat)(const char *s,
|
bool (*stat)(const char *s,
|
||||||
vfs_stat *); /// obtain size, age, permissions of a file.
|
vfs_stat *); /// obtain size, age, permissions of a file.
|
||||||
bool (*isdir)(const char *s); /// verify whether is directory.
|
bool (*isdir)(struct vfs *,const char *s); /// verify whether is directory.
|
||||||
bool (*exists)(const char *s); /// verify whether a file exists.
|
bool (*exists)(struct vfs *, const char *s); /// verify whether a file exists.
|
||||||
bool (*chdir)(const char *s); /// set working directory (may be virtual).
|
bool (*chdir)(struct vfs *,const char *s); /// set working directory (may be virtual).
|
||||||
encoding_t enc; /// default file encoded.
|
encoding_t enc; /// default file encoded.
|
||||||
YAP_Term (*parsers)(int sno); // a set of parsers that can read the
|
YAP_Term (*parsers)(int sno); // a set of parsers that can read the
|
||||||
// stream and generate a YAP_Term
|
// stream and generate a YAP_Term
|
||||||
@ -121,12 +121,15 @@ static inline VFS_t *vfs_owner(const char *fname) {
|
|||||||
size_t sz0 = strlen(fname), sz;
|
size_t sz0 = strlen(fname), sz;
|
||||||
|
|
||||||
while (me) {
|
while (me) {
|
||||||
if ((me->vflags & VFS_HAS_PREFIX) && strstr(fname, me->prefix) == fname)
|
bool p = true;
|
||||||
|
if ((me->vflags & VFS_HAS_PREFIX) && p) {
|
||||||
|
const char *r = fname, *s = me->prefix;
|
||||||
|
while (*s && p) p = *s++ == *r++;
|
||||||
|
if (p && r > fname+1)
|
||||||
return me;
|
return me;
|
||||||
|
}
|
||||||
if (me->vflags & VFS_HAS_SUFFIX && (sz = strlen(me->suffix)) && (d = (sz0 - sz)) >= 0 &&
|
if (me->vflags & VFS_HAS_SUFFIX && (sz = strlen(me->suffix)) && (d = (sz0 - sz)) >= 0 &&
|
||||||
strcmp(fname + d, me->suffix) == 0)
|
strcmp(fname + d, me->suffix) == 0) {
|
||||||
return me;
|
|
||||||
if (me->vflags & VFS_HAS_FUNCTION && (me->id(me, fname))) {
|
|
||||||
return me;
|
return me;
|
||||||
}
|
}
|
||||||
me = me->next;
|
me = me->next;
|
||||||
|
@ -189,6 +189,11 @@ typedef encoding_t YAP_encoding_t;
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if __ANDROID__
|
||||||
|
#include <android/asset_manager.h>
|
||||||
|
#include <android/native_activity.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef struct YAP_thread_attr_struct {
|
typedef struct YAP_thread_attr_struct {
|
||||||
size_t ssize;
|
size_t ssize;
|
||||||
size_t tsize;
|
size_t tsize;
|
||||||
@ -322,6 +327,10 @@ typedef struct yap_boot_params {
|
|||||||
int QuietMode;
|
int QuietMode;
|
||||||
//> 0, maintain default, > 0 use fd-1, < 0 close
|
//> 0, maintain default, > 0 use fd-1, < 0 close
|
||||||
int inp, out, err;
|
int inp, out, err;
|
||||||
|
#if __ANDROID__
|
||||||
|
//> android asset support
|
||||||
|
AAssetManager *assetManager;
|
||||||
|
#endif
|
||||||
/* support nf's ypp preprocessor code */
|
/* support nf's ypp preprocessor code */
|
||||||
#define YAP_MAX_YPP_DEFS 100
|
#define YAP_MAX_YPP_DEFS 100
|
||||||
char *def_var[YAP_MAX_YPP_DEFS];
|
char *def_var[YAP_MAX_YPP_DEFS];
|
||||||
@ -342,11 +351,14 @@ typedef struct yap_boot_params {
|
|||||||
int ErrorNo;
|
int ErrorNo;
|
||||||
//> errorstring
|
//> errorstring
|
||||||
char *ErrorCause;
|
char *ErrorCause;
|
||||||
|
#ifdef __cplusplus
|
||||||
|
void YAP_init_args();
|
||||||
|
#endif
|
||||||
} YAP_init_args;
|
} YAP_init_args;
|
||||||
|
|
||||||
#ifdef YAP_H
|
#ifdef YAP_H
|
||||||
YAP_file_type_t Yap_InitDefaults(YAP_init_args *init_args, char saved_state[],
|
YAP_file_type_t Yap_InitDefaults(YAP_init_args *init_args, char saved_state[],
|
||||||
int Argc, char *Argv[]);
|
int Argc, char **Argv);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* this should be opaque to the user */
|
/* this should be opaque to the user */
|
||||||
|
@ -76,8 +76,8 @@ MY_add_subdirectory(ytest)
|
|||||||
|
|
||||||
add_to_group( LIBRARY_PL pl_library)
|
add_to_group( LIBRARY_PL pl_library)
|
||||||
|
|
||||||
if (0)
|
install(FILES ${LIBRARY_PL} DESTINATION ${libpl})
|
||||||
file(COPY ${LIBRARY_PL} DESTINATION ${libpl})
|
|
||||||
else()
|
if (ANDROID)
|
||||||
install(FILES ${LIBRARY_PL} DESTINATION ${libpl})
|
file( INSTALL ${LIBRARY_PL} DESTINATION ${libpl} )
|
||||||
endif()
|
endif()
|
161
os/assets.c
161
os/assets.c
@ -33,107 +33,93 @@ static char SccsId[] = "%W% %G%";
|
|||||||
// for native asset manager
|
// for native asset manager
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#if __ANDROID__0
|
|
||||||
|
|
||||||
|
#if __ANDROID__
|
||||||
|
#include <android/asset_manager.h>
|
||||||
|
#include <android/native_activity.h>
|
||||||
|
|
||||||
static AAssetManager * getMgr(struct vfs *me)
|
AAssetManager * Yap_assetManager;
|
||||||
|
|
||||||
|
jboolean Java_pt_up_yap_app_YAPDroid_setAssetManager(JNIEnv* env, jclass clazz, jobject assetManager)
|
||||||
{
|
{
|
||||||
return me->priv[0].mgr;
|
Yap_assetManager = AAssetManager_fromJava(env, assetManager);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void *
|
||||||
void
|
open_asset__( int sno, const char *fname, const char *io_mode)
|
||||||
Java_pt_up_yap_app_YAPDroid_load(JNIEnv *env,
|
|
||||||
jobject assetManager) {
|
|
||||||
|
|
||||||
AAssetManager *mgr = AAssetManager_fromJava(env, assetManager);
|
|
||||||
if (mgr == NULL) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
VFS_t *me = GLOBAL_VFS;
|
|
||||||
while ( strcmp(me->name, "/assets") == 0)
|
|
||||||
me = me->next;
|
|
||||||
me->priv[0].mgr = mgr;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool
|
|
||||||
open_asset(struct vfs *me, struct stream_desc *st, const char *fname, const char
|
|
||||||
*io_mode)
|
|
||||||
{
|
{
|
||||||
AAssetManager *mgr;
|
|
||||||
int mode;
|
int mode;
|
||||||
const void *buf;
|
const void *buf;
|
||||||
|
VFS_t *me = GLOBAL_Stream[sno].vfs;
|
||||||
if (strstr(fname,"/assets") == fname) {
|
if (strstr(fname,"/assets") == fname) {
|
||||||
// we're in
|
// we're in
|
||||||
mgr = getMgr(me);
|
if ( Yap_assetManager == NULL) {
|
||||||
if (mgr == NULL) {
|
PlIOError(PERMISSION_ERROR_OPEN_SOURCE_SINK, TermNil,
|
||||||
return PlIOError(PERMISSION_ERROR_OPEN_SOURCE_SINK, TermNil,
|
"asset manager",
|
||||||
"asset manager",
|
fname);
|
||||||
fname);
|
return NULL;
|
||||||
}
|
|
||||||
if (strchr(io_mode, 'w') || strchr(io_mode, 'a')) {
|
|
||||||
return PlIOError(PERMISSION_ERROR_OPEN_SOURCE_SINK, TermNil,
|
|
||||||
"%s: no writing but flags are %s",
|
|
||||||
fname, io_mode);
|
|
||||||
}
|
|
||||||
if (strchr(io_mode, 'B'))
|
|
||||||
mode = AASSET_MODE_BUFFER;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mode = AASSET_MODE_UNKNOWN;
|
|
||||||
}
|
}
|
||||||
AAsset *a = AAssetManager_open(mgr , fname, mode);
|
if (strchr(io_mode, 'w') || strchr(io_mode, 'a')) {
|
||||||
// try not to use it as an asset
|
PlIOError(PERMISSION_ERROR_OPEN_SOURCE_SINK, TermNil,
|
||||||
off64_t sz = AAsset_getLength64(a), sz0 = 0;
|
"%s: no writing but flags are %s",
|
||||||
int fd;
|
fname, io_mode);
|
||||||
if ((fd = AAsset_openFileDescriptor64(a, &sz0, &sz)) >= 0) {
|
return NULL;
|
||||||
// can use it as red-only file
|
}
|
||||||
st->file = fdopen( fd, "r");
|
if (strchr(io_mode, 'B'))
|
||||||
|
mode = AASSET_MODE_BUFFER;
|
||||||
|
else {
|
||||||
|
mode = AASSET_MODE_UNKNOWN;
|
||||||
|
}
|
||||||
|
AAsset *a = AAssetManager_open( Yap_assetManager, fname, mode);
|
||||||
|
// try not to use it as an asset
|
||||||
|
off64_t sz = AAsset_getLength64(a), sz0 = 0;
|
||||||
|
int fd;
|
||||||
|
StreamDesc *st = GLOBAL_Stream+sno;
|
||||||
|
if ((fd = AAsset_openFileDescriptor64(a, &sz0, &sz)) >= 0) {
|
||||||
|
// can use it as red-only file
|
||||||
|
st->file = fdopen(fd, "r");
|
||||||
|
st->vfs = me;
|
||||||
|
st->vfs_handle = a;
|
||||||
|
return a;
|
||||||
|
} else if ((buf = AAsset_getBuffer(a))) {
|
||||||
|
// copy to memory
|
||||||
|
bool rc = Yap_set_stream_to_buf(st, buf, sz);
|
||||||
|
if (rc) AAsset_close(a);
|
||||||
|
return st;
|
||||||
|
}
|
||||||
|
// should be done, but if not
|
||||||
|
GLOBAL_Stream[sno].vfs_handle= a;
|
||||||
st->vfs = me;
|
st->vfs = me;
|
||||||
st->vfs_handle = a;
|
return a;
|
||||||
return true;
|
|
||||||
} else if ((buf = AAsset_getBuffer(a)) ) {
|
|
||||||
// copy to memory
|
|
||||||
bool rc = Yap_set_stream_to_buf(st, buf, sz);
|
|
||||||
AAsset_close(a);
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
// should be done, but if not
|
|
||||||
st->vfs_handle = a;
|
|
||||||
st->vfs = me;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (me->next) {
|
|
||||||
return me->next->open(me->next, st, fname, io_mode);
|
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
close_asset(struct stream_desc *st)
|
close_asset(int sno)
|
||||||
{
|
{
|
||||||
AAsset_close(st->vfs_handle);
|
AAsset_close(GLOBAL_Stream[sno].vfs_handle);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t seek64(struct stream_desc *st, int64_t offset, int whence)
|
static int64_t seek64(int sno, int64_t offset, int whence)
|
||||||
{
|
{
|
||||||
return AAsset_seek64(st->vfs_handle, offset, whence);
|
return AAsset_seek64(GLOBAL_Stream[sno].vfs_handle, offset, whence);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int getc_asset(struct stream_desc *st)
|
static int getc_asset(int sno)
|
||||||
{
|
{
|
||||||
int ch;
|
int ch;
|
||||||
if ( AAsset_read (st->vfs_handle, &ch, 1) )
|
if ( AAsset_read (GLOBAL_Stream[sno].vfs_handle, &ch, 1) )
|
||||||
return ch;
|
return ch;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void *opendir_a(struct vfs *me, const char *dirName)
|
static void *opendir_a( VFS_t *me, const char *dirName)
|
||||||
{
|
{
|
||||||
return (void *)AAssetManager_openDir (getMgr(me), dirName);
|
return (void *)AAssetManager_openDir (Yap_assetManager, dirName);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *readdir_a(void *dirHandle)
|
static const char *readdir_a(void *dirHandle)
|
||||||
@ -148,10 +134,10 @@ static bool closedir_a(void *dirHandle)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static bool stat_a(struct vfs *me, const char *fname, vfs_stat *out)
|
static bool stat_a(VFS_t *me, const char *fname, vfs_stat *out)
|
||||||
{
|
{
|
||||||
struct stat64 bf;
|
struct stat bf;
|
||||||
if (stat64( "/assets", &bf)) {
|
if (stat( "/assets", &bf)) {
|
||||||
|
|
||||||
out->st_dev = bf.st_dev;
|
out->st_dev = bf.st_dev;
|
||||||
out->st_uid = bf.st_uid;
|
out->st_uid = bf.st_uid;
|
||||||
@ -161,8 +147,7 @@ static bool stat_a(struct vfs *me, const char *fname, vfs_stat *out)
|
|||||||
memcpy(&out->st_ctimespec, (const void *)&out->st_ctimespec, sizeof(struct timespec));
|
memcpy(&out->st_ctimespec, (const void *)&out->st_ctimespec, sizeof(struct timespec));
|
||||||
memcpy(&out->st_birthtimespec, (const void *)&out->st_birthtimespec, sizeof(struct timespec));
|
memcpy(&out->st_birthtimespec, (const void *)&out->st_birthtimespec, sizeof(struct timespec));
|
||||||
}
|
}
|
||||||
AAssetManager *mgr = getMgr(me);
|
AAsset *a = AAssetManager_open( Yap_assetManager , fname, AASSET_MODE_UNKNOWN);
|
||||||
AAsset *a = AAssetManager_open(mgr , fname, AASSET_MODE_UNKNOWN);
|
|
||||||
// try not to use it as an asset
|
// try not to use it as an asset
|
||||||
out->st_size = AAsset_getLength64(a);
|
out->st_size = AAsset_getLength64(a);
|
||||||
AAsset_close(a);
|
AAsset_close(a);
|
||||||
@ -171,11 +156,11 @@ static bool stat_a(struct vfs *me, const char *fname, vfs_stat *out)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
bool is_dir_a(struct vfs *me, const char *dirName)
|
bool is_dir_a( VFS_t *me,const char *dirName)
|
||||||
{
|
{
|
||||||
bool rc;
|
bool rc;
|
||||||
// try not to use it as an asset
|
// try not to use it as an asset
|
||||||
AAssetDir *d = AAssetManager_openDir (getMgr(me), dirName);
|
AAssetDir *d = AAssetManager_openDir ( Yap_assetManager, dirName);
|
||||||
if (d == NULL)
|
if (d == NULL)
|
||||||
return false;
|
return false;
|
||||||
rc = (AAssetDir_getNextFileName(d) != NULL);
|
rc = (AAssetDir_getNextFileName(d) != NULL);
|
||||||
@ -184,22 +169,22 @@ bool is_dir_a(struct vfs *me, const char *dirName)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
bool exists_a(struct vfs *me, const char *dirName)
|
VFS_t *exists_a(VFS_t *me, const char *dirName)
|
||||||
{
|
{
|
||||||
// try not to use it as an asset
|
// try not to use it as an asset
|
||||||
AAsset *d = AAssetManager_open (getMgr(me), dirName, AASSET_MODE_UNKNOWN);
|
AAsset *d = AAssetManager_open ( Yap_assetManager, dirName, AASSET_MODE_UNKNOWN);
|
||||||
if (d == NULL)
|
if (d == NULL)
|
||||||
return false;
|
return NULL;
|
||||||
AAsset_close(d);
|
AAsset_close(d);
|
||||||
return true;
|
return me;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static bool set_cwd (struct vfs *me, const char *dirName) {
|
static bool set_cwd (VFS_t *me, const char *dirName) {
|
||||||
|
|
||||||
chdir("/assets");
|
chdir("/assets");
|
||||||
if (me->virtual_cwd)
|
if (me->virtual_cwd)
|
||||||
free(me->virtual_cwd);
|
free((void*)(me->virtual_cwd));
|
||||||
me->virtual_cwd = malloc( sizeof(dirName) + 1 );
|
me->virtual_cwd = malloc( sizeof(dirName) + 1 );
|
||||||
return me!= NULL;
|
return me!= NULL;
|
||||||
}
|
}
|
||||||
@ -207,23 +192,23 @@ static bool set_cwd (struct vfs *me, const char *dirName) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* create a new alias arg for stream sno */
|
|
||||||
VFS_t *
|
VFS_t *
|
||||||
Yap_InitAssetManager(void)
|
Yap_InitAssetManager( void )
|
||||||
{
|
{
|
||||||
|
|
||||||
#if __ANDROID__O
|
#if __ANDROID__
|
||||||
VFS_t *me;
|
VFS_t *me;
|
||||||
|
|
||||||
/* init standard VFS */
|
/* init standard VFS */
|
||||||
me = (VFS_t *)Yap_AllocCodeSpace(sizeof(struct vfs));
|
me = (VFS_t *)Yap_AllocCodeSpace(sizeof(struct vfs));
|
||||||
me->name = "/assets";
|
me->name = "/assets";
|
||||||
me->vflags = VFS_CAN_EXEC|VFS_CAN_SEEK|VFS_HAS_PREFIX; /// the main flags describing the operation of the Fs.
|
me->vflags = VFS_CAN_EXEC|VFS_CAN_SEEK|VFS_HAS_PREFIX; /// the main flags describing the operation of the Fs.
|
||||||
me->prefix = "/assets";
|
me->prefix = "/assets";
|
||||||
/** operations */
|
/** operations */
|
||||||
me->open = open_asset; /// open an object in this space
|
me->open = open_asset__; /// open an object in this space
|
||||||
me->close= close_asset; /// close the object
|
me->close= close_asset; /// close the object
|
||||||
me->get_char = getc_asset; /// get an octet to the stream
|
me->get_char = getc_asset; /// get an octet to the stream
|
||||||
me->putc = NULL; /// output an octet to the stream
|
me->put_char = NULL; /// output an octet to the stream
|
||||||
me->seek = seek64; /// jump around the stream
|
me->seek = seek64; /// jump around the stream
|
||||||
me->opendir = opendir_a; /// open a directory object, if one exists
|
me->opendir = opendir_a; /// open a directory object, if one exists
|
||||||
me->nextdir = readdir_a; /// open a directory object, if one exists
|
me->nextdir = readdir_a; /// open a directory object, if one exists
|
||||||
|
@ -865,7 +865,7 @@ as those for `put` (see 6.11).
|
|||||||
static Int skip_1(USES_REGS1) { /* 'skip'(N) */
|
static Int skip_1(USES_REGS1) { /* 'skip'(N) */
|
||||||
Int n;
|
Int n;
|
||||||
Term t1;
|
Term t1;
|
||||||
int sno;
|
int sno = LOCAL_c_output_stream;
|
||||||
int ch;
|
int ch;
|
||||||
|
|
||||||
if (IsVarTerm(t1 = Deref(ARG1))) {
|
if (IsVarTerm(t1 = Deref(ARG1))) {
|
||||||
|
@ -25,6 +25,7 @@ static char SccsId[] = "%W% %G%";
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "sysbits.h"
|
#include "sysbits.h"
|
||||||
|
#include "yapio.h"
|
||||||
|
|
||||||
#if _MSC_VER || defined(__MINGW32__)
|
#if _MSC_VER || defined(__MINGW32__)
|
||||||
#define SYSTEM_STAT _stat
|
#define SYSTEM_STAT _stat
|
||||||
|
94
os/iopreds.c
94
os/iopreds.c
@ -246,20 +246,18 @@ static void unix_upd_stream_info(StreamDesc *s) {
|
|||||||
|
|
||||||
void Yap_DefaultStreamOps(StreamDesc *st) {
|
void Yap_DefaultStreamOps(StreamDesc *st) {
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
if (st->vfs) {
|
|
||||||
st->stream_wputc = st->vfs->put_char;
|
|
||||||
st->stream_wgetc = st->vfs->get_char;
|
|
||||||
st->stream_putc = st->vfs->put_char;
|
|
||||||
st->stream_wgetc = st->vfs->get_char;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
st->stream_wputc = put_wchar;
|
st->stream_wputc = put_wchar;
|
||||||
if (st->encoding == ENC_ISO_UTF8)
|
if (st->encoding == ENC_ISO_UTF8)
|
||||||
st->stream_wgetc = get_wchar_UTF8;
|
st->stream_wgetc = get_wchar_UTF8;
|
||||||
else
|
else
|
||||||
st->stream_wgetc = get_wchar;
|
st->stream_wgetc = get_wchar;
|
||||||
st->stream_putc = FilePutc;
|
if (st->vfs) {
|
||||||
st->stream_getc = PlGetc;
|
st->stream_putc = st->vfs->put_char;
|
||||||
|
st->stream_wgetc = st->vfs->get_char;
|
||||||
|
} else {
|
||||||
|
st->stream_putc = FilePutc;
|
||||||
|
st->stream_getc = PlGetc;
|
||||||
|
}
|
||||||
if (st->status & (Promptable_Stream_f)) {
|
if (st->status & (Promptable_Stream_f)) {
|
||||||
Yap_ConsoleOps(st);
|
Yap_ConsoleOps(st);
|
||||||
}
|
}
|
||||||
@ -300,7 +298,7 @@ static void InitStdStream(int sno, SMALLUNSGN flags, FILE *file, VFS_t *vfsp) {
|
|||||||
INIT_LOCK(s->streamlock);
|
INIT_LOCK(s->streamlock);
|
||||||
if (vfsp != NULL) {
|
if (vfsp != NULL) {
|
||||||
s->u.private_data =
|
s->u.private_data =
|
||||||
vfsp->open(vfsp->name, (sno == StdInStream ? "read" : "write"));
|
vfsp->open(sno, vfsp->name, (sno == StdInStream ? "read" : "write"));
|
||||||
if (s->u.private_data == NULL) {
|
if (s->u.private_data == NULL) {
|
||||||
(PlIOError(EXISTENCE_ERROR_SOURCE_SINK, MkIntTerm(sno), "%s",
|
(PlIOError(EXISTENCE_ERROR_SOURCE_SINK, MkIntTerm(sno), "%s",
|
||||||
vfsp->name));
|
vfsp->name));
|
||||||
@ -1312,7 +1310,7 @@ do_open(Term file_name, Term t2,
|
|||||||
}
|
}
|
||||||
struct vfs *vfsp = NULL;
|
struct vfs *vfsp = NULL;
|
||||||
if ((vfsp = vfs_owner(fname)) != NULL) {
|
if ((vfsp = vfs_owner(fname)) != NULL) {
|
||||||
st->u.private_data = vfsp->open(fname, io_mode);
|
st->u.private_data = vfsp->open(sno, fname, io_mode);
|
||||||
fd = NULL;
|
fd = NULL;
|
||||||
if (st->u.private_data == NULL)
|
if (st->u.private_data == NULL)
|
||||||
return (PlIOError(EXISTENCE_ERROR_SOURCE_SINK, file_name, "%s", fname));
|
return (PlIOError(EXISTENCE_ERROR_SOURCE_SINK, file_name, "%s", fname));
|
||||||
@ -1522,7 +1520,56 @@ static Int p_open_null_stream(USES_REGS1) {
|
|||||||
return (Yap_unify(ARG1, t));
|
return (Yap_unify(ARG1, t));
|
||||||
}
|
}
|
||||||
|
|
||||||
int Yap_OpenStream(FILE *fd, char *name, Term file_name, int flags) {
|
int Yap_OpenStream(const char *fname, const char * io_mode) {
|
||||||
|
CACHE_REGS
|
||||||
|
int sno;
|
||||||
|
StreamDesc *st;
|
||||||
|
Atom at;
|
||||||
|
struct vfs *vfsp;
|
||||||
|
FILE *fd;
|
||||||
|
int flags;
|
||||||
|
|
||||||
|
sno = GetFreeStreamD();
|
||||||
|
if (sno < 0)
|
||||||
|
return (PlIOError(RESOURCE_ERROR_MAX_STREAMS, MkAtomTerm(Yap_LookupAtom(fname)),
|
||||||
|
"new stream not available for opening"));
|
||||||
|
st = GLOBAL_Stream+sno;
|
||||||
|
vfsp = NULL;
|
||||||
|
if ((vfsp = vfs_owner(fname)) != NULL) {
|
||||||
|
st->u.private_data = vfsp->open(sno, fname, io_mode);
|
||||||
|
UNLOCK(st->streamlock);
|
||||||
|
fd = NULL;
|
||||||
|
if (st->u.private_data == NULL)
|
||||||
|
return (PlIOError(EXISTENCE_ERROR_SOURCE_SINK, MkAtomTerm(Yap_LookupAtom(fname)), "%s", fname));
|
||||||
|
st->vfs = vfsp;
|
||||||
|
} else if ((fd = fopen(fname, io_mode)) == NULL ||
|
||||||
|
(!strchr(io_mode, 'b') && binary_file(fname))) {
|
||||||
|
UNLOCK(st->streamlock);
|
||||||
|
if (errno == ENOENT && !strchr(io_mode, 'r')) {
|
||||||
|
return PlIOError(EXISTENCE_ERROR_SOURCE_SINK, MkAtomTerm(Yap_LookupAtom(fname)), "%s: %s", fname,
|
||||||
|
strerror(errno));
|
||||||
|
} else {
|
||||||
|
return PlIOError(PERMISSION_ERROR_OPEN_SOURCE_SINK, MkAtomTerm(Yap_LookupAtom(fname)), "%s: %s",
|
||||||
|
fname, strerror(errno));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (strchr(io_mode, 'r')) {
|
||||||
|
if (strchr(io_mode, 'a')) {
|
||||||
|
at = AtomAppend;
|
||||||
|
flags = Append_Stream_f | Output_Stream_f;
|
||||||
|
} else {
|
||||||
|
at = AtomWrite;
|
||||||
|
flags = Output_Stream_f;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
at = AtomRead;
|
||||||
|
flags = Input_Stream_f;
|
||||||
|
}
|
||||||
|
Yap_initStream(sno, fd, fname, fname, LOCAL_encoding, flags, at, NULL);
|
||||||
|
return sno;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Yap_FileStream(FILE *fd, char *name, Term file_name, int flags) {
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
int sno;
|
int sno;
|
||||||
Atom at;
|
Atom at;
|
||||||
@ -1542,6 +1589,26 @@ int Yap_OpenStream(FILE *fd, char *name, Term file_name, int flags) {
|
|||||||
return sno;
|
return sno;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int FileStream(FILE* fd, char *name, Term file_name, int flags )
|
||||||
|
{
|
||||||
|
int sno;
|
||||||
|
Atom at;
|
||||||
|
|
||||||
|
sno = GetFreeStreamD();
|
||||||
|
if (sno < 0)
|
||||||
|
return (PlIOError(RESOURCE_ERROR_MAX_STREAMS, name,
|
||||||
|
"new stream not available for opening"));
|
||||||
|
if (flags & Output_Stream_f) {
|
||||||
|
if (flags & Append_Stream_f)
|
||||||
|
at = AtomAppend;
|
||||||
|
else
|
||||||
|
at = AtomWrite;
|
||||||
|
} else
|
||||||
|
at = AtomRead;
|
||||||
|
Yap_initStream(sno, fd, name, file_name, LOCAL_encoding, flags, at, NULL);
|
||||||
|
return sno;
|
||||||
|
}
|
||||||
|
|
||||||
#define CheckStream(arg, kind, msg) \
|
#define CheckStream(arg, kind, msg) \
|
||||||
CheckStream__(__FILE__, __FUNCTION__, __LINE__, arg, kind, msg)
|
CheckStream__(__FILE__, __FUNCTION__, __LINE__, arg, kind, msg)
|
||||||
|
|
||||||
@ -1869,8 +1936,7 @@ static Int get_abs_file_parameter(USES_REGS1) {
|
|||||||
|
|
||||||
void Yap_InitPlIO(struct yap_boot_params *argi) {
|
void Yap_InitPlIO(struct yap_boot_params *argi) {
|
||||||
Int i;
|
Int i;
|
||||||
|
if (argi->inp > 0)
|
||||||
if (argi->inp > 0)
|
|
||||||
Yap_stdin = fdopen(argi->inp - 1, "r");
|
Yap_stdin = fdopen(argi->inp - 1, "r");
|
||||||
else if (argi->inp)
|
else if (argi->inp)
|
||||||
Yap_stdin = NULL;
|
Yap_stdin = NULL;
|
||||||
|
@ -283,8 +283,4 @@ static inline void freeBuffer(const void *ptr) {
|
|||||||
free((void *)ptr);
|
free((void *)ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** VFS handling */
|
|
||||||
|
|
||||||
VFS_t *Yap_InitAssetManager(void);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
9
os/mem.c
9
os/mem.c
@ -24,7 +24,7 @@ static char SccsId[] = "%W% %G%";
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "sysbits.h"
|
#include "sysbits.h"
|
||||||
|
#include "YapStreams.h"
|
||||||
|
|
||||||
#if !HAVE_FMEMOPEN || !defined(HAVE_FMEMOPEN)
|
#if !HAVE_FMEMOPEN || !defined(HAVE_FMEMOPEN)
|
||||||
|
|
||||||
@ -180,7 +180,7 @@ static int MemPutc(int sno, int ch) {
|
|||||||
return ((int)ch);
|
return ((int)ch);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Yap_set_stream_to_buf(StreamDesc *st, const char *buf, size_t nchars) {
|
bool Yap_set_stream_to_buf(StreamDesc *st, const char *buf, size_t nchars USES_REGS) {
|
||||||
FILE *f;
|
FILE *f;
|
||||||
stream_flags_t flags;
|
stream_flags_t flags;
|
||||||
|
|
||||||
@ -241,14 +241,15 @@ open_mem_read_stream(USES_REGS1) /* $open_mem_read_stream(+List,-Stream) */
|
|||||||
{
|
{
|
||||||
Term t, ti;
|
Term t, ti;
|
||||||
int sno;
|
int sno;
|
||||||
char buf0[YAP_FILENAME_MAX + 1];
|
int i = push_text_stack();
|
||||||
const char *buf;
|
const char *buf;
|
||||||
|
|
||||||
ti = Deref(ARG1);
|
ti = Deref(ARG1);
|
||||||
buf = Yap_TextTermToText(ti, buf0, 0, LOCAL_encoding);
|
buf = Yap_TextTermToText(ti PASS_REGS);
|
||||||
if (!buf) {
|
if (!buf) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
buf = pop_output_text_stack(i, buf);
|
||||||
sno = Yap_open_buf_read_stream(buf, strlen(buf) + 1, &LOCAL_encoding,
|
sno = Yap_open_buf_read_stream(buf, strlen(buf) + 1, &LOCAL_encoding,
|
||||||
MEM_BUF_MALLOC);
|
MEM_BUF_MALLOC);
|
||||||
t = Yap_MkStream(sno);
|
t = Yap_MkStream(sno);
|
||||||
|
24
os/sysbits.c
24
os/sysbits.c
@ -79,7 +79,7 @@ static bool is_directory(const char *FileName) {
|
|||||||
|
|
||||||
VFS_t *vfs;
|
VFS_t *vfs;
|
||||||
if ((vfs = vfs_owner(FileName))) {
|
if ((vfs = vfs_owner(FileName))) {
|
||||||
return vfs->isdir(FileName);
|
return vfs->isdir(vfs,FileName);
|
||||||
}
|
}
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
DWORD dwAtts = GetFileAttributes(FileName);
|
DWORD dwAtts = GetFileAttributes(FileName);
|
||||||
@ -102,10 +102,9 @@ static bool is_directory(const char *FileName) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool Yap_Exists(const char *f) {
|
bool Yap_Exists(const char *f) {
|
||||||
VFS_t *vfs;
|
VFS_t *vfs;
|
||||||
|
if ((vfs = vfs_owner(f))) {
|
||||||
if ((vfs = vfs_owner(f))) {
|
return vfs->exists(vfs,f) != NULL;
|
||||||
return vfs->exists(f);
|
|
||||||
}
|
}
|
||||||
#if _WIN32
|
#if _WIN32
|
||||||
if (_access(f, 0) == 0)
|
if (_access(f, 0) == 0)
|
||||||
@ -169,9 +168,10 @@ bool Yap_IsAbsolutePath(const char *p0) {
|
|||||||
static const char *PlExpandVars(const char *source, const char *root,
|
static const char *PlExpandVars(const char *source, const char *root,
|
||||||
char *result) {
|
char *result) {
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
|
int lvl = push_text_stack();
|
||||||
const char *src = source;
|
const char *src = source;
|
||||||
if (!result)
|
if (!result)
|
||||||
result = BaseMalloc(YAP_FILENAME_MAX + 1);
|
result = Malloc(YAP_FILENAME_MAX + 1);
|
||||||
|
|
||||||
if (strlen(source) >= YAP_FILENAME_MAX) {
|
if (strlen(source) >= YAP_FILENAME_MAX) {
|
||||||
Yap_Error(SYSTEM_ERROR_OPERATING_SYSTEM, TermNil,
|
Yap_Error(SYSTEM_ERROR_OPERATING_SYSTEM, TermNil,
|
||||||
@ -194,6 +194,7 @@ static const char *PlExpandVars(const char *source, const char *root,
|
|||||||
if (s != NULL)
|
if (s != NULL)
|
||||||
strncpy(result, s, YAP_FILENAME_MAX);
|
strncpy(result, s, YAP_FILENAME_MAX);
|
||||||
strcat(result, src);
|
strcat(result, src);
|
||||||
|
result = pop_output_text_stack(lvl, result);
|
||||||
return result;
|
return result;
|
||||||
} else {
|
} else {
|
||||||
#if HAVE_GETPWNAM
|
#if HAVE_GETPWNAM
|
||||||
@ -208,6 +209,7 @@ static const char *PlExpandVars(const char *source, const char *root,
|
|||||||
FileError(SYSTEM_ERROR_OPERATING_SYSTEM,
|
FileError(SYSTEM_ERROR_OPERATING_SYSTEM,
|
||||||
MkAtomTerm(Yap_LookupAtom(source)),
|
MkAtomTerm(Yap_LookupAtom(source)),
|
||||||
"User %s does not exist in %s", result, source);
|
"User %s does not exist in %s", result, source);
|
||||||
|
pop_text_stack(lvl);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
strncpy(result, user_passwd->pw_dir, YAP_FILENAME_MAX);
|
strncpy(result, user_passwd->pw_dir, YAP_FILENAME_MAX);
|
||||||
@ -219,6 +221,7 @@ static const char *PlExpandVars(const char *source, const char *root,
|
|||||||
return NULL;
|
return NULL;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
result = pop_output_text_stack(lvl, result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
// do VARIABLE expansion
|
// do VARIABLE expansion
|
||||||
@ -260,6 +263,7 @@ static const char *PlExpandVars(const char *source, const char *root,
|
|||||||
if (tocp > YAP_FILENAME_MAX) {
|
if (tocp > YAP_FILENAME_MAX) {
|
||||||
Yap_Error(SYSTEM_ERROR_OPERATING_SYSTEM, MkStringTerm(src),
|
Yap_Error(SYSTEM_ERROR_OPERATING_SYSTEM, MkStringTerm(src),
|
||||||
"path too long");
|
"path too long");
|
||||||
|
pop_text_stack(lvl);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (root && !Yap_IsAbsolutePath(source)) {
|
if (root && !Yap_IsAbsolutePath(source)) {
|
||||||
@ -271,6 +275,7 @@ static const char *PlExpandVars(const char *source, const char *root,
|
|||||||
strncpy(result, source, strlen(src) + 1);
|
strncpy(result, source, strlen(src) + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
result = pop_output_text_stack(lvl, result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -341,14 +346,14 @@ static char *PrologPath(const char *Y, char *X) { return (char *)Y; }
|
|||||||
#define HAVE_REALPATH 1
|
#define HAVE_REALPATH 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static bool ChDir(const char *path) {
|
bool ChDir(const char *path) {
|
||||||
bool rc = false;
|
bool rc = false;
|
||||||
char qp[FILENAME_MAX + 1];
|
char qp[FILENAME_MAX + 1];
|
||||||
const char *qpath = Yap_AbsoluteFile(path, qp, true);
|
const char *qpath = Yap_AbsoluteFile(path, qp, true);
|
||||||
|
|
||||||
VFS_t *v;
|
VFS_t *v;
|
||||||
if ((v = vfs_owner(path))) {
|
if ((v = vfs_owner(path))) {
|
||||||
return v->chdir(path);
|
return v->chdir(v, path);
|
||||||
}
|
}
|
||||||
#if _WIN32
|
#if _WIN32
|
||||||
rc = true;
|
rc = true;
|
||||||
@ -1242,7 +1247,8 @@ const char *Yap_findFile(const char *isource, const char *idef,
|
|||||||
if (ftype == YAP_PL) {
|
if (ftype == YAP_PL) {
|
||||||
root = YAP_SHAREDIR;
|
root = YAP_SHAREDIR;
|
||||||
} else if (ftype == YAP_BOOT_PL) {
|
} else if (ftype == YAP_BOOT_PL) {
|
||||||
root = YAP_SHAREDIR;
|
root = malloc(YAP_FILENAME_MAX+1);
|
||||||
|
strcpy(root, YAP_SHAREDIR);
|
||||||
strcat(root,"/pl");
|
strcat(root,"/pl");
|
||||||
} else {
|
} else {
|
||||||
root = YAP_LIBDIR;
|
root = YAP_LIBDIR;
|
||||||
|
19
os/yapio.h
19
os/yapio.h
@ -22,11 +22,14 @@
|
|||||||
#undef HAVE_LIBREADLINE
|
#undef HAVE_LIBREADLINE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "YapStreams.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
|
|
||||||
#include "YapIOConfig.h"
|
#include "YapIOConfig.h"
|
||||||
#include <Yatom.h>
|
#include <Yatom.h>
|
||||||
|
#include <VFS.h>
|
||||||
|
|
||||||
#ifndef _PL_WRITE_
|
#ifndef _PL_WRITE_
|
||||||
|
|
||||||
@ -45,6 +48,13 @@ typedef struct AliasDescS {
|
|||||||
/* parser stack, used to be AuxSp, now is ASP */
|
/* parser stack, used to be AuxSp, now is ASP */
|
||||||
#define ParserAuxSp LOCAL_ScannerStack
|
#define ParserAuxSp LOCAL_ScannerStack
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return a new VFS that will support /assets
|
||||||
|
*/
|
||||||
|
|
||||||
|
extern VFS_t *Yap_InitAssetManager( void );
|
||||||
|
|
||||||
/* routines in parser.c */
|
/* routines in parser.c */
|
||||||
extern VarEntry *Yap_LookupVar(const char *);
|
extern VarEntry *Yap_LookupVar(const char *);
|
||||||
extern Term Yap_VarNames(VarEntry *, Term);
|
extern Term Yap_VarNames(VarEntry *, Term);
|
||||||
@ -76,7 +86,8 @@ extern int Yap_PlGetWchar(void);
|
|||||||
extern int Yap_PlFGetchar(void);
|
extern int Yap_PlFGetchar(void);
|
||||||
extern int Yap_GetCharForSIGINT(void);
|
extern int Yap_GetCharForSIGINT(void);
|
||||||
extern Int Yap_StreamToFileNo(Term);
|
extern Int Yap_StreamToFileNo(Term);
|
||||||
extern int Yap_OpenStream(FILE *, char *, Term, int);
|
extern int Yap_OpenStream(const char*, const char *);
|
||||||
|
extern int Yap_FileStream(FILE*, char *, Term, int);
|
||||||
extern char *Yap_TermToString(Term t, encoding_t encoding, int flags);
|
extern char *Yap_TermToString(Term t, encoding_t encoding, int flags);
|
||||||
extern char *Yap_HandleToString(yhandle_t l, size_t sz, size_t *length,
|
extern char *Yap_HandleToString(yhandle_t l, size_t sz, size_t *length,
|
||||||
encoding_t *encoding, int flags);
|
encoding_t *encoding, int flags);
|
||||||
@ -108,8 +119,6 @@ extern Term Yap_StringToNumberTerm(const char *s, encoding_t *encp,
|
|||||||
extern int Yap_FormatFloat(Float f, char **s, size_t sz);
|
extern int Yap_FormatFloat(Float f, char **s, size_t sz);
|
||||||
extern int Yap_open_buf_read_stream(const char *buf, size_t nchars,
|
extern int Yap_open_buf_read_stream(const char *buf, size_t nchars,
|
||||||
encoding_t *encp, memBufSource src);
|
encoding_t *encp, memBufSource src);
|
||||||
extern bool Yap_set_stream_to_buf(struct stream_desc *st, const char *buf,
|
|
||||||
encoding_t enc, size_t nchars);
|
|
||||||
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 Yap_BufferToTermWithPrioBindings(const unsigned char *s,
|
||||||
@ -151,4 +160,8 @@ INLINE_ONLY inline EXTERN Term MkCharTerm(Int c) {
|
|||||||
extern uint64_t Yap_StartOfWTimes;
|
extern uint64_t Yap_StartOfWTimes;
|
||||||
|
|
||||||
extern bool Yap_HandleSIGINT(void);
|
extern bool Yap_HandleSIGINT(void);
|
||||||
|
|
||||||
|
|
||||||
|
extern bool Yap_set_stream_to_buf(StreamDesc *st, const char *buf, size_t nchars USES_REGS);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
]).
|
]).
|
||||||
|
|
||||||
|
|
||||||
:- catch(load_foreign_files([horus], [], init_predicates), _, patch_things_up)
|
:- catch(load_foreign_files([libhorus], [], init_predicates), _, patch_things_up)
|
||||||
-> true ; warning.
|
-> true ; warning.
|
||||||
|
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ if (CMAKE_MAJOR_VERSION GREATER 2)
|
|||||||
#set_property(TARGET horus PROPERTY CXX_STANDARD 11)
|
#set_property(TARGET horus PROPERTY CXX_STANDARD 11)
|
||||||
#set_property(TARGET horus PROPERTY CXX_STANDARD_REQUIRED ON)
|
#set_property(TARGET horus PROPERTY CXX_STANDARD_REQUIRED ON)
|
||||||
|
|
||||||
set_target_properties (horus PROPERTIES PREFIX "" CXX_STANDARD 11 CXX_STANDARD_REQUIRED ON)
|
set_target_properties (horus PROPERTIES CXX_STANDARD 11 CXX_STANDARD_REQUIRED ON)
|
||||||
|
|
||||||
add_executable (HorusCli HorusCli.cpp)
|
add_executable (HorusCli HorusCli.cpp)
|
||||||
|
|
||||||
|
@ -46,9 +46,7 @@ IF (CUDD_FOUND)
|
|||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set_target_properties (cudd PROPERTIES PREFIX "")
|
add_subdirectory(simplecudd)
|
||||||
|
|
||||||
add_subdirectory(simplecudd)
|
|
||||||
add_subdirectory(simplecudd_lfi)
|
add_subdirectory(simplecudd_lfi)
|
||||||
set(YAP_SYSTEM_OPTIONS "cudd " ${YAP_SYSTEM_OPTIONS} PARENT_SCOPE)
|
set(YAP_SYSTEM_OPTIONS "cudd " ${YAP_SYSTEM_OPTIONS} PARENT_SCOPE)
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ The following predicates construct a BDD:
|
|||||||
tell_warning :-
|
tell_warning :-
|
||||||
print_message(warning,functionality(cudd)).
|
print_message(warning,functionality(cudd)).
|
||||||
|
|
||||||
:- catch(load_foreign_files([cudd], [], init_cudd),_,fail) -> true ; tell_warning.
|
:- catch(load_foreign_files([libcudd], [], init_cudd),_,fail) -> true ; tell_warning.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@pred bdd_new(? _Exp_, - _BddHandle_)
|
@pred bdd_new(? _Exp_, - _BddHandle_)
|
||||||
|
@ -19,7 +19,7 @@ for the relative license.
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
FILE *open_file (char *filename, const char *mode);
|
FILE *open_file (char *file_name, const char *mode);
|
||||||
static YAP_Bool compute_prob(void);
|
static YAP_Bool compute_prob(void);
|
||||||
|
|
||||||
variables createVars(YAP_Term t,DdManager * mgr, int create_dot, char inames[1000][20])
|
variables createVars(YAP_Term t,DdManager * mgr, int create_dot, char inames[1000][20])
|
||||||
@ -214,14 +214,14 @@ void init_my_predicates()
|
|||||||
YAP_UserCPredicate("compute_prob",compute_prob,4);
|
YAP_UserCPredicate("compute_prob",compute_prob,4);
|
||||||
}
|
}
|
||||||
|
|
||||||
FILE * open_file(char *filename, const char *mode)
|
FILE * open_file(char *file_name, const char *mode)
|
||||||
/* opens a file */
|
/* opens a file */
|
||||||
{
|
{
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
|
|
||||||
if ((fp = fopen(filename, mode)) == NULL)
|
if ((fp = fopen(file_name, mode)) == NULL)
|
||||||
{
|
{
|
||||||
perror(filename);
|
perror(file_name);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
return fp;
|
return fp;
|
||||||
|
@ -11,18 +11,19 @@ set(MYDDAS_YPP
|
|||||||
set(MYDDAS_DRIVERS
|
set(MYDDAS_DRIVERS
|
||||||
"myddas_driver.ypp"
|
"myddas_driver.ypp"
|
||||||
)
|
)
|
||||||
message("libpl ${libpl}")
|
|
||||||
if (0)
|
|
||||||
set (PREFIX ${libpl} )
|
if (ANDROID)
|
||||||
|
set (MYDDAS_PREFIX ${libpl} )
|
||||||
else()
|
else()
|
||||||
set (PREFIX ${CMAKE_CURRENT_BINARY_DIR} )
|
set (MYDDAS_PREFIX ${CMAKE_CURRENT_BINARY_DIR} )
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
get_property(MYDDAS_FLAGS GLOBAL PROPERTY COMPILE_DEFINITIONS)
|
get_property(MYDDAS_FLAGS GLOBAL PROPERTY COMPILE_DEFINITIONS)
|
||||||
|
|
||||||
function(cpp_compile output filename)
|
function(cpp_compile output filename)
|
||||||
get_filename_component(base ${filename} NAME_WE)
|
get_filename_component(base ${filename} NAME_WE)
|
||||||
set(base_abs ${PREFIX}/${base})
|
set(base_abs ${MYDDAS_PREFIX}/${base})
|
||||||
set(outfile ${base_abs}.yap)
|
set(outfile ${base_abs}.yap)
|
||||||
set(${output} ${${output}} ${outfile} PARENT_SCOPE)
|
set(${output} ${${output}} ${outfile} PARENT_SCOPE)
|
||||||
IF (MSVC)
|
IF (MSVC)
|
||||||
@ -40,17 +41,13 @@ function(cpp_compile output filename)
|
|||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
if (ANDROID)
|
if (ANDROID)
|
||||||
set (MYDDAS_PL_OUTDIR ${YAP_APP_DIR}/src/generated/assets/Yap} )
|
set (MYDDAS_PL_OUTDIR ${YAP_APP_DIR}/src/generated/assets/Yap )
|
||||||
else()
|
else()
|
||||||
set (MYDDAS_PL_OUTDIR ${CMAKE_CURRENT_BINARY_DIR} )
|
set (MYDDAS_PL_OUTDIR ${CMAKE_CURRENT_BINARY_DIR} )
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
function(cpp_driver output dbms filename)
|
function(cpp_driver output dbms filename)
|
||||||
if (0)
|
set(outfile ${MYDDAS_PL_OUTDIR}/myddas_${dbms}.yap)
|
||||||
set(outfile ${MYDDAS_PL_OUTDIR}/myddas_${dbms}.yap)
|
|
||||||
else()
|
|
||||||
set(outfile ${MYDDAS_PL_OUTDIR}/myddas_${dbms}.yap)
|
|
||||||
endif()
|
|
||||||
set(${output} ${${output}} ${outfile} PARENT_SCOPE)
|
set(${output} ${${output}} ${outfile} PARENT_SCOPE)
|
||||||
IF (MSVC)
|
IF (MSVC)
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
|
@ -18,21 +18,21 @@
|
|||||||
#undef sqlite3
|
#undef sqlite3
|
||||||
#define DBMS(x) sqlite3_##x
|
#define DBMS(x) sqlite3_##x
|
||||||
#define c_DBMS(x) c_sqlite3_##x
|
#define c_DBMS(x) c_sqlite3_##x
|
||||||
#define NAME() 'Yapsqlite3'
|
#define NAME() 'libYapsqlite3'
|
||||||
#define MODULE() myddas_sqlite3
|
#define MODULE() myddas_sqlite3
|
||||||
#define INIT() init_sqlite3
|
#define INIT() init_sqlite3
|
||||||
#elif defined( odbc )
|
#elif defined( odbc )
|
||||||
#undef odbc
|
#undef odbc
|
||||||
#define DBMS(x) odbc_##x
|
#define DBMS(x) odbc_##x
|
||||||
#define c_DBMS(x) c_odbc_##x
|
#define c_DBMS(x) c_odbc_##x
|
||||||
#define NAME() 'Yapodbc'
|
#define NAME() 'libYapodbc'
|
||||||
#define MODULE() myddas_odbc
|
#define MODULE() myddas_odbc
|
||||||
#define INIT() init_odbc
|
#define INIT() init_odbc
|
||||||
#elif defined( postgres )
|
#elif defined( postgres )
|
||||||
#undef postgres
|
#undef postgres
|
||||||
#define DBMS(x) postgres_##x
|
#define DBMS(x) postgres_##x
|
||||||
#define c_DBMS(x) c_postgres_##x
|
#define c_DBMS(x) c_postgres_##x
|
||||||
#define NAME() 'Yappostgres'
|
#define NAME() 'libYappostgres'
|
||||||
#define MODULE() myddas_postgres
|
#define MODULE() myddas_postgres
|
||||||
#define INIT() init_odbc
|
#define INIT() init_odbc
|
||||||
#endif
|
#endif
|
||||||
|
@ -60,7 +60,6 @@ set_target_properties(Yapsqlite3
|
|||||||
# RPATH ${libdir} VERSION ${LIBYAPTAI_FULL_VERSION}
|
# RPATH ${libdir} VERSION ${LIBYAPTAI_FULL_VERSION}
|
||||||
# SOVERSION ${LIBYAPTAI_MAJOR_VERSION}.${LIBYAPTAI_MINOR_VERSION}
|
# SOVERSION ${LIBYAPTAI_MAJOR_VERSION}.${LIBYAPTAI_MINOR_VERSION}
|
||||||
POSITION_INDEPENDENT_CODE TRUE
|
POSITION_INDEPENDENT_CODE TRUE
|
||||||
PREFIX ""
|
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(Yapsqlite3 libYap)
|
target_link_libraries(Yapsqlite3 libYap)
|
||||||
|
@ -285,346 +285,6 @@ class YAPEngine;
|
|||||||
|
|
||||||
#if THREADS
|
#if THREADS
|
||||||
#define Yap_regp regcache
|
#define Yap_regp regcache
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// we cannot consult YapInterface.h, that conflicts with what we
|
// we cannot consult YapInterface.h, that conflicts with what we
|
||||||
@ -661,6 +321,7 @@ class YAPEngine;
|
|||||||
//%feature("novaluewrapper") vector<YAPTerm>;
|
//%feature("novaluewrapper") vector<YAPTerm>;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
%init %{
|
%init %{
|
||||||
|
@ -58,7 +58,12 @@ set(PL_BOOT_SOURCES
|
|||||||
|
|
||||||
add_to_group(PL_BOOT_SOURCES pl_boot_library)
|
add_to_group(PL_BOOT_SOURCES pl_boot_library)
|
||||||
|
|
||||||
if (CMAKE_CROSSCOMPILING)
|
if (ANDROID)
|
||||||
|
add_custom_target(STARTUP
|
||||||
|
DEPENDS ${PL_BOOT_SOURCES}
|
||||||
|
)
|
||||||
|
file (INSTALL ${PL_BOOT_SOURCES} DESTINATION ${libpl}/pl)
|
||||||
|
elseif(CMAKE_CROSSCOMPILING)
|
||||||
add_custom_target(STARTUP ALL SOURCES
|
add_custom_target(STARTUP ALL SOURCES
|
||||||
DEPENDS ${PL_BOOT_SOURCES}
|
DEPENDS ${PL_BOOT_SOURCES}
|
||||||
)
|
)
|
||||||
@ -67,7 +72,6 @@ else ()
|
|||||||
DEPENDS ${CMAKE_TOP_BINARY_DIR}/${YAP_STARTUP}
|
DEPENDS ${CMAKE_TOP_BINARY_DIR}/${YAP_STARTUP}
|
||||||
)
|
)
|
||||||
add_custom_command(OUTPUT ${CMAKE_TOP_BINARY_DIR}/${YAP_STARTUP}
|
add_custom_command(OUTPUT ${CMAKE_TOP_BINARY_DIR}/${YAP_STARTUP}
|
||||||
COMMAND ldd yap
|
|
||||||
COMMAND ./yap -B
|
COMMAND ./yap -B
|
||||||
VERBATIM
|
VERBATIM
|
||||||
WORKING_DIRECTORY ${CMAKE_TOP_BINARY_DIR}
|
WORKING_DIRECTORY ${CMAKE_TOP_BINARY_DIR}
|
||||||
@ -79,7 +83,7 @@ install(FILES ${CMAKE_TOP_BINARY_DIR}/${YAP_STARTUP}
|
|||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
install(FILES ${PL_SOURCES}
|
install(FILES ${PL_SOURCES}
|
||||||
DESTINATION ${libpl}/pl
|
DESTINATION ${libpl}/pl
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user