android
This commit is contained in:
parent
f6596da27d
commit
05733938c1
38
CXX/yapi.cpp
38
CXX/yapi.cpp
@ -255,19 +255,31 @@ YAPApplTerm::YAPApplTerm(YAPFunctor f, YAPTerm ts[]) {
|
|||||||
RECOVER_H();
|
RECOVER_H();
|
||||||
}
|
}
|
||||||
|
|
||||||
YAPApplTerm::YAPApplTerm(std::string f, std::vector<Term> ts) {
|
YAPApplTerm::YAPApplTerm(const std::string f, std::vector<Term> ts) {
|
||||||
BACKUP_H();
|
BACKUP_H();
|
||||||
arity_t arity = ts.size();
|
arity_t arity = ts.size();
|
||||||
Functor ff = Yap_MkFunctor(Yap_LookupAtom(f.c_str()), arity);
|
Functor ff = Yap_MkFunctor(Yap_LookupAtom(f.c_str()), arity);
|
||||||
Term o = Yap_MkNewApplTerm(ff, arity);
|
Term o = Yap_MkNewApplTerm(ff, arity);
|
||||||
Term *tt = RepAppl(o) + 1;
|
Term *tt = RepAppl(o) + 1;
|
||||||
for (arity_t i = 0; i < arity; i++)
|
for (arity_t i = 0; i < arity; i++)
|
||||||
tt[i] = ts[i];
|
tt[i] = ts[i];
|
||||||
mk(o);
|
mk(o);
|
||||||
RECOVER_H();
|
RECOVER_H();
|
||||||
}
|
}
|
||||||
|
|
||||||
YAPApplTerm::YAPApplTerm(std::string f, YAPTerm a1) {
|
YAPApplTerm::YAPApplTerm(const std::string f, std::vector<YAPTerm> ts) {
|
||||||
|
BACKUP_H();
|
||||||
|
arity_t arity = ts.size();
|
||||||
|
Functor ff = Yap_MkFunctor(Yap_LookupAtom(f.c_str()), arity);
|
||||||
|
Term o = Yap_MkNewApplTerm(ff, arity);
|
||||||
|
Term *tt = RepAppl(o) + 1;
|
||||||
|
for (arity_t i = 0; i < arity; i++)
|
||||||
|
tt[i] = ts[i].term();
|
||||||
|
mk(o);
|
||||||
|
RECOVER_H();
|
||||||
|
}
|
||||||
|
|
||||||
|
YAPApplTerm::YAPApplTerm(const std::string f, YAPTerm a1) {
|
||||||
BACKUP_H();
|
BACKUP_H();
|
||||||
arity_t arity = 1;
|
arity_t arity = 1;
|
||||||
Functor ff = Yap_MkFunctor(Yap_LookupAtom(f.c_str()), arity);
|
Functor ff = Yap_MkFunctor(Yap_LookupAtom(f.c_str()), arity);
|
||||||
@ -278,7 +290,7 @@ YAPApplTerm::YAPApplTerm(std::string f, YAPTerm a1) {
|
|||||||
RECOVER_H();
|
RECOVER_H();
|
||||||
}
|
}
|
||||||
|
|
||||||
YAPApplTerm::YAPApplTerm(std::string f, YAPTerm a1, YAPTerm a2) {
|
YAPApplTerm::YAPApplTerm(const std::string f, YAPTerm a1, YAPTerm a2) {
|
||||||
BACKUP_H();
|
BACKUP_H();
|
||||||
arity_t arity = 2;
|
arity_t arity = 2;
|
||||||
Functor ff = Yap_MkFunctor(Yap_LookupAtom(f.c_str()), arity);
|
Functor ff = Yap_MkFunctor(Yap_LookupAtom(f.c_str()), arity);
|
||||||
@ -290,7 +302,7 @@ YAPApplTerm::YAPApplTerm(std::string f, YAPTerm a1, YAPTerm a2) {
|
|||||||
RECOVER_H();
|
RECOVER_H();
|
||||||
}
|
}
|
||||||
|
|
||||||
YAPApplTerm::YAPApplTerm(std::string f, YAPTerm a1, YAPTerm a2, YAPTerm a3) {
|
YAPApplTerm::YAPApplTerm(const std::string f, YAPTerm a1, YAPTerm a2, YAPTerm a3) {
|
||||||
BACKUP_H();
|
BACKUP_H();
|
||||||
arity_t arity = 3;
|
arity_t arity = 3;
|
||||||
Functor ff = Yap_MkFunctor(Yap_LookupAtom(f.c_str()), arity);
|
Functor ff = Yap_MkFunctor(Yap_LookupAtom(f.c_str()), arity);
|
||||||
@ -303,7 +315,7 @@ YAPApplTerm::YAPApplTerm(std::string f, YAPTerm a1, YAPTerm a2, YAPTerm a3) {
|
|||||||
RECOVER_H();
|
RECOVER_H();
|
||||||
}
|
}
|
||||||
|
|
||||||
YAPApplTerm::YAPApplTerm(std::string f, YAPTerm a1, YAPTerm a2, YAPTerm a3, YAPTerm a4) {
|
YAPApplTerm::YAPApplTerm(const std::string f, YAPTerm a1, YAPTerm a2, YAPTerm a3, YAPTerm a4) {
|
||||||
BACKUP_H();
|
BACKUP_H();
|
||||||
arity_t arity = 4;
|
arity_t arity = 4;
|
||||||
Functor ff = Yap_MkFunctor(Yap_LookupAtom(f.c_str()), arity);
|
Functor ff = Yap_MkFunctor(Yap_LookupAtom(f.c_str()), arity);
|
||||||
|
@ -307,12 +307,17 @@ YAPApplTerm(Functor f, Term ts[]) {
|
|||||||
mk(Yap_MkNewApplTerm(Yap_MkFunctor(Yap_LookupAtom(s.c_str()), arity),
|
mk(Yap_MkNewApplTerm(Yap_MkFunctor(Yap_LookupAtom(s.c_str()), arity),
|
||||||
arity));
|
arity));
|
||||||
};
|
};
|
||||||
YAPApplTerm(const std::string s, std::vector<YAPTerm> ts);
|
YAPApplTerm(const std::string s, std::vector<Term> ts);
|
||||||
|
YAPApplTerm(const std::string s, std::vector<YAPTerm> ts);
|
||||||
YAPApplTerm(YAPFunctor f);
|
YAPApplTerm(YAPFunctor f);
|
||||||
inline Functor functor() { return FunctorOfTerm(gt()); }
|
inline Functor functor() { return FunctorOfTerm(gt()); }
|
||||||
inline YAPFunctor getFunctor() { return YAPFunctor(FunctorOfTerm(gt())); }
|
inline YAPFunctor getFunctor() { return YAPFunctor(FunctorOfTerm(gt())); }
|
||||||
|
YAPApplTerm(const std::string f, YAPTerm a1);
|
||||||
|
YAPApplTerm(const std::string f, YAPTerm a1, YAPTerm a2);
|
||||||
|
YAPApplTerm(const std::string f, YAPTerm a1, YAPTerm a2, YAPTerm a3);
|
||||||
|
YAPApplTerm(const std::string f, YAPTerm a1, YAPTerm a2, YAPTerm a3, YAPTerm a4);
|
||||||
|
|
||||||
Term getArg(arity_t i) {
|
Term getArg(arity_t i) {
|
||||||
BACKUP_MACHINE_REGS();
|
BACKUP_MACHINE_REGS();
|
||||||
Term t0 = gt();
|
Term t0 = gt();
|
||||||
Term tf;
|
Term tf;
|
||||||
|
@ -835,11 +835,6 @@ static parser_state_t initParser(Term opts, FEnv *fe, REnv *re, int inp_stream,
|
|||||||
LOCAL_ErrorMessage = NULL;
|
LOCAL_ErrorMessage = NULL;
|
||||||
fe->old_TR = TR;
|
fe->old_TR = TR;
|
||||||
LOCAL_Error_TYPE = YAP_NO_ERROR;
|
LOCAL_Error_TYPE = YAP_NO_ERROR;
|
||||||
__android_log_print(ANDROID_LOG_INFO, "YAPDroid ", " open %s, %d",
|
|
||||||
CurrentModule == 0
|
|
||||||
? "prolog"
|
|
||||||
: RepAtom(AtomOfTerm(CurrentModule))->StrOfAE,
|
|
||||||
inp_stream);
|
|
||||||
LOCAL_SourceFileName = GLOBAL_Stream[inp_stream].name;
|
LOCAL_SourceFileName = GLOBAL_Stream[inp_stream].name;
|
||||||
LOCAL_eot_before_eof = false;
|
LOCAL_eot_before_eof = false;
|
||||||
fe->tpos = StreamPosition(inp_stream);
|
fe->tpos = StreamPosition(inp_stream);
|
||||||
|
@ -15,12 +15,15 @@
|
|||||||
* *
|
* *
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
#include "Yap.h"
|
#include "Yap.h"
|
||||||
#ifdef USE_MYDDAS
|
|
||||||
|
|
||||||
#include "Yatom.h"
|
#include "Yatom.h"
|
||||||
#include "cut_c.h"
|
|
||||||
#include "myddas.h"
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef USE_MYDDAS
|
||||||
|
|
||||||
|
#include "myddas.h"
|
||||||
|
|
||||||
#ifdef MYDDAS_STATS
|
#ifdef MYDDAS_STATS
|
||||||
#include "myddas_statistics.h"
|
#include "myddas_statistics.h"
|
||||||
#endif
|
#endif
|
||||||
@ -678,6 +681,8 @@ void Yap_MYDDAS_delete_all_myddas_structs(void) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
void init_myddas(void) {
|
void init_myddas(void) {
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
if (myddas_initialised)
|
if (myddas_initialised)
|
||||||
@ -701,9 +706,6 @@ void init_myddas(void) {
|
|||||||
Yap_MYDDAS_delete_all_myddas_structs();
|
Yap_MYDDAS_delete_all_myddas_structs();
|
||||||
#if defined MYDDAS_ODBC
|
#if defined MYDDAS_ODBC
|
||||||
Yap_InitBackMYDDAS_ODBCPreds();
|
Yap_InitBackMYDDAS_ODBCPreds();
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#if defined MYDDAS_ODBC
|
|
||||||
Yap_InitMYDDAS_ODBCPreds();
|
Yap_InitMYDDAS_ODBCPreds();
|
||||||
#endif
|
#endif
|
||||||
#if defined MYDDAS_TOP_LEVEL && \
|
#if defined MYDDAS_TOP_LEVEL && \
|
||||||
@ -711,9 +713,9 @@ void init_myddas(void) {
|
|||||||
Yap_InitMYDDAS_TopLevelPreds();
|
Yap_InitMYDDAS_TopLevelPreds();
|
||||||
#endif
|
#endif
|
||||||
c_db_initialize_myddas(PASS_REGS1);
|
c_db_initialize_myddas(PASS_REGS1);
|
||||||
#ifdef __ANDROiD__
|
#ifdef __ANDROID__
|
||||||
init_sqlite3();
|
init_sqlite3();
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
myddas_initialised = true;
|
myddas_initialised = true;
|
||||||
CurrentModule = cm;
|
CurrentModule = cm;
|
||||||
|
@ -13,12 +13,14 @@ main_ :-
|
|||||||
fail.
|
fail.
|
||||||
main_ .
|
main_ .
|
||||||
|
|
||||||
:- if yap_flag(android,true).
|
:- if( yap_flag(android,true) ).
|
||||||
|
init :-
|
||||||
|
db_open(sqlite3, '/data/user/0/pt.up.yap/files/chinook.db', _, _),
|
||||||
|
!,
|
||||||
|
writeln('chinook has landed').
|
||||||
|
|
||||||
init :-
|
init :-
|
||||||
catch(db_open(sqlite3,'chinook.db',_,_), _, fail),
|
catch(db_open(sqlite3,'chinook.db',_,_), _, fail),
|
||||||
!.
|
|
||||||
init :-
|
|
||||||
db_open(sqlite3, '/data/user/0/pt.up.yap.yapdroid/files/Yap/chinook.db', _, _),
|
|
||||||
% db_open(sqlite3, 'chinook.db', _, _),
|
% db_open(sqlite3, 'chinook.db', _, _),
|
||||||
writeln('chinook has landed').
|
writeln('chinook has landed').
|
||||||
:- else.
|
:- else.
|
||||||
@ -26,7 +28,7 @@ init :-
|
|||||||
db_open(sqlite3, '/data/user/0/pt.up.yap.yapdroid/files/Yap/chinook.db', _, _),
|
db_open(sqlite3, '/data/user/0/pt.up.yap.yapdroid/files/Yap/chinook.db', _, _),
|
||||||
% db_open(sqlite3, 'chinook.db', _, _),
|
% db_open(sqlite3, 'chinook.db', _, _),
|
||||||
writeln('chinook has landed').
|
writeln('chinook has landed').
|
||||||
:-endif
|
:-endif.
|
||||||
|
|
||||||
go :-
|
go :-
|
||||||
writeln(('db_import')),
|
writeln(('db_import')),
|
||||||
|
@ -124,6 +124,19 @@ YAPError = _yap.YAPError
|
|||||||
|
|
||||||
%typecheck(0) YAPTerm { $1 = !PyUnicode_Check($input); }
|
%typecheck(0) YAPTerm { $1 = !PyUnicode_Check($input); }
|
||||||
|
|
||||||
|
%exception {
|
||||||
|
try {
|
||||||
|
$action
|
||||||
|
} catch (const std::out_of_range& e) {
|
||||||
|
SWIG_exception(SWIG_IndexError, e.what());
|
||||||
|
} catch (const std::exception& e) {
|
||||||
|
SWIG_exception(SWIG_RuntimeError, e.what());
|
||||||
|
} catch (...) {
|
||||||
|
SWIG_exception(SWIG_RuntimeError, "unknown exception");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
%typemap(in) arity_t { (jlong)($input); }
|
%typemap(in) arity_t { (jlong)($input); }
|
||||||
@ -139,19 +152,6 @@ YAPError = _yap.YAPError
|
|||||||
// Language independent exception handler
|
// Language independent exception handler
|
||||||
// simplified version
|
// simplified version
|
||||||
%include <exception.i>
|
%include <exception.i>
|
||||||
|
|
||||||
%exception {
|
|
||||||
try {
|
|
||||||
$action
|
|
||||||
} catch (const std::out_of_range& e) {
|
|
||||||
SWIG_exception(SWIG_IndexError, e.what());
|
|
||||||
} catch (const std::exception& e) {
|
|
||||||
SWIG_exception(SWIG_RuntimeError, e.what());
|
|
||||||
} catch (...) {
|
|
||||||
SWIG_exception(SWIG_RuntimeError, "unknown exception");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@ -351,8 +351,9 @@ static void
|
|||||||
};
|
};
|
||||||
|
|
||||||
%init %{
|
%init %{
|
||||||
PyObject * pYAPError = PyErr_NewException("_yap.YAPError", NULL, NULL);
|
#ifdef SWIGYTHON
|
||||||
Py_INCREF(pYAPError);
|
PyObject * pYAPError = PyErr_NewException("_yap.YAPError", NULL, NULL);
|
||||||
PyModule_AddObject(m, "YAPError", pYAPError);
|
Py_INCREF(pYAPError);
|
||||||
|
PyModule_AddObject(m, "YAPError", pYAPError);
|
||||||
|
#endif
|
||||||
%}
|
%}
|
||||||
|
Reference in New Issue
Block a user