Merge ssh://ssh.dcc.fc.up.pt:31064/home/vsc/yap
This commit is contained in:
commit
8196666cdc
1
C/init.c
1
C/init.c
@ -984,6 +984,7 @@ void Yap_InitCPredBack_(const char *Name, arity_t Arity, arity_t Extra,
|
||||
|
||||
static void InitStdPreds(struct yap_boot_params *yapi)
|
||||
{
|
||||
CurrentModule = PROLOG_MODULE;
|
||||
Yap_InitCPreds();
|
||||
Yap_InitBackCPreds();
|
||||
BACKUP_MACHINE_REGS();
|
||||
|
2
C/text.c
2
C/text.c
@ -557,11 +557,9 @@ unsigned char *Yap_readText(seq_tv_t *inp USES_REGS) {
|
||||
POPRET( (char*)latin2utf8(inp));
|
||||
}
|
||||
|
||||
if (inp->enc == ENC_ISO_UTF8) {
|
||||
pop_text_stack(lvl);
|
||||
return inp->val.c;
|
||||
}
|
||||
}
|
||||
if (inp->type & YAP_STRING_WCHARS) {
|
||||
// printf("%S\n",inp->val.w);
|
||||
POPRET( (char *)wchar2utf8(inp) );
|
||||
|
67
CXX/yapi.cpp
67
CXX/yapi.cpp
@ -125,6 +125,7 @@ YAPAtomTerm::YAPAtomTerm(char s[]) { // build string
|
||||
|
||||
CACHE_REGS
|
||||
seq_tv_t inp, out;
|
||||
inp.enc = LOCAL_encoding;
|
||||
inp.val.c = s;
|
||||
inp.type = YAP_STRING_CHARS;
|
||||
out.type = YAP_STRING_ATOM;
|
||||
@ -142,6 +143,7 @@ YAPAtomTerm::YAPAtomTerm(char *s, size_t len) { // build string
|
||||
seq_tv_t inp, out;
|
||||
inp.val.c = s;
|
||||
inp.type = YAP_STRING_CHARS;
|
||||
inp.enc = LOCAL_encoding;
|
||||
out.type = YAP_STRING_ATOM | YAP_STRING_NCHARS | YAP_STRING_TRUNC;
|
||||
out.max = len;
|
||||
if (Yap_CVT_Text(&inp, &out PASS_REGS))
|
||||
@ -253,7 +255,19 @@ YAPApplTerm::YAPApplTerm(YAPFunctor f, YAPTerm ts[]) {
|
||||
RECOVER_H();
|
||||
}
|
||||
|
||||
YAPApplTerm::YAPApplTerm(std::string f, std::vector<YAPTerm> ts) {
|
||||
YAPApplTerm::YAPApplTerm(const std::string f, std::vector<Term> 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];
|
||||
mk(o);
|
||||
RECOVER_H();
|
||||
}
|
||||
|
||||
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);
|
||||
@ -262,6 +276,57 @@ YAPApplTerm::YAPApplTerm(std::string f, std::vector<YAPTerm> ts) {
|
||||
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();
|
||||
arity_t arity = 1;
|
||||
Functor ff = Yap_MkFunctor(Yap_LookupAtom(f.c_str()), arity);
|
||||
Term o = Yap_MkNewApplTerm(ff, arity);
|
||||
Term *tt = RepAppl(o) + 1;
|
||||
tt[0] = a1.term();
|
||||
mk(o);
|
||||
RECOVER_H();
|
||||
}
|
||||
|
||||
YAPApplTerm::YAPApplTerm(const std::string f, YAPTerm a1, YAPTerm a2) {
|
||||
BACKUP_H();
|
||||
arity_t arity = 2;
|
||||
Functor ff = Yap_MkFunctor(Yap_LookupAtom(f.c_str()), arity);
|
||||
Term o = Yap_MkNewApplTerm(ff, arity);
|
||||
Term *tt = RepAppl(o) + 1;
|
||||
tt[0] = a1.term();
|
||||
tt[1] = a2.term();
|
||||
mk(o);
|
||||
RECOVER_H();
|
||||
}
|
||||
|
||||
YAPApplTerm::YAPApplTerm(const std::string f, YAPTerm a1, YAPTerm a2, YAPTerm a3) {
|
||||
BACKUP_H();
|
||||
arity_t arity = 3;
|
||||
Functor ff = Yap_MkFunctor(Yap_LookupAtom(f.c_str()), arity);
|
||||
Term o = Yap_MkNewApplTerm(ff, arity);
|
||||
Term *tt = RepAppl(o) + 1;
|
||||
tt[0] = a1.term();
|
||||
tt[2] = a2.term();
|
||||
tt[3] = a3.term();
|
||||
mk(o);
|
||||
RECOVER_H();
|
||||
}
|
||||
|
||||
YAPApplTerm::YAPApplTerm(const std::string f, YAPTerm a1, YAPTerm a2, YAPTerm a3, YAPTerm a4) {
|
||||
BACKUP_H();
|
||||
arity_t arity = 4;
|
||||
Functor ff = Yap_MkFunctor(Yap_LookupAtom(f.c_str()), arity);
|
||||
Term o = Yap_MkNewApplTerm(ff, arity);
|
||||
Term *tt = RepAppl(o) + 1;
|
||||
tt[0] = a1.term();
|
||||
tt[2] = a2.term();
|
||||
tt[3] = a3.term();
|
||||
tt[4] = a4.term();
|
||||
mk(o);
|
||||
RECOVER_H();
|
||||
}
|
||||
|
||||
YAPApplTerm::YAPApplTerm(YAPFunctor f) : YAPTerm() {
|
||||
|
@ -295,8 +295,8 @@ class X_API YAPApplTerm : public YAPTerm {
|
||||
friend class YAPTerm;
|
||||
|
||||
public:
|
||||
YAPApplTerm(Term t0) { mk(t0); }
|
||||
YAPApplTerm(Functor f, Term ts[]) {
|
||||
YAPApplTerm(Term t0) { mk(t0); }
|
||||
YAPApplTerm(Functor f, Term ts[]) {
|
||||
BACKUP_MACHINE_REGS();
|
||||
Term t0 = Yap_MkApplTerm(f, f->ArityOfFE, ts);
|
||||
mk(t0);
|
||||
@ -307,10 +307,15 @@ public:
|
||||
mk(Yap_MkNewApplTerm(Yap_MkFunctor(Yap_LookupAtom(s.c_str()), arity),
|
||||
arity));
|
||||
};
|
||||
YAPApplTerm(const std::string s, std::vector<Term> ts);
|
||||
YAPApplTerm(const std::string s, std::vector<YAPTerm> ts);
|
||||
YAPApplTerm(YAPFunctor f);
|
||||
inline Functor functor() { return FunctorOfTerm(gt()); }
|
||||
inline YAPFunctor getFunctor() { return YAPFunctor(FunctorOfTerm(gt())); }
|
||||
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) {
|
||||
BACKUP_MACHINE_REGS();
|
||||
|
@ -1,7 +1,11 @@
|
||||
site_name: 'YAP'
|
||||
theme: 'readthedocs'
|
||||
markdown_extensions:
|
||||
use_directory_urls: false
|
||||
- smarty
|
||||
- toc:
|
||||
permalink: True
|
||||
- sane_lists
|
||||
use_directory_urls: false
|
||||
plugins:
|
||||
- search
|
||||
- awesome-pages:
|
||||
|
@ -835,11 +835,6 @@ static parser_state_t initParser(Term opts, FEnv *fe, REnv *re, int inp_stream,
|
||||
LOCAL_ErrorMessage = NULL;
|
||||
fe->old_TR = TR;
|
||||
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_eot_before_eof = false;
|
||||
fe->tpos = StreamPosition(inp_stream);
|
||||
|
@ -1551,11 +1551,7 @@ FILE *Yap_FileDescriptorFromStream(Term t) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
Yap_InitBackIO (
|
||||
|
||||
void)
|
||||
void Yap_InitBackIO(void)
|
||||
{
|
||||
Yap_InitCPredBack("stream_property", 2, 2, stream_property,
|
||||
cont_stream_property, SafePredFlag | SyncPredFlag);
|
||||
|
@ -15,12 +15,15 @@
|
||||
* *
|
||||
*************************************************************************/
|
||||
#include "Yap.h"
|
||||
#ifdef USE_MYDDAS
|
||||
|
||||
#include "Yatom.h"
|
||||
#include "cut_c.h"
|
||||
#include "myddas.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
#ifdef USE_MYDDAS
|
||||
|
||||
#include "myddas.h"
|
||||
|
||||
#ifdef MYDDAS_STATS
|
||||
#include "myddas_statistics.h"
|
||||
#endif
|
||||
@ -678,30 +681,17 @@ void Yap_MYDDAS_delete_all_myddas_structs(void) {
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void init_myddas(void) {
|
||||
CACHE_REGS
|
||||
if (myddas_initialised)
|
||||
{
|
||||
return;
|
||||
}
|
||||
#if USE_MYDDAS
|
||||
Term cm=CurrentModule;
|
||||
CurrentModule = USER_MODULE;
|
||||
if (myddas_initialised)
|
||||
return;
|
||||
#ifdef __ANDROID__
|
||||
init_sqlite3();
|
||||
#endif
|
||||
#if defined MYDDAS_ODBC
|
||||
Yap_InitBackMYDDAS_ODBCPreds();
|
||||
#endif
|
||||
#endif
|
||||
#if defined MYDDAS_ODBC
|
||||
Yap_InitMYDDAS_ODBCPreds();
|
||||
#endif
|
||||
#if defined USE_MYDDAS
|
||||
Yap_InitMYDDAS_SharedPreds();
|
||||
#endif
|
||||
#if defined MYDDAS_TOP_LEVEL && \
|
||||
defined MYDDAS_MYSQL // && defined HAVE_LIBREADLINE
|
||||
Yap_InitMYDDAS_TopLevelPreds();
|
||||
#endif
|
||||
#if USE_MYDDAS
|
||||
#define stringify(X) _stringify(X)
|
||||
#define _stringify(X) #X
|
||||
Yap_REGS.MYDDAS_GLOBAL_POINTER = NULL;
|
||||
@ -709,12 +699,25 @@ void init_myddas(void) {
|
||||
MkAtomTerm(Yap_LookupAtom(stringify(MYDDAS_VERSION))));
|
||||
Yap_HaltRegisterHook((HaltHookFunc)Yap_MYDDAS_delete_all_myddas_structs,
|
||||
NULL);
|
||||
Yap_InitMYDDAS_SharedPreds();
|
||||
Yap_InitBackMYDDAS_SharedPreds();
|
||||
#undef stringify
|
||||
#undef _stringify
|
||||
Yap_MYDDAS_delete_all_myddas_structs();
|
||||
#if defined MYDDAS_ODBC
|
||||
Yap_InitBackMYDDAS_ODBCPreds();
|
||||
Yap_InitMYDDAS_ODBCPreds();
|
||||
#endif
|
||||
#if defined MYDDAS_TOP_LEVEL && \
|
||||
defined MYDDAS_MYSQL // && defined HAVE_LIBREADLINE
|
||||
Yap_InitMYDDAS_TopLevelPreds();
|
||||
#endif
|
||||
c_db_initialize_myddas(PASS_REGS1);
|
||||
myddas_initialised = TRUE;
|
||||
#ifdef __ANDROID__
|
||||
init_sqlite3();
|
||||
#endif
|
||||
#endif
|
||||
myddas_initialised = true;
|
||||
CurrentModule = cm;
|
||||
}
|
||||
|
||||
|
@ -22,6 +22,7 @@
|
||||
|
||||
#ifdef DEBUG
|
||||
:- yap_flag(single_var_warnings,on).
|
||||
:- yap_flag(write_strings,on).
|
||||
#endif
|
||||
|
||||
#define SWITCH(Contype, G) \
|
||||
@ -181,7 +182,7 @@
|
||||
member/2
|
||||
]).
|
||||
|
||||
:- set(verbose,silent).
|
||||
:- set_prolog_flag(verbose,silent).
|
||||
|
||||
|
||||
|
||||
@ -251,11 +252,11 @@ db_open(sqlite3,Connection,File,User,Password) :-
|
||||
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%% db_close/1
|
||||
%% db_close/0
|
||||
%
|
||||
% close a connection _Con_: all its resources are returned, and all undefined
|
||||
% predicates are abolished. Default is to close `myddas`.
|
||||
%% db_close/1
|
||||
%% db_close/0
|
||||
%
|
||||
% close a connection _Con_: all its resources are returned, and all undefined
|
||||
% predicates are abolished. Default is to close `myddas`.
|
||||
db_close:-
|
||||
db_close(myddas).
|
||||
db_close(Protocol):-
|
||||
@ -271,38 +272,38 @@ db_close(Protocol):-
|
||||
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% db_verbose/1
|
||||
%
|
||||
%
|
||||
% db_verbose/1
|
||||
%
|
||||
%
|
||||
db_verbose(X):-
|
||||
var(X),!,
|
||||
get_value(db_verbose,X).
|
||||
db_verbose(N):-!,
|
||||
set_value(db_verbose,N).
|
||||
%default value
|
||||
%default value
|
||||
:- set_value(db_verbose,0).
|
||||
:- set_value(db_verbose_filename,myddas_queries).
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% db_module/1
|
||||
%
|
||||
%
|
||||
% db_module/1
|
||||
%
|
||||
%
|
||||
db_module(X):-
|
||||
var(X),!,
|
||||
get_value(db_module,X).
|
||||
db_module(ModuleName):-
|
||||
set_value(db_module,ModuleName).
|
||||
% default value
|
||||
% default value
|
||||
:- db_module(user).
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% db_is_database_predicate(+,+,+)
|
||||
%
|
||||
%
|
||||
% db_is_database_predicate(+,+,+)
|
||||
%
|
||||
%
|
||||
db_is_database_predicate(Module,PredName,Arity):-
|
||||
'$error_checks'(db_is_database_predicate(PredName,Arity,Module)),
|
||||
c_db_check_if_exists_pred(PredName,Arity,Module).
|
||||
@ -310,9 +311,9 @@ db_is_database_predicate(Module,PredName,Arity):-
|
||||
|
||||
#ifdef MYDDAS_STATS
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% db_stats(+,-)
|
||||
%
|
||||
%
|
||||
% db_stats(+,-)
|
||||
%
|
||||
%
|
||||
db_stats(List):-
|
||||
db_stats(myddas,List).
|
||||
|
||||
@ -330,8 +331,8 @@ db_stats(Protocol,List):-
|
||||
|
||||
#ifdef DEBUG
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% db_stats_time(+,-)
|
||||
% Reference is C pointer (memory reference)
|
||||
% db_stats_time(+,-)
|
||||
% Reference is C puuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uuuuu;ointer (memory reference)
|
||||
%
|
||||
db_stats_time(Reference,Time):-
|
||||
'$error_checks'(db_stats_time(Reference,Time)),
|
||||
@ -449,7 +450,6 @@ db_assert(Connection,PredName):-
|
||||
'$error_checks'(db_insert2(Connection,PredName,Code)),
|
||||
'$get_values_for_insert'(Code,ValuesList,RelName),
|
||||
'$make_atom'(['INSERT INTO `',RelName,'` VALUES '|ValuesList],SQL),
|
||||
|
||||
get_value(Connection,Con),
|
||||
c_db_connection_type(Con,ConType),
|
||||
'$write_or_not'(SQL),
|
||||
@ -685,17 +685,18 @@ db_describe(Connection,Y,Z) :-
|
||||
|
||||
db_datalog_show_tables :-
|
||||
db_datalog_show_tables(myddas).
|
||||
db_show_tables :-
|
||||
'$error_checks'(db_datalog_show_tables),
|
||||
get_value(myddas,Con),
|
||||
c_db_connection_type(Con,DBMS),
|
||||
DBMS:datalog_show_tables.
|
||||
|
||||
db_datalog_show_tables(Connection) :-
|
||||
'$error_checks'(db_datalog_show_tables(Connection) ),
|
||||
get_value(Connection,Con),
|
||||
c_db_connection_type(Con,DBMS),
|
||||
switch( DBMS, datalog_show_tables(Connection) ).
|
||||
|
||||
db_datalog_show_tables :-
|
||||
'$error_checks'(db_datalog_show_tables),
|
||||
get_value(myddas,Con),
|
||||
c_db_connection_type(Con,DBMS),
|
||||
DBMS:datalog_show_tables.
|
||||
|
||||
/**
|
||||
@pred db_show_tables(+,?).
|
||||
|
@ -230,7 +230,7 @@ db_abolish(PredName,Arity):-
|
||||
%
|
||||
db_listing:-
|
||||
c_db_connection(Con),
|
||||
c_db_preds_conn(Con,Module,Name,Arity),
|
||||
user:c_db_preds_conn(Con,Module,Name,Arity),
|
||||
listing(Module:Name/Arity),
|
||||
fail.
|
||||
db_listing.
|
||||
@ -243,15 +243,15 @@ db_listing.
|
||||
%
|
||||
db_listing(Module:Name/Arity):-!,
|
||||
c_db_connection(Con),
|
||||
c_db_preds_conn(Con,Module,Name,Arity),
|
||||
user:c_db_preds_conn(Con,Module,Name,Arity),
|
||||
listing(Module:Name/Arity).
|
||||
db_listing(Name/Arity):-!,
|
||||
c_db_connection(Con),
|
||||
c_db_preds_conn(Con,Module,Name,Arity),
|
||||
user:c_db_preds_conn(Con,Module,Name,Arity),
|
||||
listing(Module:Name/Arity).
|
||||
db_listing(Name):-
|
||||
c_db_connection(Con),
|
||||
c_db_preds_conn(Con,Module,Name,Arity),
|
||||
user:c_db_preds_conn(Con,Module,Name,Arity),
|
||||
listing(Module:Name/Arity).
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
@ -260,13 +260,12 @@ db_listing(Name):-
|
||||
%
|
||||
table_arity( Con, ConType, RelationName, Arity ) :-
|
||||
c_db_connection_type(Con,ConType),
|
||||
writeln( ConType ),
|
||||
% get relation arity
|
||||
( ConType == mysql ->
|
||||
c_db_my_number_of_fields(RelationName,Con,Arity)
|
||||
;
|
||||
ConType == postgres ->
|
||||
c_postgres_number_of_fields(RelationName,Con,Arity)
|
||||
c_postgres_number_of_fields(RelationName,Con,Arit)
|
||||
;
|
||||
ConType == odbc ->
|
||||
c_odbc_number_of_fields(RelationName,Con,Arity)
|
||||
|
@ -28,7 +28,7 @@
|
||||
#define NAME() 'YAPodbc'
|
||||
#define MODULE() user
|
||||
#define INIT() init_odbc
|
||||
#elif defined( postgres )
|
||||
#elif defined( postrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrs )
|
||||
#undef postgres
|
||||
#define DBMS(x) postgres_##x
|
||||
#define c_DBMS(x) c_postgres_##x
|
||||
@ -101,7 +101,6 @@ DBMS(result_set)(store_result):-
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% DBMS(db_datalog_describe)/2
|
||||
%
|
||||
|
@ -1,4 +1,3 @@
|
||||
:- stop_low_level_trace.
|
||||
|
||||
|
||||
:- use_module(library(lists)).
|
||||
@ -14,10 +13,22 @@ main_ :-
|
||||
fail.
|
||||
main_ .
|
||||
|
||||
:- if( yap_flag(android,true) ).
|
||||
init :-
|
||||
db_open(sqlite3, '/data/user/0/pt.up.yap/files/chinook.db', _, _),
|
||||
!,
|
||||
writeln('chinook has landed').
|
||||
|
||||
init :-
|
||||
catch(db_open(sqlite3,'chinook.db',_,_), _, fail),
|
||||
% db_open(sqlite3, 'chinook.db', _, _),
|
||||
writeln('chinook has landed').
|
||||
:- else.
|
||||
init :-
|
||||
db_open(sqlite3, '/data/user/0/pt.up.yap.yapdroid/files/Yap/chinook.db', _, _),
|
||||
% db_open(sqlite3, 'chinook.db', _, _),
|
||||
writeln('chinook has landed').
|
||||
:-endif.
|
||||
|
||||
go :-
|
||||
writeln(('db_import')),
|
||||
|
@ -8,6 +8,8 @@
|
||||
#define PASS_REGS
|
||||
#define USES_REGS
|
||||
|
||||
#include "Yap.h"
|
||||
|
||||
//@{
|
||||
|
||||
/** @brief Prolog to Python library
|
||||
|
@ -591,7 +591,7 @@ static int python_import(term_t mname, term_t mod) {
|
||||
const char *sn, *as = NULL;
|
||||
Term t = Deref(ARG1), sm;
|
||||
if (IsApplTerm(t)) {
|
||||
Functor f = FunctorOfTerm(t);
|
||||
Functor f = (Functor)*RepAppl(t);
|
||||
if (f != FunctorAs)
|
||||
return false;
|
||||
do_as = true;
|
||||
|
@ -54,7 +54,6 @@ endif()
|
||||
COMMAND ${SWIG_EXECUTABLE} -c++ -python -O -py3 -module "yap" -addextern -I${CMAKE_SOURCE_DIR}/H -I${CMAKE_SOURCE_DIR}/H/generated -I${CMAKE_SOURCE_DIR}/include
|
||||
-I${CMAKE_SOURCE_DIR}/OPTYap -I${CMAKE_SOURCE_DIR}/os -I${CMAKE_SOURCE_DIR}/utf8proc -I.././.. -I${CMAKE_SOURCE_DIR}/CXX -I${CMAKE_SOURCE_DIR}/packages/python
|
||||
-outdir ${CMAKE_CURRENT_BINARY_DIR}/yap4py -I${GMP_INCLUDE_DIRS} -DX_API="" -o ${CMAKE_CURRENT_BINARY_DIR}/yap4py/yap_wrap.cxx -oh ${CMAKE_CURRENT_BINARY_DIR}/yap4py/yap_wrap.hh ${SWIG_SOURCES}
|
||||
COMMAND ${PYTHON_EXECUTABLE} setup.py sdist ${bdist}
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
DEPENDS ${SWIG_SOURCES} Py4YAP YAP++ yap4py/yapi.cpp YAP4PY_PY
|
||||
)
|
||||
@ -70,7 +69,9 @@ endif()
|
||||
DEPENDS ${PYTHON_SOURCES}
|
||||
)
|
||||
|
||||
install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} -m pip install ${PYTHON_USER_INSTALL} --ignore-installed .
|
||||
install(CODE "execute_process(
|
||||
COMMAND ${PYTHON_EXECUTABLE} setup.py sdist ${bdist}
|
||||
COMMAND ${PYTHON_EXECUTABLE} -m pip install ${PYTHON_USER_INSTALL} --ignore-installed .
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})"
|
||||
DEPENDS Py4YAP ${CMAKE_BINARY_DIR}/${YAP_STARTUP} ${YAP_INSTALL_DLLDIR} )
|
||||
|
||||
|
@ -84,8 +84,8 @@ native_sources = ["yap4py/yap_wrap.cxx","yap4py/yapi.cpp"]
|
||||
|
||||
|
||||
extensions = [Extension('_yap', native_sources,
|
||||
define_macros=[('MAJOR_VERSION', '1'),
|
||||
('MINOR_VERSION', '0'),
|
||||
define_macros=[('MAJOR_VERSION', '@YAP_MAJOR_VERSION@'),
|
||||
('MINOR_VERSION', '@YAP_MINOR_VERSION@'),
|
||||
('_YAP_NOT_INSTALLED_', '1'),
|
||||
('YAP_PYTHON', '1'),
|
||||
('PYTHONSWIG', '1'),
|
||||
@ -104,7 +104,7 @@ extensions = [Extension('_yap', native_sources,
|
||||
'${CMAKE_SOURCE_DIR}/os',
|
||||
'${CMAKE_SOURCE_DIR}/utf8proc',
|
||||
'${CMAKE_SOURCE_DIR}/packages/python',
|
||||
'../../..',
|
||||
'${CMAKE_BINARY_DIR}',
|
||||
'${CMAKE_SOURCE_DIR}/CXX' ]
|
||||
)]
|
||||
|
||||
|
@ -185,7 +185,6 @@ yap_ipython/sphinxext/ipython_console_highlighting.py
|
||||
yap_ipython/sphinxext/ipython_directive.py
|
||||
yap_ipython/nbformat.py
|
||||
yap_ipython/paths.py
|
||||
yap_ipython/_version.py
|
||||
yap_ipython/nbconvert.py
|
||||
yap_ipython/qt.py
|
||||
yap_ipython/html.py
|
||||
@ -413,23 +412,12 @@ add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/yap_kernel/resources/kerne
|
||||
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/kernel.js
|
||||
)
|
||||
|
||||
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/yap_kernel/resources/meta.js
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/misc/editors/meta.js ${CMAKE_CURRENT_BINARY_DIR}/yap_kernel/resources/
|
||||
DEPENDS ${CMAKE_SOURCE_DIR}/misc/editors/meta.js
|
||||
)
|
||||
|
||||
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/yap_kernel/resources/prolog.js
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/misc/editors/yap.js ${CMAKE_CURRENT_BINARY_DIR}/yap_kernel/resources/prolog.js
|
||||
DEPENDS ${CMAKE_SOURCE_DIR}/misc/editors/yap.js
|
||||
)
|
||||
|
||||
|
||||
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/yap_kernel/resources/mode.js
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/misc/editors/mode.js ${CMAKE_CURRENT_BINARY_DIR}/yap_kernel/resources/
|
||||
DEPENDS ${CMAKE_SOURCE_DIR}/misc/editors/mode.js
|
||||
)
|
||||
|
||||
|
||||
foreach(f ${FILES})
|
||||
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${f}
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/${f} ${CMAKE_CURRENT_BINARY_DIR}/${f}
|
||||
@ -441,13 +429,13 @@ endforeach()
|
||||
|
||||
|
||||
add_custom_target(YAP_KERNEL ALL
|
||||
COMMAND ${PYTHON_EXECUTABLE} ${SETUP_PY} build sdist bdist
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/yap_kernel/resources/logo-32x32.png ${CMAKE_CURRENT_BINARY_DIR}/yap_kernel/resources/logo-64x64.png ${CMAKE_CURRENT_BINARY_DIR}/yap_kernel/resources/kernel.js ${CMAKE_CURRENT_BINARY_DIR}/yap_kernel/resources/meta.js ${CMAKE_CURRENT_BINARY_DIR}/yap_kernel/resources/prolog.js ${CMAKE_CURRENT_BINARY_DIR}/yap_kernel/resources/mode.js ${OUTS} YAP4PY
|
||||
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/yap_kernel/resources/logo-32x32.png ${CMAKE_CURRENT_BINARY_DIR}/yap_kernel/resources/logo-64x64.png ${CMAKE_CURRENT_BINARY_DIR}/yap_kernel/resources/kernel.js ${CMAKE_CURRENT_BINARY_DIR}/yap_kernel/resources/prolog.js ${OUTS} YAP4PY
|
||||
)
|
||||
|
||||
|
||||
install(CODE "execute_process(
|
||||
COMMAND ${PYTHON_EXECUTABLE} ${SETUP_PY} build sdist bdist
|
||||
COMMAND ${PYTHON_EXECUTABLE} -m pip install ${PYTHON_USER_INSTALL} --ignore-installed --no-deps .
|
||||
COMMAND ${PYTHON_EXECUTABLE} -m yap_kernel.kernelspec
|
||||
ERROR_VARIABLE setupErr
|
||||
|
@ -36,12 +36,12 @@ DEPENDS pllibpl ${pl_os_library}
|
||||
)
|
||||
|
||||
add_custom_command (OUTPUT ${CMAKE_SWIG_OUTPUT}/swig_streamer.cpp
|
||||
COMMAND ${SWIG_EXECUTABLE} -c++ -java -package ${SWIG_MODULE_NAME} -outdir ${CMAKE_SWIG_OUTDIR} -addextern -I${CMAKE_CURRENT_SOURCE_DIR} -o ${CMAKE_SWIG_OUTPUT}/swig_streamer.cpp -oh ${CMAKE_SWIG_OUTPUT}/swig_streamer.hh streamer.i
|
||||
COMMAND ${SWIG_EXECUTABLE} -c++ -java -package ${SWIG_MODULE_NAME} -O -outdir ${CMAKE_SWIG_OUTDIR} -addextern -I${CMAKE_CURRENT_SOURCE_DIR} -o ${CMAKE_SWIG_OUTPUT}/swig_streamer.cpp -oh ${CMAKE_SWIG_OUTPUT}/swig_streamer.hh streamer.i
|
||||
DEPENDS streamer.i
|
||||
)
|
||||
|
||||
add_custom_command (OUTPUT ${CMAKE_SWIG_OUTPUT}/yap_swig.cpp
|
||||
COMMAND ${SWIG_EXECUTABLE} -c++ -java -package ${SWIG_MODULE_NAME} -outdir ${CMAKE_SWIG_OUTDIR} -addextern -I${CMAKE_SOURCE_DIR}/CXX -I${CMAKE_SOURCE_DIR}/include -I${CMAKE_SOURCE_DIR}/H -I${CMAKE_SOURCE_DIR}/os -I${CMAKE_SOURCE_DIR}/OPTYap -I${CMAKE_BINARY_DIR} -I${GMP_INCLUDE_DIRS} -DX_API="" -o ${CMAKE_SWIG_OUTPUT}/yap_swig.cpp -oh ${CMAKE_SWIG_OUTPUT}/yap_swig.hh ${SWIG_SOURCES}
|
||||
COMMAND ${SWIG_EXECUTABLE} -c++ -java -package ${SWIG_MODULE_NAME} -O -outdir ${CMAKE_SWIG_OUTDIR} -addextern -I${CMAKE_SOURCE_DIR}/CXX -I${CMAKE_SOURCE_DIR}/include -I${CMAKE_SOURCE_DIR}/H -I${CMAKE_SOURCE_DIR}/os -I${CMAKE_SOURCE_DIR}/OPTYap -I${CMAKE_BINARY_DIR} -I${GMP_INCLUDE_DIRS} -DX_API="" -o ${CMAKE_SWIG_OUTPUT}/yap_swig.cpp -oh ${CMAKE_SWIG_OUTPUT}/yap_swig.hh ${SWIG_SOURCES}
|
||||
DEPENDS pllibos ${SWIG_SOURCES} YAP++)
|
||||
|
||||
|
||||
|
@ -124,6 +124,19 @@ YAPError = _yap.YAPError
|
||||
|
||||
%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
|
||||
|
||||
%typemap(in) arity_t { (jlong)($input); }
|
||||
@ -139,19 +152,6 @@ YAPError = _yap.YAPError
|
||||
// Language independent exception handler
|
||||
// simplified version
|
||||
%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
|
||||
|
||||
|
||||
@ -351,8 +351,9 @@ static void
|
||||
};
|
||||
|
||||
%init %{
|
||||
#ifdef SWIGYTHON
|
||||
PyObject * pYAPError = PyErr_NewException("_yap.YAPError", NULL, NULL);
|
||||
Py_INCREF(pYAPError);
|
||||
PyModule_AddObject(m, "YAPError", pYAPError);
|
||||
|
||||
#endif
|
||||
%}
|
||||
|
@ -478,4 +478,8 @@ If this hook preodicate succeeds it must instantiate the _Action_ argument to t
|
||||
:- ensure_loaded('../pl/pathconf.yap').
|
||||
|
||||
:- yap_flag(user:unknown,error).
|
||||
|
||||
:- ensure_loaded('../android.yap').
|
||||
|
||||
|
||||
%% @}
|
||||
|
@ -293,7 +293,7 @@ abolish(X0) :-
|
||||
'$old_abolish'(X,M).
|
||||
|
||||
'$new_abolish'(V,M) :- var(V), !,
|
||||
'$abolish_all'(M).
|
||||
'$abolish_all_in_module'(M).
|
||||
'$new_abolish'(A/V,M) :- atom(A), var(V), !,
|
||||
'$abolish_all_atoms'(A,M).
|
||||
'$new_abolish'(Na//Ar1, M) :-
|
||||
@ -313,12 +313,12 @@ abolish(X0) :-
|
||||
'$new_abolish'(T, M) :-
|
||||
'$do_error'(type_error(predicate_indicator,T),abolish(M:T)).
|
||||
|
||||
'$abolish_all'(M) :-
|
||||
'$abolish_all_in_module'(M) :-
|
||||
'$current_predicate'(Na, M, S, _),
|
||||
functor(S, Na, Ar),
|
||||
'$new_abolish'(Na/Ar, M),
|
||||
fail.
|
||||
'$abolish_all'(_).
|
||||
'$abolish_all_in_module'(_).
|
||||
|
||||
'$abolish_all_atoms'(Na, M) :-
|
||||
'$current_predicate'(Na,M,S,_),
|
||||
@ -817,3 +817,4 @@ clause_property(ClauseRef, predicate(PredicateIndicator)) :-
|
||||
/**
|
||||
@}
|
||||
*/
|
||||
|
||||
|
Reference in New Issue
Block a user