changes to support eclipse compat

support of Android assets as /assets files.
This commit is contained in:
Vítor Santos Costa 2014-06-04 22:08:37 +01:00
parent 3087d51b18
commit 71b40e0438
28 changed files with 1273 additions and 569 deletions

View File

@ -2288,12 +2288,14 @@ YAP_EnterGoal(PredEntry *pe, Term *ptr, YAP_dogoalinfo *dgi)
CACHE_REGS
int out;
__android_log_print(ANDROID_LOG_INFO, "yapi.cpp", "got %p pred %p slot %d", LOCAL, pe, dgi->CurSlot);
BACKUP_MACHINE_REGS();
LOCAL_PrologMode = UserMode;
dgi->p = P;
dgi->cp = CP;
dgi->CurSlot = LOCAL_CurSlot;
// ensure our current ENV receives current P.
Yap_PrepGoal(pe->ArityOfPE, ptr, B PASS_REGS);
P = pe->CodeOfPred;
dgi->b = LCL0-(CELL*)B;
@ -2986,6 +2988,7 @@ YAP_Init(YAP_init_args *yap_init)
if (initialised)
return YAP_BOOT_DONE_BEFOREHAND;
initialised = TRUE;
__android_log_print(ANDROID_LOG_INFO, "c_interface.c", "entered init %p", yap_init);
Yap_InitPageSize(); /* init memory page size, required by later functions */
#if defined(YAPOR_COPY) || defined(YAPOR_COW) || defined(YAPOR_SBA)

View File

@ -1419,13 +1419,18 @@ Yap_locked_growheap(int fix_code, size_t in_size, void *cip)
int res;
int blob_overflow = (NOfBlobs > NOfBlobsMax);
#if (THREADS) || YAPOR
res = FALSE;
if (NOfAtoms > 2*AtomHashTableSize || blob_overflow) {
Yap_undo_signal( YAP_CDOVF_SIGNAL );
return TRUE;
LOCK(GLOBAL_ThreadHandlesLock);
// make sure that we cannot have more than a thread life
if (Yap_NOfThreads() > 1) {
UNLOCK(GLOBAL_ThreadHandlesLock);
res = FALSE;
if (NOfAtoms > 2*AtomHashTableSize || blob_overflow) {
Yap_undo_signal( YAP_CDOVF_SIGNAL );
UNLOCK(LOCAL_SignalLock);
return TRUE;
}
}
#else
// don't release the MTHREAD lock in case we're running from the C-interface.
if (NOfAtoms > 2*AtomHashTableSize || blob_overflow) {
UInt n = NOfAtoms;
if (GLOBAL_AGcThreshold)
@ -1438,11 +1443,14 @@ Yap_locked_growheap(int fix_code, size_t in_size, void *cip)
res = growatomtable( PASS_REGS1 );
} else {
Yap_undo_signal( YAP_CDOVF_SIGNAL );
UNLOCK(GLOBAL_ThreadHandlesLock);
return TRUE;
}
LeaveGrowMode(GrowHeapMode);
if (res)
if (res) {
UNLOCK(GLOBAL_ThreadHandlesLock);
return res;
}
}
#if USE_SYSTEM_MALLOC
P = Yap_Error(OUT_OF_HEAP_ERROR,TermNil,"malloc failed");
@ -1451,7 +1459,7 @@ Yap_locked_growheap(int fix_code, size_t in_size, void *cip)
res=do_growheap(fix_code, in_size, (struct intermediates *)cip, NULL, NULL, NULL PASS_REGS);
#endif
LeaveGrowMode(GrowHeapMode);
#endif
UNLOCK(GLOBAL_ThreadHandlesLock);
return res;
}

View File

@ -169,11 +169,13 @@ PUSH_POINTER(CELL *v USES_REGS) {
*LOCAL_iptop++ = v;
}
#ifdef EASY_SHUNTING
inline static void
POP_POINTER( USES_REGS1 ) {
if (LOCAL_iptop >= (CELL_PTR *)ASP) return;
--LOCAL_iptop;
}
#endif
inline static void
POPSWAP_POINTER(CELL_PTR *vp, CELL_PTR v USES_REGS) {
@ -1524,21 +1526,6 @@ mark_external_reference(CELL *ptr USES_REGS) {
}
}
static void inline
mark_external_reference2(CELL *ptr USES_REGS) {
CELL *next = GET_NEXT(*ptr);
if (ONHEAP(next)) {
#ifdef HYBRID_SCHEME
CELL_PTR *old = LOCAL_iptop;
#endif
mark_variable(ptr PASS_REGS);
POPSWAP_POINTER(old, ptr PASS_REGS);
} else {
mark_code(ptr,next PASS_REGS);
}
}
/*
* mark all heap objects accessible from the trail (which includes the active
* general purpose registers)

View File

@ -484,7 +484,7 @@ Yap_read_term(term_t t0, IOSTREAM *inp_stream, struct read_data_t *rd)
{
CACHE_REGS
TokEntry *tokstart;
Term t, v;
Term t;
Term OCurrentModule = CurrentModule, tmod, tpos;
int store_comments = rd->comments;
@ -614,6 +614,7 @@ Yap_read_term(term_t t0, IOSTREAM *inp_stream, struct read_data_t *rd)
if (store_comments && !Yap_unify(LOCAL_Comments, Yap_GetFromSlot( rd->comments PASS_REGS)))
return FALSE;
if (rd->varnames) {
Term v;
while (TRUE) {
CELL *old_H = HR;
@ -638,6 +639,7 @@ Yap_read_term(term_t t0, IOSTREAM *inp_stream, struct read_data_t *rd)
}
if (rd->variables) {
Term v;
while (TRUE) {
CELL *old_H = HR;
@ -661,6 +663,7 @@ Yap_read_term(term_t t0, IOSTREAM *inp_stream, struct read_data_t *rd)
return FALSE;
}
if (rd->singles) {
Term v;
while (TRUE) {
CELL *old_H = HR;

View File

@ -1082,6 +1082,7 @@ Yap_Restore(char *s, char *lib_dir)
IOSTREAM *stream = Yap_OpenRestore(s, lib_dir);
if (!stream)
return -1;
__android_log_print(ANDROID_LOG_INFO, "qlyr.c", "loading startup %p", stream);
GLOBAL_RestoreFile = s;
read_module(stream);
Sclose( stream );

View File

@ -247,6 +247,22 @@ open_file(char *my_file, int flag)
{
int splfild;
#if __ANDROID__
if (strstr(my_file, "/assets/") == my_file) {
if (flag == O_RDONLY) {
extern AAssetManager *assetManager;
my_file += strlen("/assets/");
__android_log_print(ANDROID_LOG_ERROR, "save.c", "open_file %p %s", assetManager, my_file);
AAsset* asset = AAssetManager_open(assetManager, my_file, AASSET_MODE_UNKNOWN);
if (!asset)
return -1;
__android_log_print(ANDROID_LOG_ERROR, "save.c", "open_file %p", asset);
AAsset_close( asset );
return 0; // usually the file will be compressed, so there is no point in actually trying to open it.
}
return -1;
}
#endif
#ifdef M_WILLIAMS
if (flag & O_CREAT)
splfild = creat(my_file, flag);
@ -1453,6 +1469,11 @@ OpenRestore(char *inpf, char *YapLibDir, CELL *Astate, CELL *ATrail, CELL *AStac
int mode = FAIL_RESTORE;
char save_buffer[YAP_FILENAME_MAX+1];
#if __ANDROID__
if (!inpf)
inpf = YAPSTARTUP;
#endif
__android_log_print(ANDROID_LOG_ERROR, "save.c", "saved state %s", inpf);
save_buffer[0] = '\0';
// LOCAL_ErrorMessage = NULL;
if (inpf == NULL) {
@ -1473,10 +1494,13 @@ OpenRestore(char *inpf, char *YapLibDir, CELL *Astate, CELL *ATrail, CELL *AStac
strncat(LOCAL_FileNameBuf, "/", YAP_FILENAME_MAX-1);
strncat(LOCAL_FileNameBuf, inpf, YAP_FILENAME_MAX-1);
} else {
strncat(LOCAL_FileNameBuf, inpf, YAP_FILENAME_MAX-1);
strncpy(LOCAL_FileNameBuf, inpf, YAP_FILENAME_MAX-1);
}
if (inpf != NULL && !((splfild = open_file(inpf, O_RDONLY)) < 0)) {
if (inpf != NULL &&
!((splfild = open_file(inpf, O_RDONLY)) < 0))
{
if ((mode = try_open(inpf,Astate,ATrail,AStack,AHeap,save_buffer,streamp)) != FAIL_RESTORE) {
__android_log_print(ANDROID_LOG_ERROR, "save.c", "saved state %p", *streamp);
return mode;
}
}
@ -1517,7 +1541,7 @@ OpenRestore(char *inpf, char *YapLibDir, CELL *Astate, CELL *ATrail, CELL *AStac
}
#if _MSC_VER || defined(__MINGW32__)
if ((inpf = Yap_RegistryGetString("startup"))) {
if (!((splfild = open_file(inpf, O_RDONLY)) < 0)) {
if (!((splfild = Sopen_file(inpf, "r")) < 0)) {
if ((mode = try_open(inpf,Astate,ATrail,AStack,AHeap,save_buffer,streamp)) != FAIL_RESTORE) {
return mode;
}
@ -1582,6 +1606,7 @@ Yap_OpenRestore(char *inpf, char *YapLibDir)
IOSTREAM *stream = NULL;
OpenRestore(inpf, YapLibDir, NULL, NULL, NULL, NULL, &stream);
__android_log_print(ANDROID_LOG_ERROR, "save.c", "saved state %p", stream);
return stream;
}

View File

@ -90,6 +90,12 @@ Yap_ThreadID( void )
return -1;
}
int
Yap_NOfThreads(void) {
// GLOBAL_ThreadHandlesLock is held
return GLOBAL_NOfThreads;
}
static int
allocate_new_tid(void)
{
@ -1090,6 +1096,17 @@ void Yap_InitThreadPreds(void)
#else
int
Yap_NOfThreads(void) {
// GLOBAL_ThreadHandlesLock is held
#ifdef YAPOR
return 2;
#else
return 1;
#endif
}
static Int
p_no_threads(void)
{ /* '$thread_signal'(+P) */

View File

@ -1618,6 +1618,40 @@ p_term_variables( USES_REGS1 ) /* variables in term t */
return Yap_unify(ARG2,out);
}
/**
* Exports a nil-terminated list with all the variables in a term.
* @param[in] the term
* @param[in] the arity of the calling predicate (required for exact garbage collection).
*/
Term
Yap_TermVariables( Term t, UInt arity USES_REGS ) /* variables in term t */
{
Term out;
do {
t = Deref(t);
if (IsVarTerm(t)) {
return MkPairTerm(t, TermNil);
} else if (IsPrimitiveTerm(t)) {
return TermNil;
} else if (IsPairTerm(t)) {
out = vars_in_complex_term(RepPair(t)-1,
RepPair(t)+1, TermNil PASS_REGS);
}
else {
Functor f = FunctorOfTerm(t);
out = vars_in_complex_term(RepAppl(t),
RepAppl(t)+
ArityOfFunctor(f), TermNil PASS_REGS);
}
if (out == 0L) {
if (!expand_vts( arity PASS_REGS ))
return FALSE;
}
} while (out == 0L);
return out;
}
static Term attvars_in_complex_term(register CELL *pt0, register CELL *pt0_end, Term inp USES_REGS)
{

View File

@ -3,6 +3,8 @@
#include "yapi.hh"
YAPAtomTerm::YAPAtomTerm(char *s) { // build string
BACKUP_H();
@ -12,7 +14,7 @@ YAPAtomTerm::YAPAtomTerm(char *s) { // build string
inp.type = YAP_STRING_CHARS;
out.type = YAP_STRING_ATOM;
if (Yap_CVT_Text(&inp, &out PASS_REGS))
t = MkAtomTerm(out.val.a);
mk ( MkAtomTerm(out.val.a) );
else t = 0L;
RECOVER_H();
}
@ -29,7 +31,7 @@ YAPAtomTerm::YAPAtomTerm(char *s, size_t len) { // build string
out.sz = len;
out.max = len;
if (Yap_CVT_Text(&inp, &out PASS_REGS))
t = MkAtomTerm(out.val.a);
mk ( MkAtomTerm(out.val.a) );
else t = 0L;
RECOVER_H();
}
@ -43,7 +45,7 @@ YAPAtomTerm::YAPAtomTerm(wchar_t *s): YAPTerm() { // build string
inp.type = YAP_STRING_WCHARS;
out.type = YAP_STRING_ATOM;
if (Yap_CVT_Text(&inp, &out PASS_REGS))
t = MkAtomTerm(out.val.a);
mk ( MkAtomTerm(out.val.a) );
else t = 0L;
RECOVER_H();
}
@ -60,7 +62,7 @@ YAPAtomTerm::YAPAtomTerm(wchar_t *s, size_t len) : YAPTerm() { // build string
out.sz = len;
out.max = len;
if (Yap_CVT_Text(&inp, &out PASS_REGS))
t = MkAtomTerm(out.val.a);
mk ( MkAtomTerm(out.val.a) );
else t = 0L;
RECOVER_H();
}
@ -75,7 +77,7 @@ YAPStringTerm::YAPStringTerm(char *s) { // build string
inp.type = YAP_STRING_CHARS;
out.type = YAP_STRING_STRING;
if (Yap_CVT_Text(&inp, &out PASS_REGS))
t = out.val.t;
mk ( out.val.t );
else t = 0L;
RECOVER_H();
}
@ -92,7 +94,7 @@ YAPStringTerm::YAPStringTerm(char *s, size_t len) { // build string
out.sz = len;
out.max = len;
if (Yap_CVT_Text(&inp, &out PASS_REGS))
t = out.val.t;
mk ( out.val.t );
else t = 0L;
RECOVER_H();
}
@ -106,7 +108,7 @@ YAPStringTerm::YAPStringTerm(wchar_t *s): YAPTerm() { // build string
inp.type = YAP_STRING_WCHARS;
out.type = YAP_STRING_STRING;
if (Yap_CVT_Text(&inp, &out PASS_REGS))
t = out.val.t;
mk ( out.val.t );
else t = 0L;
RECOVER_H();
}
@ -123,7 +125,7 @@ YAPStringTerm::YAPStringTerm(wchar_t *s, size_t len) : YAPTerm() { // build stri
out.sz = len;
out.max = len;
if (Yap_CVT_Text(&inp, &out PASS_REGS))
t = out.val.t;
mk ( out.val.t );
else t = 0L;
RECOVER_H();
}
@ -131,25 +133,25 @@ YAPStringTerm::YAPStringTerm(wchar_t *s, size_t len) : YAPTerm() { // build stri
YAPApplTerm::YAPApplTerm(YAPFunctor f, YAPTerm ts[]) : YAPTerm() {
UInt arity = ArityOfFunctor(f.f);
t = Yap_MkApplTerm( f.f, arity, (Term *)ts);
mk ( Yap_MkApplTerm( f.f, arity, (Term *)ts) );
}
YAPApplTerm::YAPApplTerm(YAPFunctor f) : YAPTerm() {
UInt arity = ArityOfFunctor(f.f);
t = Yap_MkNewApplTerm( f.f, arity);
mk ( Yap_MkNewApplTerm( f.f, arity) );
}
YAPTerm YAPApplTerm::getArg(unsigned int arg) {
return YAPTerm( ArgOfTerm(arg, t) );
YAPTerm YAPApplTerm::getArg(int arg) {
return YAPTerm( ArgOfTerm(arg, gt() ) );
}
YAPFunctor YAPApplTerm::getFunctor() {
return YAPFunctor( FunctorOfTerm(t) );
return YAPFunctor( FunctorOfTerm( gt( )) );
}
YAPPairTerm::YAPPairTerm(YAPTerm th, YAPTerm tl) : YAPTerm() {
CACHE_REGS
t = MkPairTerm( th.t, tl.t);
mk ( MkPairTerm( th.term(), tl.term() ) );
}
YAPPairTerm::YAPPairTerm() : YAPTerm() {
@ -157,8 +159,9 @@ YAPPairTerm::YAPPairTerm() : YAPTerm() {
}
YAP_tag_t YAPTerm::tag() {
if (IsVarTerm(t)) {
CELL *pt = VarOfTerm(t);
Term tt = gt( );
if (IsVarTerm(tt)) {
CELL *pt = VarOfTerm(tt);
if (IsUnboundVar(pt)) {
CACHE_REGS
if (IsAttVar(pt))
@ -167,14 +170,14 @@ YAP_tag_t YAPTerm::tag() {
}
return YAP_TAG_REF;
}
if (IsPairTerm(t))
if (IsPairTerm(tt))
return YAP_TAG_PAIR;
if (IsAtomOrIntTerm(t)) {
if (IsAtomTerm(t))
if (IsAtomOrIntTerm(tt)) {
if (IsAtomTerm(tt))
return YAP_TAG_ATOM;
return YAP_TAG_INT;
} else {
Functor f = FunctorOfTerm(t);
Functor f = FunctorOfTerm(tt);
if (IsExtensionFunctor(f)) {
if (f == FunctorDBRef) {
@ -184,7 +187,7 @@ YAP_tag_t YAPTerm::tag() {
return YAP_TAG_LONG_INT;
}
if (f == FunctorBigInt) {
big_blob_type bt = (big_blob_type)RepAppl(t)[1];
big_blob_type bt = (big_blob_type)RepAppl(tt)[1];
switch (bt) {
case BIG_INT:
return YAP_TAG_BIG_INT;
@ -203,7 +206,7 @@ YAPTerm YAPTerm::deepCopy() {
Term tn;
BACKUP_MACHINE_REGS();
tn = Yap_CopyTerm(t);
tn = Yap_CopyTerm( gt() );
RECOVER_MACHINE_REGS();
return new YAPTerm( tn );
@ -213,7 +216,7 @@ bool YAPTerm::exactlyEqual(YAPTerm t1) {
int out;
BACKUP_MACHINE_REGS();
out = Yap_eq(Deref(t), Deref(t1.t));
out = Yap_eq(gt(), t1.term());
RECOVER_MACHINE_REGS();
return out;
@ -223,7 +226,7 @@ bool YAPTerm::unify(YAPTerm t1) {
int out;
BACKUP_MACHINE_REGS();
out = Yap_unify(Deref(t), Deref(t1.t));
out = Yap_unify(gt(), t1.term());
RECOVER_MACHINE_REGS();
return out;
@ -233,7 +236,7 @@ bool YAPTerm::unifiable(YAPTerm t1) {
int out;
BACKUP_MACHINE_REGS();
out = Yap_Unifiable(Deref(t), Deref(t1.t));
out = Yap_Unifiable(gt(), t1.term());
RECOVER_MACHINE_REGS();
return out;
@ -243,23 +246,57 @@ bool YAPTerm::variant(YAPTerm t1) {
int out;
BACKUP_MACHINE_REGS();
out = Yap_Variant(Deref(t), Deref(t1.t));
out = Yap_Variant(gt(), t1.term());
RECOVER_MACHINE_REGS();
return out;
}
intptr_t YAPTerm::hash(size_t sz, size_t depth, bool variant) {
Int out;
intptr_t out;
BACKUP_MACHINE_REGS();
out = Yap_TermHash(t, sz, depth, variant);
out = Yap_TermHash(gt(), sz, depth, variant) ;
RECOVER_MACHINE_REGS();
return out;
}
char *YAPTerm::text(void) {
size_t sze = 4096, sz, length;
char *buf = new char[sze], *b;
int enc;
BACKUP_MACHINE_REGS();
if ((b = Yap_TermToString(gt(), buf, sze, &length, &enc, 0)) != buf) {
if (b) free(b);
RECOVER_MACHINE_REGS();
return NULL;
}
sz = length+1;
char *os = new char[sz];
if (!os) {
RECOVER_MACHINE_REGS();
return NULL;
}
memcpy(os, buf, sz);
delete buf;
RECOVER_MACHINE_REGS();
return os;
}
/*
YAPTerm *YAPTerm::vars()
{
BACKUP_MACHINE_REGS();
CACHE_REGS
YAPPairTerm lv = YAPPairTerm(Yap_TermVariables(gt(), 0 PASS_REGS));
RECOVER_MACHINE_REGS();
return lv;
}
*/
char *YAPAtom::name(void) {
if (IsWideAtom(a)) {
@ -312,8 +349,27 @@ char *YAPAtom::name(void) {
}
YAPPredicate::YAPPredicate(const char *s, Term **outp, term_t &vnames) {
CACHE_REGS
vnames = Yap_NewSlots(1 PASS_REGS);
Term t = Yap_StringToTerm(s, strlen(s)+1, vnames), m;
t = Yap_StripModule(t, &m);
if (IsVarTerm(t) || IsNumTerm(t))
ap = NULL;
if (IsAtomTerm(t)) {
ap = RepPredProp(PredPropByAtom(AtomOfTerm(t), m));
*outp = NULL;
} else if (IsApplTerm(t)) {
ap = RepPredProp(PredPropByFunc(FunctorOfTerm(t), m));
*outp = RepAppl(t)+1;
} else if (IsPairTerm(t)) {
ap = RepPredProp(PredPropByFunc(FunctorOfTerm(t), m));
*outp = RepPair(t);
}
}
void
YAPQuery::initQuery( Term *t )
YAPQuery::initQuery( Term *ts )
{
CACHE_REGS
@ -322,35 +378,37 @@ YAPQuery::initQuery( Term *t )
this->q_open=1;
this->q_state=0;
this->q_flags = 0;
this->q_g = t;
this->q_g = ts;
}
void
YAPQuery::initQuery( YAPTerm t[], arity_t arity )
{
Term *ts = new Term[arity];
for (int i = 0; i < arity; i++)
ts[i] = t[i].term();
return initQuery( ts );
}
YAPQuery::YAPQuery(YAPFunctor f, YAPTerm mod, YAPTerm t[]): YAPPredicate(f, mod)
{
/* ignore flags for now */
initQuery( (Term *)t );
initQuery( t , f.arity());
}
YAPQuery::YAPQuery(YAPFunctor f, YAPTerm t[]): YAPPredicate(f)
{
/* ignore flags for now */
initQuery( (Term *)t );
initQuery( t , f.arity());
}
YAPQuery::YAPQuery(YAPPredicate p, YAPTerm t[]): YAPPredicate(p.ap)
{
initQuery( (Term *)t );
initQuery( t , p.ap->ArityOfPE);
}
YAPQuery::YAPQuery(char *s): YAPPredicate(s, &this->q_g)
{
Term *t = this->q_g;
initQuery( t );
}
int YAPQuery::next()
{
CACHE_REGS
@ -412,3 +470,10 @@ YAPEngine::YAPEngine(YAPParams const& params)
{ YAP_Init( (YAP_init_args *)&params.init_args ); }
YAPEngine::YAPEngine()
{
YAPParams *params = new YAPParams();
YAP_Init( &params->init_args );
}

View File

@ -63,6 +63,8 @@ extern "C" {
// taken from yap_structs.h
#include "iopreds.h"
extern Term Yap_StringToTerm(const char *s, size_t len, term_t bindings);
// we cannot consult YapInterface.h, that conflicts with what we declare, though
// it shouldn't
}
@ -73,6 +75,8 @@ class YAPEngine;
class YAPTermHandle;
class YAPAtom;
class YAPFunctor;
class YAPApplTerm;
class YAPPairTerm;
class YAPQuery;
/**
@ -84,62 +88,89 @@ class YAPTerm {
friend class YAPApplTerm;
friend class YAPPairTerm;
protected:
Term t;
term_t t;
inline void mk(Term t0) { CACHE_REGS t = Yap_InitSlot( t0 PASS_REGS); }
inline Term gt(void) { CACHE_REGS return Yap_GetFromSlot( t PASS_REGS); }
public:
YAPTerm() { t = TermNil; } // do nothing constructor
YAPTerm(void *ptr) { CACHE_REGS t = MkIntegerTerm( (Int)ptr ); }
YAPTerm(Term tn) { t = tn; }
YAPTerm(char *s) { Term tp ; t = YAP_ReadBuffer(s,&tp); }
YAPTerm() { mk(TermNil); } // do nothing constructor
YAPTerm(void *ptr) { CACHE_REGS mk( MkIntegerTerm( (Int)ptr ) );}
YAPTerm(Term tn) { mk( tn ); }
YAPTerm(char *s) { Term tp ; mk( YAP_ReadBuffer(s,&tp) ); }
/*~YAPTerm(void) {
CACHE_REGS
Yap_RecoverSlots(1, t PASS_REGS);
}*/
Term term() { return gt(); }
YAP_tag_t tag();
YAPTerm deepCopy();
//const YAPTerm *vars();
bool exactlyEqual(YAPTerm t1);
bool unify(YAPTerm t1);
bool unifiable(YAPTerm t1);
bool variant(YAPTerm t1);
intptr_t hash(size_t sz, size_t depth, bool variant);
bool isVar() { return IsVarTerm(t); }
bool isAtom() { return IsAtomTerm(t); }
bool isInteger() { return IsIntegerTerm(t); }
bool isFloat() { return IsFloatTerm(t); }
bool isCompound() { return !(IsVarTerm(t) || IsNumTerm(t)); }
bool isAppl() { return IsApplTerm(t); }
bool isPair() { return IsPairTerm(t); }
bool isGround() { return Yap_IsGroundTerm(t); }
bool isList() { return Yap_IsListTerm(t); }
bool isString() { return IsStringTerm(t); }
bool isVar() { return IsVarTerm( gt() ); }
bool isAtom() { return IsAtomTerm( gt() ); }
bool isInteger() { return IsIntegerTerm( gt() ); }
bool isFloat() { return IsFloatTerm( gt() ); }
bool isCompound() { return !(IsVarTerm( gt() ) || IsNumTerm( gt() )); }
bool isAppl() { return IsApplTerm( gt() ); }
bool isPair() { return IsPairTerm( gt() ); }
bool isGround() { return Yap_IsGroundTerm( gt() ); }
bool isList() { return Yap_IsListTerm( gt() ); }
bool isString() { return IsStringTerm( gt() ); }
inline YAPTerm getArg(int i) {
Term t0 = gt();
if (IsApplTerm(t0))
return YAPTerm(ArgOfTerm(i, t0));
else if (IsPairTerm(t0)) {
if (i==1)
return YAPTerm(HeadOfTerm(t0));
if (i==2)
return YAPTerm(TailOfTerm(t0));
}
return YAPTerm((Term)0);
}
char *text();
};
/**
* @brief Variable Term
*/
class YAPVarTerm: private YAPTerm {
YAPVarTerm(Term t) { if (IsVarTerm(t)) mk( t ); }
public:
YAPVarTerm(): YAPTerm() { CACHE_REGS t = MkVarTerm(); }
CELL *getVar() { return VarOfTerm(t); }
bool unbound() { return IsUnboundVar(VarOfTerm(t)); }
YAPVarTerm() { CACHE_REGS mk( MkVarTerm( ) ); }
CELL *getVar() { return VarOfTerm( gt() ); }
bool unbound() { return IsUnboundVar(VarOfTerm( gt() )); }
};
/**
* @brief Compound Term
*/
class YAPApplTerm: private YAPTerm {
friend class YAPTerm;
YAPApplTerm(Term t0) { mk(t0); }
public:
YAPApplTerm(YAPTerm t0) { mk(t0.term()); }
YAPApplTerm(YAPFunctor f, YAPTerm ts[]);
YAPApplTerm(YAPFunctor f);
YAPFunctor getFunctor();
YAPTerm getArg(unsigned int i);
YAPTerm getArg(int i);
};
/**
* @brief List Constructor Term
*/
class YAPPairTerm: private YAPTerm {
friend class YAPTerm;
YAPPairTerm(Term t0) { if (IsPairTerm(t0)) mk( t0 ); else mk(0); }
public:
YAPPairTerm(YAPTerm hd, YAPTerm tl);
YAPPairTerm();
YAPTerm getHead() { return YAPTerm(HeadOfTerm(t)); }
YAPTerm getTail() { return YAPTerm(TailOfTerm(t)); }
YAPTerm getHead() { return YAPTerm(HeadOfTerm( gt() )); }
YAPTerm getTail() { return YAPTerm(TailOfTerm( gt() )); }
};
/**
@ -148,21 +179,39 @@ public:
class YAPIntegerTerm: private YAPTerm {
public:
YAPIntegerTerm(intptr_t i) { CACHE_REGS t = MkIntegerTerm( i ); }
intptr_t getInteger(YAPIntegerTerm t) { return IntegerOfTerm(t.t); }
bool isTagged(YAPIntegerTerm i) { return IsIntTerm( t ); }
YAPIntegerTerm(intptr_t i) { CACHE_REGS Term tn = MkIntegerTerm( i ); mk( tn ); }
intptr_t getInteger() { return IntegerOfTerm( gt() ); }
bool isTagged() { return IsIntTerm( gt() ); }
};
/*
class YAPListTerm: private YAPPairTerm {
class YAPListTerm: private YAPTerm {
public:
YAPListTerm(YAPTerm ts[], size_t n);
YAPListTerm(Term ts[], size_t n);
YAPListTerm( vector<YAPTerm> v );
size_t length() { Term *tailp; return Yap_SkipList(&t, &tailp); }
vector<YAPTerm> toVector();
/// Create a list term out of a standard term. Check if a valid operation.
///
/// @param[in] the term
YAPListTerm(Term t0) { mk(t0); /* else type_error */ }
/* /// Create a list term out of an array of terms.
///
/// @param[in] the array of terms
/// @param[in] the length of the array
YAPListTerm(YAPTerm ts[], size_t n);
/// Create a list term out of an array of Prolog terms.
///
/// @param[in] the array of terms
/// @param[in] the length of the array
YAPListTerm(Term ts[], size_t n);
*/
// YAPListTerm( vector<YAPTerm> v );
/// Return the number of elements in a list term.
size_t length() { Term *tailp; Term t1 = gt(); return Yap_SkipList(&t1, &tailp); }
// vector<YAPTerm> toVector();
/// Create an array of term out of a list.
///
/// @param[in] the list
YAPTerm car() { if (IsPairTerm(gt())) return YAPTerm(HeadOfTerm(gt())); else return YAPTerm((term_t)0); }
YAPListTerm cdr() { if (IsPairTerm(gt())) return YAPListTerm(TailOfTerm(gt())); else return YAPListTerm((term_t)0); }
bool nil() { return gt() == TermNil; }
};
*/
/**
* @brief Atom
@ -190,7 +239,7 @@ public:
YAPStringTerm(char *s, size_t len);
YAPStringTerm(wchar_t *s) ;
YAPStringTerm(wchar_t *s, size_t len);
const char *getString() { return StringOfTerm(t); }
const char *getString() { return StringOfTerm( gt() ); }
};
/**
@ -198,13 +247,13 @@ public:
*/
class YAPAtomTerm: private YAPTerm {
public:
YAPAtomTerm(YAPAtom a): YAPTerm() { t = MkAtomTerm(a.a); }
YAPAtomTerm(Atom a): YAPTerm() { t = MkAtomTerm(a); }
YAPAtomTerm(YAPAtom a): YAPTerm() { mk( MkAtomTerm(a.a) ); }
YAPAtomTerm(Atom a): YAPTerm() { mk( MkAtomTerm(a) ); }
YAPAtomTerm(char *s) ;
YAPAtomTerm(char *s, size_t len);
YAPAtomTerm(wchar_t *s) ;
YAPAtomTerm(wchar_t *s, size_t len);
YAPAtom getAtom() { return YAPAtom(AtomOfTerm(t)); }
YAPAtom getAtom() { return YAPAtom(AtomOfTerm( gt() )); }
};
/**
@ -215,16 +264,16 @@ class YAPFunctor {
friend class YAPPredicate;
Functor f;
public:
YAPFunctor( char * s, unsigned int arity) { f = Yap_MkFunctor( Yap_LookupAtom( s ), arity ); }
YAPFunctor( wchar_t * s, unsigned int arity) { f = Yap_MkFunctor( Yap_LookupWideAtom( s ), arity ); }
YAPFunctor( YAPAtom at, unsigned int arity) { f = Yap_MkFunctor( at.a, arity ); }
YAPFunctor( char * s, arity_t arity) { f = Yap_MkFunctor( Yap_LookupAtom( s ), arity ); }
YAPFunctor( wchar_t * s, arity_t arity) { f = Yap_MkFunctor( Yap_LookupWideAtom( s ), arity ); }
YAPFunctor( YAPAtom at, arity_t arity) { f = Yap_MkFunctor( at.a, arity ); }
YAPFunctor( Functor ff) { f = ff; }
Atom name(void) {
return NameOfFunctor( f );
}
unsigned int arity(void) {
arity_t arity(void) {
return ArityOfFunctor( f );
}
};
@ -239,15 +288,6 @@ public:
CACHE_REGS
handle = Yap_InitSlot(t PASS_REGS);
}
~YAPTermHandle(void) {
CACHE_REGS
Yap_RecoverSlots(1, handle PASS_REGS);
}
YAPTerm get() {
CACHE_REGS
return new YAPTerm( Yap_GetFromSlot(handle PASS_REGS) );
}
void set(YAPTerm t) {
CACHE_REGS
@ -262,42 +302,42 @@ class YAPPredicate {
friend class YAPQuery;
PredEntry *ap;
// trick to communicate t[] back to yapquery
YAPPredicate(char *s, Term **th) {
YAPPredicate(const char *s, Term **outp, term_t& vnames );
inline YAPPredicate(Term t) {
CACHE_REGS
Term t, tp, m = CurrentModule ;
t = YAP_ReadBuffer(s,&tp);
Term m = CurrentModule ;
t = Yap_StripModule(t, &m);
if (IsVarTerm(t) || IsNumTerm(t))
ap = NULL;
if (IsAtomTerm(t)) {
ap = RepPredProp(PredPropByAtom(AtomOfTerm(t), m));
*th = NULL;
} else if (IsApplTerm(t)) {
ap = RepPredProp(PredPropByFunc(FunctorOfTerm(t), m));
*th = RepAppl(t)+1;
} else if (IsPairTerm(t)) {
ap = RepPredProp(PredPropByFunc(FunctorCsult, PROLOG_MODULE));
} else {
ap = NULL;
}
}
public:
YAPPredicate(PredEntry *pe) {
inline YAPPredicate(PredEntry *pe) {
ap = pe;
}
YAPPredicate(YAPFunctor f) {
public:
inline YAPPredicate(YAPFunctor f) {
CACHE_REGS
ap = RepPredProp(PredPropByFunc(f.f,CurrentModule));
}
YAPPredicate(YAPFunctor f, YAPTerm mod) {
inline YAPPredicate(YAPFunctor f, YAPTerm mod) {
ap = RepPredProp(PredPropByFunc(f.f,mod.t));
}
YAPPredicate(YAPAtom at, YAPTerm mod) {
inline YAPPredicate(YAPAtom at, YAPTerm mod) {
ap = RepPredProp(PredPropByAtom(at.a,mod.t));
}
YAPPredicate(YAPAtom at) {
inline YAPPredicate(YAPAtom at) {
CACHE_REGS
ap = RepPredProp(PredPropByAtom(at.a,CurrentModule));
}
YAPPredicate(YAPAtom at, unsigned int arity, YAPTerm mod) {
inline YAPPredicate(YAPAtom at, arity_t arity, YAPTerm mod) {
if (arity) {
Functor f = Yap_MkFunctor(at.a, arity);
ap = RepPredProp(PredPropByFunc(f,mod.t));
@ -305,7 +345,7 @@ public:
ap = RepPredProp(PredPropByAtom(at.a,mod.t));
}
}
YAPPredicate(YAPAtom at, unsigned int arity) {
inline YAPPredicate(YAPAtom at, arity_t arity) {
CACHE_REGS
if (arity) {
Functor f = Yap_MkFunctor(at.a, arity);
@ -314,7 +354,7 @@ public:
ap = RepPredProp(PredPropByAtom(at.a,CurrentModule));
}
}
YAPPredicate(char *s) {
inline YAPPredicate(char *s) {
CACHE_REGS
Term t, tp, m = CurrentModule ;
t = YAP_ReadBuffer(s,&tp);
@ -327,37 +367,102 @@ public:
ap = RepPredProp(PredPropByFunc(FunctorOfTerm(t), m));
}
}
inline YAPPredicate(char *s, Term **outp) {
CACHE_REGS
Term t, tp, m = CurrentModule ;
t = YAP_ReadBuffer(s,&tp);
t = Yap_StripModule(t, &m);
if (IsVarTerm(t) || IsNumTerm(t))
ap = NULL;
if (IsAtomTerm(t)) {
ap = RepPredProp(PredPropByAtom(AtomOfTerm(t), m));
*outp = NULL;
} else if (IsApplTerm(t)) {
ap = RepPredProp(PredPropByFunc(FunctorOfTerm(t), m));
*outp = RepAppl(t)+1;
} else if (IsPairTerm(t)) {
ap = RepPredProp(PredPropByFunc(FunctorOfTerm(t), m));
*outp = RepPair(t);
}
}
int call(YAPTerm ts[]);
arity_t arity() { return ap->ArityOfPE; }
/// module of predicate
///
/// notice that modules are currently treated as atoms, this should change.
YAPAtom module() { if (ap->ModuleOfPred == PROLOG_MODULE)
return YAPAtom(AtomProlog);
else
return YAPAtom(AtomOfTerm(ap->ModuleOfPred)); }
/// name of predicate
///
/// notice that we return the atom, not a string.
YAPAtom name() { if (ap->ArityOfPE)
return YAPAtom((Atom)ap->FunctorOfPred);
else
return YAPAtom(NameOfFunctor(ap->FunctorOfPred));
}
};
/**
* @brief Term Handle
* @brief Queries
*
* interface to a YAP Query;
* uses an SWI-like status info internally.
*/
class YAPQuery: private YAPPredicate {
int q_open;
int q_state;
Term *q_g;
yamop *q_p, *q_cp;
jmp_buf q_env;
int q_flags;
YAP_dogoalinfo q_h;
YAPQuery *oq;
void initQuery( Term *t );
int q_open;
int q_state;
Term *q_g;
yamop *q_p, *q_cp;
jmp_buf q_env;
int q_flags;
YAP_dogoalinfo q_h;
YAPQuery *oq;
term_t vnames;
void initQuery( Term ts[] );
void initQuery( YAPTerm t[], arity_t arity );
public:
/// full constructor, is given a functor, module, and an array of terms that must hav at least
/// the same arity as the functor.
YAPQuery(YAPFunctor f, YAPTerm mod, YAPTerm t[]);
YAPQuery(YAPFunctor f, YAPTerm t[]);
YAPQuery(YAPPredicate p, YAPTerm t[]);
YAPQuery(char *s);
// YAPQuery(YAPTerm t);
int next();
void cut();
void close();
};
/// main constructor, uses a predicate and an array of terms
///
/// It is given a YAPPredicate _p_ , and an array of terms that must have at least
/// the same arity as the functor.
YAPQuery(YAPPredicate p, YAPTerm t[]);
/// full constructor,
///
/// It is given a functor, module, and an array of terms that must have at least
/// the same arity as the functor.
YAPQuery(YAPFunctor f, YAPTerm mod, YAPTerm t[]);
/// functor/term constructor,
///
/// It is given a functor, and an array of terms that must have at least
/// the same arity as the functor. Works within the current module.
YAPQuery(YAPFunctor f, YAPTerm t[]);
/// string constructor with varnames
///
/// It is given a string, calls the parser and obtains a Prolog term that should be a callable
/// goal and a list of variables. Useful for top-level simulation. Works within the current module.
inline YAPQuery(char *s): YAPPredicate(s, &this->q_g, vnames)
{
Term *ts = this->q_g;
initQuery( ts );
}
/// first query
///
/// actually implemented by calling the next();
inline int first() { return next(); }
/// ask for the next solution of the current query
/// same call for every solution
int next();
/// remove alternatives in the current search space, and finish the current query
void cut();
/// finish the current query: undo all bindings.
void close();
/// query variables.
YAPListTerm namedVars() { CACHE_REGS Term o = Yap_GetFromSlot( vnames PASS_REGS ); return YAPListTerm( o ); }
};
class YAPParams;
@ -368,6 +473,7 @@ class YAPParams;
class YAPEngine {
public:
YAPEngine(YAPParams const& params); /// construct a new engine
YAPEngine(); /// construct a new engine, no arguments
YAPQuery *query( char *s ) { return new YAPQuery( s ); } /// build a query on the engine
};

View File

@ -107,6 +107,7 @@ typedef struct PropEntryStruct
#define MaxArity 255
typedef CELL arity_t;
#define FunctorProperty ((PropFlags)(0xbb00))
@ -115,7 +116,7 @@ typedef struct FunctorEntryStruct
{
Prop NextOfPE; /* used to chain properties */
PropFlags KindOfPE; /* kind of property */
unsigned int ArityOfFE; /* arity of functor */
arity_t ArityOfFE; /* arity of functor */
Atom NameOfFE; /* back pointer to owner atom */
Prop PropsOfFE; /* pointer to list of properties for this functor */
#if defined(YAPOR) || defined(THREADS)

10
H/Yap.h
View File

@ -445,6 +445,16 @@ extern ADDR Yap_HeapBase;
#ifdef DEBUG
extern int Yap_output_msg;
#endif
#if __ANDROID__
#include <android/asset_manager.h>
#include <android/asset_manager_jni.h>
#include <android/log.h>
#else
inline void __android_log_print(int i, char *loc, char *msg, ...) {}
#define ANDROID_LOG_INFO 0
#define ANDROID_LOG_ERROR 0
#define ANDROID_LOG_DEBUG 0
#endif
/*************************************************************************************************
variables concerned with atoms table

View File

@ -387,6 +387,7 @@ void Yap_WinError(char *);
void Yap_InitThreadPreds(void);
void Yap_InitFirstWorkerThreadHandle(void);
int Yap_ThreadID( void );
int Yap_NOfThreads( void );
#if THREADS
int Yap_InitThread(int);
#endif
@ -427,6 +428,7 @@ int Yap_IsAcyclicTerm(Term);
void Yap_InitUtilCPreds(void);
Int Yap_TermHash(Term, Int, Int, int);
Int Yap_NumberVars(Term, Int, int);
Term Yap_TermVariables( Term t, UInt arity USES_REGS );
Term Yap_UnNumberTerm(Term, int);
Int Yap_SkipList(Term *, Term **);
/* yap.c */

View File

@ -251,4 +251,6 @@ atom_t ATOM_;
intptr_t system_thread_id(PL_thread_info_t *info);
#endif
extern Term Yap_StringToTerm(const char *s, size_t len, term_t bindings);
#endif /* PL_YAP_H */

View File

@ -266,7 +266,6 @@ int Yap_PlFGetchar(void);
int Yap_GetCharForSIGINT(void);
Int Yap_StreamToFileNo(Term);
Term Yap_OpenStream(FILE *,char *,Term,int);
Term Yap_StringToTerm(char *,Term *);
char *Yap_TermToString(Term t, char *s, size_t sz, size_t *length, int *encoding, int flags);
int Yap_GetFreeStreamD(void);
int Yap_GetFreeStreamDForReading(void);

View File

@ -52,7 +52,7 @@ DOCSDIR=$(SHAREDIR)/doc/Yap
#
YAP_EXTRAS=@YAP_EXTRAS@
YAPSTARTUP=startup.yss
YAPSTARTUP=@SAVED_STATE_PREFIX@startup.yss
#
# Please do not add YAP_EXTRA flags here: if you do check the flags
@ -108,6 +108,7 @@ VPATH=@srcdir@
CWD=$(PWD)
#
VERSION=@YAP_VERSION@
Y=@YAP_MAJOR_VERSION@
DOC_VERSION=@DOC_VERSION@
MYDDAS_VERSION=@MYDDAS_VERSION@
#
@ -451,6 +452,9 @@ clause_list.o: C/clause_list.c include/clause_list.h config.h
udi.o: C/udi.c config.h
$(CC) -c $(C_INTERF_FLAGS) $< -o $@
save.o: C/save.c
$(CC) -c $(C_INTERF_FLAGS) -DYAPSTARTUP=\"$(YAPSTARTUP)\" $< -o $@
%.o: C/%.c config.h
$(CC) -c $(CFLAGS) $< -o $@
@ -590,27 +594,26 @@ libYap.a: $(LIB_OBJECTS)
$(LN_S) -f @DYNYAPLIB@ $$p; \
done
@STARTUP_ANDROID@startup.yss: yap@EXEC_SUFFIX@ $(PL_SOURCES) $(SWI_LIB_SOURCES)
@STARTUP_ANDROID@startup.yss: yap@EXEC_SUFFIX@ @DYNYAPLIB@ $(PL_SOURCES) $(SWI_LIB_SOURCES) install_unix
adb shell mkdir -p /data/yap
adb shell mkdir -p /data/yap/pl
adb shell mkdir -p /data/yap/swi/library
adb push yap /data/yap/
adb push libYap.so.? /data/yap/
adb push @DYNYAPLIB@ /data/yap/
adb push $(srcdir)/swi/library /data/yap/swi/library
adb push $(srcdir)/pl /data/yap/pl/
adb shell "echo \"bootstrap('/data/yap/pl/init.yap'). module(user). qsave_program('/data/yap/startup.yss').\" | LD_LIBRARY_PATH=/data/yap /data/yap/yap@EXEC_SUFFIX@ -b /data/yap/pl/boot.yap"
adb pull /data/yap/startup.yss .
adb pull /data/yap/startup.yss
install: @INSTALL_COMMAND@ install_common
install: @INSTALL_COMMAND@ install_startup install_common
install_unix: startup.yss @YAPLIB@
install_unix: @YAPLIB@ yap@EXEC_SUFFIX@
mkdir -p $(DESTDIR)$(BINDIR)
mkdir -p $(DESTDIR)$(YAPLIBDIR)
mkdir -p $(DESTDIR)$(SHAREDIR)
mkdir -p $(DESTDIR)$(SHAREDIR)/Yap
mkdir -p $(DESTDIR)$(SHAREDIR)/Yap/icons
$(INSTALL_PROGRAM) -m 755 yap@EXEC_SUFFIX@ $(DESTDIR)$(BINDIR)/yap
$(INSTALL_DATA) startup.yss $(DESTDIR)$(YAPLIBDIR)/startup.yss
$(INSTALL_DATA) -m 755 @YAPLIB@ $(DESTDIR)$(LIBDIR)
install_startup: startup.yss
@ -626,10 +629,12 @@ install_win32: startup.yss @WINDOWS@ yap-win@EXEC_SUFFIX@
@WINDOWS@ $(INSTALL_PROGRAM) -m 755 yap-win.exe $(DESTDIR)$(BINDIR)/yap-win.exe
@WINDOWS@ $(INSTALL_PROGRAM) -m 755 yap.exe $(DESTDIR)$(BINDIR)/yap.exe
@WINDOWS@ for i in *.dll; do $(INSTALL_PROGRAM) -m 755 $$i $(DESTDIR)$(BINDIR)/; done
$(INSTALL_DATA) startup.yss $(DESTDIR)$(YAPLIBDIR)/startup.yss
$(INSTALL_DATA) $(srcdir)/misc/icons/yap.ico $(DESTDIR)$(SHAREDIR)/Yap/icons/yap.ico
install_common:
install_common: install_startup
mkdir -p $(DESTDIR)$(YAPLIBDIR)
mkdir -p $(DESTDIR)$(SHAREDIR)
mkdir -p $(DESTDIR)$(SHAREDIR)/Yap
mkdir -p $(DESTDIR)$(SHAREDIR)/PrologCommons
mkdir -p $(DESTDIR)$(SHAREDIR)/Yap/pl
mkdir -p $(DESTDIR)$(DOCSDIR)

View File

@ -324,6 +324,9 @@
/* Define to 1 if you have the `lgamma' function. */
#undef HAVE_LGAMMA
/* Define to 1 if you have the `android' library (-landroid). */
#undef HAVE_LIBANDROID
/* Define to 1 if you have the `comdlg32' library (-lcomdlg32). */
#undef HAVE_LIBCOMDLG32
@ -339,6 +342,9 @@
/* Define to 1 if you have the <LibLoaderAPI.h> header file. */
#undef HAVE_LIBLOADERAPI_H
/* Define to 1 if you have the `log' library (-llog). */
#undef HAVE_LIBLOG
/* Define to 1 if you have the `m' library (-lm). */
#undef HAVE_LIBM

846
configure vendored
View File

@ -708,6 +708,7 @@ IN_SWI
IN_YAP
PROLOG_SYSTEM
M4GENABSMI
SAVED_STATE_PREFIX
INSTALL_PRISM
PKG_REAL
PKG_MINISAT
@ -760,8 +761,6 @@ M4
PRE_INSTALL_ENV
INSTALL_ENV
PKG_PRISM
EGREP
GREP
INDENT
INSTALL_INFO
AR
@ -770,6 +769,8 @@ INSTALL_DATA
INSTALL_SCRIPT
INSTALL_PROGRAM
LN_S
EGREP
GREP
SED
target_os
target_vendor
@ -1782,6 +1783,125 @@ fi
} # ac_fn_cxx_try_compile
# ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES
# ---------------------------------------------
# Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR
# accordingly.
ac_fn_c_check_decl ()
{
as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
as_decl_name=`echo $2|sed 's/ *(.*//'`
as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'`
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5
$as_echo_n "checking whether $as_decl_name is declared... " >&6; }
if eval \${$3+:} false; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
$4
int
main ()
{
#ifndef $as_decl_name
#ifdef __cplusplus
(void) $as_decl_use;
#else
(void) $as_decl_name;
#endif
#endif
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
eval "$3=yes"
else
eval "$3=no"
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
eval ac_res=\$$3
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
} # ac_fn_c_check_decl
# ac_fn_c_try_run LINENO
# ----------------------
# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes
# that executables *can* be run.
ac_fn_c_try_run ()
{
as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
if { { ac_try="$ac_link"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
$as_echo "$ac_try_echo"; } >&5
(eval "$ac_link") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; } && { ac_try='./conftest$ac_exeext'
{ { case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
$as_echo "$ac_try_echo"; } >&5
(eval "$ac_try") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; }; then :
ac_retval=0
else
$as_echo "$as_me: program exited with status $ac_status" >&5
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_retval=$ac_status
fi
rm -rf conftest.dSYM conftest_ipa8_conftest.oo
eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
as_fn_set_status $ac_retval
} # ac_fn_c_try_run
# ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES
# -------------------------------------------------------
# Tests whether HEADER exists and can be compiled using the include files in
# INCLUDES, setting the cache variable VAR accordingly.
ac_fn_c_check_header_compile ()
{
as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
$as_echo_n "checking for $2... " >&6; }
if eval \${$3+:} false; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
$4
#include <$2>
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
eval "$3=yes"
else
eval "$3=no"
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
eval ac_res=\$$3
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
} # ac_fn_c_check_header_compile
# ac_fn_c_try_link LINENO
# -----------------------
# Try to link conftest.$ac_ext, and return whether this succeeded.
@ -1882,79 +2002,6 @@ $as_echo "$ac_res" >&6; }
} # ac_fn_c_check_type
# ac_fn_c_try_run LINENO
# ----------------------
# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes
# that executables *can* be run.
ac_fn_c_try_run ()
{
as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
if { { ac_try="$ac_link"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
$as_echo "$ac_try_echo"; } >&5
(eval "$ac_link") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; } && { ac_try='./conftest$ac_exeext'
{ { case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
$as_echo "$ac_try_echo"; } >&5
(eval "$ac_try") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; }; then :
ac_retval=0
else
$as_echo "$as_me: program exited with status $ac_status" >&5
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_retval=$ac_status
fi
rm -rf conftest.dSYM conftest_ipa8_conftest.oo
eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
as_fn_set_status $ac_retval
} # ac_fn_c_try_run
# ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES
# -------------------------------------------------------
# Tests whether HEADER exists and can be compiled using the include files in
# INCLUDES, setting the cache variable VAR accordingly.
ac_fn_c_check_header_compile ()
{
as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
$as_echo_n "checking for $2... " >&6; }
if eval \${$3+:} false; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
$4
#include <$2>
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
eval "$3=yes"
else
eval "$3=no"
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
eval ac_res=\$$3
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
} # ac_fn_c_check_header_compile
# ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES
# -------------------------------------------------------
# Tests whether HEADER exists, giving a warning if it cannot be compiled using
@ -2715,8 +2762,6 @@ if test "${with_sysroot+set}" = set; then :
CFLAGS="$CFLAGS --sysroot=$SYSROOT"
CPPFLAGS="$CPPFLAGS --sysroot=$SYSROOT"
LDFLAGS="$LDFLAGS --sysroot=$SYSROOT"
else
yap_cv_gmp=yes
fi
@ -4807,6 +4852,275 @@ else
STATIC_MODE="# "
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5
$as_echo_n "checking for grep that handles long lines and -e... " >&6; }
if ${ac_cv_path_GREP+:} false; then :
$as_echo_n "(cached) " >&6
else
if test -z "$GREP"; then
ac_path_GREP_found=false
# Loop through the user's path and test for each of PROGNAME-LIST
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_prog in grep ggrep; do
for ac_exec_ext in '' $ac_executable_extensions; do
ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext"
as_fn_executable_p "$ac_path_GREP" || continue
# Check for GNU ac_path_GREP and select it if it is found.
# Check for GNU $ac_path_GREP
case `"$ac_path_GREP" --version 2>&1` in
*GNU*)
ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;;
*)
ac_count=0
$as_echo_n 0123456789 >"conftest.in"
while :
do
cat "conftest.in" "conftest.in" >"conftest.tmp"
mv "conftest.tmp" "conftest.in"
cp "conftest.in" "conftest.nl"
$as_echo 'GREP' >> "conftest.nl"
"$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break
diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
as_fn_arith $ac_count + 1 && ac_count=$as_val
if test $ac_count -gt ${ac_path_GREP_max-0}; then
# Best one so far, save it but keep looking for a better one
ac_cv_path_GREP="$ac_path_GREP"
ac_path_GREP_max=$ac_count
fi
# 10*(2^10) chars as input seems more than enough
test $ac_count -gt 10 && break
done
rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
esac
$ac_path_GREP_found && break 3
done
done
done
IFS=$as_save_IFS
if test -z "$ac_cv_path_GREP"; then
as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
fi
else
ac_cv_path_GREP=$GREP
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5
$as_echo "$ac_cv_path_GREP" >&6; }
GREP="$ac_cv_path_GREP"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5
$as_echo_n "checking for egrep... " >&6; }
if ${ac_cv_path_EGREP+:} false; then :
$as_echo_n "(cached) " >&6
else
if echo a | $GREP -E '(a|b)' >/dev/null 2>&1
then ac_cv_path_EGREP="$GREP -E"
else
if test -z "$EGREP"; then
ac_path_EGREP_found=false
# Loop through the user's path and test for each of PROGNAME-LIST
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_prog in egrep; do
for ac_exec_ext in '' $ac_executable_extensions; do
ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext"
as_fn_executable_p "$ac_path_EGREP" || continue
# Check for GNU ac_path_EGREP and select it if it is found.
# Check for GNU $ac_path_EGREP
case `"$ac_path_EGREP" --version 2>&1` in
*GNU*)
ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;;
*)
ac_count=0
$as_echo_n 0123456789 >"conftest.in"
while :
do
cat "conftest.in" "conftest.in" >"conftest.tmp"
mv "conftest.tmp" "conftest.in"
cp "conftest.in" "conftest.nl"
$as_echo 'EGREP' >> "conftest.nl"
"$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break
diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
as_fn_arith $ac_count + 1 && ac_count=$as_val
if test $ac_count -gt ${ac_path_EGREP_max-0}; then
# Best one so far, save it but keep looking for a better one
ac_cv_path_EGREP="$ac_path_EGREP"
ac_path_EGREP_max=$ac_count
fi
# 10*(2^10) chars as input seems more than enough
test $ac_count -gt 10 && break
done
rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
esac
$ac_path_EGREP_found && break 3
done
done
done
IFS=$as_save_IFS
if test -z "$ac_cv_path_EGREP"; then
as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
fi
else
ac_cv_path_EGREP=$EGREP
fi
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5
$as_echo "$ac_cv_path_EGREP" >&6; }
EGREP="$ac_cv_path_EGREP"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5
$as_echo_n "checking for ANSI C header files... " >&6; }
if ${ac_cv_header_stdc+:} false; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <float.h>
int
main ()
{
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
ac_cv_header_stdc=yes
else
ac_cv_header_stdc=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
if test $ac_cv_header_stdc = yes; then
# SunOS 4.x string.h does not declare mem*, contrary to ANSI.
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <string.h>
_ACEOF
if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
$EGREP "memchr" >/dev/null 2>&1; then :
else
ac_cv_header_stdc=no
fi
rm -f conftest*
fi
if test $ac_cv_header_stdc = yes; then
# ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <stdlib.h>
_ACEOF
if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
$EGREP "free" >/dev/null 2>&1; then :
else
ac_cv_header_stdc=no
fi
rm -f conftest*
fi
if test $ac_cv_header_stdc = yes; then
# /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
if test "$cross_compiling" = yes; then :
:
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <ctype.h>
#include <stdlib.h>
#if ((' ' & 0x0FF) == 0x020)
# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
#else
# define ISLOWER(c) \
(('a' <= (c) && (c) <= 'i') \
|| ('j' <= (c) && (c) <= 'r') \
|| ('s' <= (c) && (c) <= 'z'))
# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
#endif
#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
int
main ()
{
int i;
for (i = 0; i < 256; i++)
if (XOR (islower (i), ISLOWER (i))
|| toupper (i) != TOUPPER (i))
return 2;
return 0;
}
_ACEOF
if ac_fn_c_try_run "$LINENO"; then :
else
ac_cv_header_stdc=no
fi
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
conftest.$ac_objext conftest.beam conftest.$ac_ext
fi
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5
$as_echo "$ac_cv_header_stdc" >&6; }
if test $ac_cv_header_stdc = yes; then
$as_echo "#define STDC_HEADERS 1" >>confdefs.h
fi
# On IRIX 5.3, sys/types and inttypes.h are conflicting.
for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
inttypes.h stdint.h unistd.h
do :
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default
"
if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
_ACEOF
fi
done
ac_fn_c_check_decl "$LINENO" "__clang_major__" "ac_cv_have_decl___clang_major__" "$ac_includes_default"
if test "x$ac_cv_have_decl___clang_major__" = xyes; then :
CLANG=yes
else
CLANG=no
fi
if test "$GCC" = "yes"
then
if test "$debugyap" = "yes"
@ -5375,8 +5689,7 @@ then
if test $win_abi = 32; then
LIBS="$LIBS $pthreadlib"
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lpthread" >&5
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lpthread" >&5
$as_echo_n "checking for main in -lpthread... " >&6; }
if ${ac_cv_lib_pthread_main+:} false; then :
$as_echo_n "(cached) " >&6
@ -5963,6 +6276,92 @@ else
INSTALL_COMMAND="install_unix"
WINDOWS="#"
PKG_WINCONSOLE=""
case "$host" in
*android*)
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -landroid" >&5
$as_echo_n "checking for main in -landroid... " >&6; }
if ${ac_cv_lib_android_main+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-landroid $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main ()
{
return main ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_android_main=yes
else
ac_cv_lib_android_main=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_android_main" >&5
$as_echo "$ac_cv_lib_android_main" >&6; }
if test "x$ac_cv_lib_android_main" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_LIBANDROID 1
_ACEOF
LIBS="-landroid $LIBS"
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -llog" >&5
$as_echo_n "checking for main in -llog... " >&6; }
if ${ac_cv_lib_log_main+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-llog $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main ()
{
return main ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_log_main=yes
else
ac_cv_lib_log_main=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_log_main" >&5
$as_echo "$ac_cv_lib_log_main" >&6; }
if test "x$ac_cv_lib_log_main" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_LIBLOG 1
_ACEOF
LIBS="-llog $LIBS"
fi
;;
**)
STARTUP_ANDROID="x"
STARTUP_DEFAULT=""
;;
esac
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sin in -lm" >&5
$as_echo_n "checking for sin in -lm... " >&6; }
if ${ac_cv_lib_m_sin+:} false; then :
@ -6462,267 +6861,7 @@ See \`config.log' for more details" "$LINENO" 5; }
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5
$as_echo_n "checking for grep that handles long lines and -e... " >&6; }
if ${ac_cv_path_GREP+:} false; then :
$as_echo_n "(cached) " >&6
else
if test -z "$GREP"; then
ac_path_GREP_found=false
# Loop through the user's path and test for each of PROGNAME-LIST
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_prog in grep ggrep; do
for ac_exec_ext in '' $ac_executable_extensions; do
ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext"
as_fn_executable_p "$ac_path_GREP" || continue
# Check for GNU ac_path_GREP and select it if it is found.
# Check for GNU $ac_path_GREP
case `"$ac_path_GREP" --version 2>&1` in
*GNU*)
ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;;
*)
ac_count=0
$as_echo_n 0123456789 >"conftest.in"
while :
do
cat "conftest.in" "conftest.in" >"conftest.tmp"
mv "conftest.tmp" "conftest.in"
cp "conftest.in" "conftest.nl"
$as_echo 'GREP' >> "conftest.nl"
"$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break
diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
as_fn_arith $ac_count + 1 && ac_count=$as_val
if test $ac_count -gt ${ac_path_GREP_max-0}; then
# Best one so far, save it but keep looking for a better one
ac_cv_path_GREP="$ac_path_GREP"
ac_path_GREP_max=$ac_count
fi
# 10*(2^10) chars as input seems more than enough
test $ac_count -gt 10 && break
done
rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
esac
$ac_path_GREP_found && break 3
done
done
done
IFS=$as_save_IFS
if test -z "$ac_cv_path_GREP"; then
as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
fi
else
ac_cv_path_GREP=$GREP
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5
$as_echo "$ac_cv_path_GREP" >&6; }
GREP="$ac_cv_path_GREP"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5
$as_echo_n "checking for egrep... " >&6; }
if ${ac_cv_path_EGREP+:} false; then :
$as_echo_n "(cached) " >&6
else
if echo a | $GREP -E '(a|b)' >/dev/null 2>&1
then ac_cv_path_EGREP="$GREP -E"
else
if test -z "$EGREP"; then
ac_path_EGREP_found=false
# Loop through the user's path and test for each of PROGNAME-LIST
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_prog in egrep; do
for ac_exec_ext in '' $ac_executable_extensions; do
ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext"
as_fn_executable_p "$ac_path_EGREP" || continue
# Check for GNU ac_path_EGREP and select it if it is found.
# Check for GNU $ac_path_EGREP
case `"$ac_path_EGREP" --version 2>&1` in
*GNU*)
ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;;
*)
ac_count=0
$as_echo_n 0123456789 >"conftest.in"
while :
do
cat "conftest.in" "conftest.in" >"conftest.tmp"
mv "conftest.tmp" "conftest.in"
cp "conftest.in" "conftest.nl"
$as_echo 'EGREP' >> "conftest.nl"
"$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break
diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
as_fn_arith $ac_count + 1 && ac_count=$as_val
if test $ac_count -gt ${ac_path_EGREP_max-0}; then
# Best one so far, save it but keep looking for a better one
ac_cv_path_EGREP="$ac_path_EGREP"
ac_path_EGREP_max=$ac_count
fi
# 10*(2^10) chars as input seems more than enough
test $ac_count -gt 10 && break
done
rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
esac
$ac_path_EGREP_found && break 3
done
done
done
IFS=$as_save_IFS
if test -z "$ac_cv_path_EGREP"; then
as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
fi
else
ac_cv_path_EGREP=$EGREP
fi
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5
$as_echo "$ac_cv_path_EGREP" >&6; }
EGREP="$ac_cv_path_EGREP"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5
$as_echo_n "checking for ANSI C header files... " >&6; }
if ${ac_cv_header_stdc+:} false; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <float.h>
int
main ()
{
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
ac_cv_header_stdc=yes
else
ac_cv_header_stdc=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
if test $ac_cv_header_stdc = yes; then
# SunOS 4.x string.h does not declare mem*, contrary to ANSI.
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <string.h>
_ACEOF
if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
$EGREP "memchr" >/dev/null 2>&1; then :
else
ac_cv_header_stdc=no
fi
rm -f conftest*
fi
if test $ac_cv_header_stdc = yes; then
# ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <stdlib.h>
_ACEOF
if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
$EGREP "free" >/dev/null 2>&1; then :
else
ac_cv_header_stdc=no
fi
rm -f conftest*
fi
if test $ac_cv_header_stdc = yes; then
# /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
if test "$cross_compiling" = yes; then :
:
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <ctype.h>
#include <stdlib.h>
#if ((' ' & 0x0FF) == 0x020)
# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
#else
# define ISLOWER(c) \
(('a' <= (c) && (c) <= 'i') \
|| ('j' <= (c) && (c) <= 'r') \
|| ('s' <= (c) && (c) <= 'z'))
# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
#endif
#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
int
main ()
{
int i;
for (i = 0; i < 256; i++)
if (XOR (islower (i), ISLOWER (i))
|| toupper (i) != TOUPPER (i))
return 2;
return 0;
}
_ACEOF
if ac_fn_c_try_run "$LINENO"; then :
else
ac_cv_header_stdc=no
fi
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
conftest.$ac_objext conftest.beam conftest.$ac_ext
fi
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5
$as_echo "$ac_cv_header_stdc" >&6; }
if test $ac_cv_header_stdc = yes; then
$as_echo "#define STDC_HEADERS 1" >>confdefs.h
fi
# On IRIX 5.3, sys/types and inttypes.h are conflicting.
for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
inttypes.h stdint.h unistd.h
do :
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default
"
if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
_ACEOF
fi
done
ac_fn_c_check_type "$LINENO" "rl_hook_func_t" "ac_cv_type_rl_hook_func_t" "$ac_includes_default"
ac_fn_c_check_type "$LINENO" "rl_hook_func_t" "ac_cv_type_rl_hook_func_t" "$ac_includes_default"
if test "x$ac_cv_type_rl_hook_func_t" = xyes; then :
cat >>confdefs.h <<_ACEOF
@ -7459,8 +7598,14 @@ fi
fi
if test "$ac_cv_c_compiler_gnu" = "yes"
then
SHLIB_CFLAGS="-shared -fPIC $CFLAGS"
SHLIB_CXXFLAGS="-shared -fPIC $CXXFLAGS"
if test "$CLANG" = "yes"
then
SHLIB_CFLAGS="-fPIC $CFLAGS"
SHLIB_CXXFLAGS="-fPIC $CXXFLAGS"
else
SHLIB_CFLAGS="-shared -fPIC $CFLAGS"
SHLIB_CXXFLAGS="-shared -fPIC $CXXFLAGS"
fi
INSTALL_DLLS="yes"
fi
CC="$CC -fstrict-aliasing -freorder-blocks -fsched-interblock -Wall"
@ -8651,7 +8796,7 @@ fi
case "$host" in
*android*)
STARTUP_ANDROID=""
STARTUP_DEFAULT="x"
STARTUP_DEFAULT="x"
;;
**)
STARTUP_ANDROID="x"
@ -8711,6 +8856,8 @@ CMDEXT=sh
@ -9419,6 +9566,7 @@ done
case "$host" in
*android*)
echo "no locale"
SAVED_STATE_PREFIX="/assets/lib/Yap/"
;;
**)
for ac_header in locale.h
@ -10813,8 +10961,8 @@ $as_echo "$as_me: WARNING: Cannot find getrlimit\"()\" -- dropping rlimit.pl" >&
fi
CLIB_PLTARGETS=`echo $CLIB_TARGETS | sed -e "s/\.$SO/.pl/g" -e "s/files.pl/filesex.pl/"`
if echo "$PL_CLIB_TARGETS" | grep socket.pl 2>&1 >/dev/null; then
CLIB_PLTARGETS="$PLCLIB_TARGETS streampool.pl"
if echo "$CLIB_PLTARGETS" | grep socket.pl 2>&1 >/dev/null; then
CLIB_PLTARGETS="$CLIB_PLTARGETS streampool.pl"
fi
@ -12481,7 +12629,7 @@ else
JAVA_TEST=Test.java
CLASS_TEST=Test.class
cat << \EOF > $JAVA_TEST
/* #line 12484 "configure" */
/* #line 12632 "configure" */
public class Test {
}
EOF
@ -12657,7 +12805,7 @@ EOF
if uudecode$EXEEXT Test.uue; then
ac_cv_prog_uudecode_base64=yes
else
echo "configure: 12660: uudecode had trouble decoding base 64 file 'Test.uue'" >&5
echo "configure: 12808: uudecode had trouble decoding base 64 file 'Test.uue'" >&5
echo "configure: failed file was:" >&5
cat Test.uue >&5
ac_cv_prog_uudecode_base64=no
@ -12788,7 +12936,7 @@ else
JAVA_TEST=Test.java
CLASS_TEST=Test.class
cat << \EOF > $JAVA_TEST
/* #line 12791 "configure" */
/* #line 12939 "configure" */
public class Test {
}
EOF
@ -12823,7 +12971,7 @@ JAVA_TEST=Test.java
CLASS_TEST=Test.class
TEST=Test
cat << \EOF > $JAVA_TEST
/* [#]line 12826 "configure" */
/* [#]line 12974 "configure" */
public class Test {
public static void main (String args[]) {
System.exit (0);

View File

@ -47,7 +47,7 @@ AC_ARG_WITH(sysroot,
CFLAGS="$CFLAGS --sysroot=$SYSROOT"
CPPFLAGS="$CPPFLAGS --sysroot=$SYSROOT"
LDFLAGS="$LDFLAGS --sysroot=$SYSROOT" ],
[yap_cv_gmp=yes])
[])
AC_PROG_CC
AC_PROG_CPP
@ -409,6 +409,8 @@ else
STATIC_MODE="# "
fi
AC_CHECK_DECL(__clang_major__, CLANG=yes, CLANG=no)
dnl Compilation Flags
if test "$GCC" = "yes"
then
@ -615,6 +617,16 @@ else
INSTALL_COMMAND="install_unix"
WINDOWS="#"
PKG_WINCONSOLE=""
case "$host" in
*android*)
AC_CHECK_LIB(android,main)
AC_CHECK_LIB(log,main)
;;
**)
STARTUP_ANDROID="x"
STARTUP_DEFAULT=""
;;
esac
AC_CHECK_LIB(m,sin)
AC_CHECK_LIB(socket,socket)
dnl X/Open Networking is sometimes a separate library
@ -860,7 +872,7 @@ fi
fi
if test "$have_nsl" = yes
then
LIBS="$LIBS -lnsl"
LIBS="$LIBS -lnsl"
fi
if test "$dynamic_loading" = "yes"
then
@ -1009,8 +1021,14 @@ dnl Linux has both elf and a.out, in this case we found elf
fi
if test "$ac_cv_prog_gcc" = "yes"
then
SHLIB_CFLAGS="-shared -fPIC $CFLAGS"
SHLIB_CXXFLAGS="-shared -fPIC $CXXFLAGS"
if test "$CLANG" = "yes"
then
SHLIB_CFLAGS="-fPIC $CFLAGS"
SHLIB_CXXFLAGS="-fPIC $CXXFLAGS"
else
SHLIB_CFLAGS="-shared -fPIC $CFLAGS"
SHLIB_CXXFLAGS="-shared -fPIC $CXXFLAGS"
fi
INSTALL_DLLS="yes"
fi
CC="$CC -fstrict-aliasing -freorder-blocks -fsched-interblock -Wall"
@ -1348,7 +1366,7 @@ AC_SUBST(ARCH)
case "$host" in
*android*)
STARTUP_ANDROID=""
STARTUP_DEFAULT="x"
STARTUP_DEFAULT="x"
;;
**)
STARTUP_ANDROID="x"
@ -1424,6 +1442,8 @@ AC_SUBST(PKG_REAL)
AC_SUBST(INSTALL_PRISM)
AC_SUBST(SAVED_STATE_PREFIX)
dnl check for threaded code
AC_MSG_CHECKING(for gcc threaded code)
AC_CACHE_VAL(yap_cv_threaded_code,[
@ -1634,6 +1654,7 @@ AC_CHECK_FUNCS(time times tmpnam usleep utime vsnprintf wcsdup wcsnlen)
case "$host" in
*android*)
echo "no locale"
SAVED_STATE_PREFIX="/assets/lib/Yap/"
;;
**)
AC_CHECK_HEADERS(locale.h)

View File

@ -373,6 +373,9 @@ PL_EXPORT(int) StryLock(IOSTREAM *s);
PL_EXPORT(int) Sunlock(IOSTREAM *s);
PL_EXPORT(IOSTREAM *) Snew(void *handle, int flags, IOFUNCTIONS *functions);
PL_EXPORT(IOSTREAM *) Sopen_file(const char *path, const char *how);
#if __ANDROID__
PL_EXPORT(IOSTREAM *) Sopen_asset(char *bufp, const char *how);
#endif
PL_EXPORT(IOSTREAM *) Sfdopen(int fd, const char *type);
PL_EXPORT(int) Sfileno(IOSTREAM *s);
PL_EXPORT(IOSTREAM *) Sopen_pipe(const char *command, const char *type);

View File

@ -3247,7 +3247,17 @@ openStream(term_t file, term_t mode, term_t options)
} else
#endif /*HAVE_POPEN*/
if ( PL_get_file_name(file, &path, 0) )
{ if ( !(s = Sopen_file(path, how)) )
{
#if __ANDROID__
if (strstr(path,"/assets/")) {
if (!(s=Sopen_asset(path+8, "r")))
{ PL_error(NULL, 0, OsError(), ERR_FILE_OPERATION,
ATOM_open, ATOM_source_sink, file);
return NULL;
}
} else
#endif
if ( !(s = Sopen_file(path, how)) )
{ PL_error(NULL, 0, OsError(), ERR_FILE_OPERATION,
ATOM_open, ATOM_source_sink, file);
return NULL;

View File

@ -1413,64 +1413,89 @@ return FALSE;
static int
atom_to_term(term_t atom, term_t term, term_t bindings)
{ GET_LD
PL_chars_t txt;
PL_chars_t txt;
if ( !bindings && PL_is_variable(atom) ) /* term_to_atom(+, -) */
{ char buf[1024];
size_t bufsize = sizeof(buf);
int rval;
char *s = buf;
IOSTREAM *stream;
PL_chars_t txt;
{ char buf[1024];
size_t bufsize = sizeof(buf);
int rval;
char *s = buf;
IOSTREAM *stream;
PL_chars_t txt;
stream = Sopenmem(&s, &bufsize, "w");
stream->encoding = ENC_UTF8;
PL_write_term(stream, term, 1200, PL_WRT_QUOTED);
Sflush(stream);
stream = Sopenmem(&s, &bufsize, "w");
stream->encoding = ENC_UTF8;
PL_write_term(stream, term, 1200, PL_WRT_QUOTED);
Sflush(stream);
txt.text.t = s;
txt.length = bufsize;
txt.storage = PL_CHARS_HEAP;
txt.encoding = ENC_UTF8;
txt.canonical = FALSE;
rval = PL_unify_text(atom, 0, &txt, PL_ATOM);
txt.text.t = s;
txt.length = bufsize;
txt.storage = PL_CHARS_HEAP;
txt.encoding = ENC_UTF8;
txt.canonical = FALSE;
rval = PL_unify_text(atom, 0, &txt, PL_ATOM);
Sclose(stream);
if ( s != buf )
Sfree(s);
Sclose(stream);
if ( s != buf )
Sfree(s);
return rval;
}
return rval;
}
if ( PL_get_text(atom, &txt, CVT_ALL|CVT_EXCEPTION) )
{ GET_LD
read_data rd;
int rval;
IOSTREAM *stream;
source_location oldsrc = LD->read_source;
{ GET_LD
read_data rd;
int rval;
IOSTREAM *stream;
source_location oldsrc = LD->read_source;
stream = Sopen_text(&txt, "r");
stream = Sopen_text(&txt, "r");
init_read_data(&rd, stream PASS_LD);
if ( bindings && (PL_is_variable(bindings) || PL_is_list(bindings)) )
rd.varnames = bindings;
else if ( bindings )
return PL_error(NULL, 0, NULL, ERR_TYPE, ATOM_list, bindings);
if ( !(rval = read_term(term, &rd PASS_LD)) && rd.has_exception )
rval = PL_raise_exception(rd.exception);
free_read_data(&rd);
Sclose(stream);
LD->read_source = oldsrc;
// getchar();
return rval;
}
fail;
}
Term
Yap_StringToTerm(const char *s, size_t len, term_t bindings)
{ GET_LD;
read_data rd;
int rval;
IOSTREAM *stream;
source_location oldsrc = LD->read_source;
stream = Sopen_string(0, (char *)s, strlen( s ), "r");
init_read_data(&rd, stream PASS_LD);
if ( bindings && (PL_is_variable(bindings) || PL_is_list(bindings)) )
rd.varnames = bindings;
else if ( bindings )
return PL_error(NULL, 0, NULL, ERR_TYPE, ATOM_list, bindings);
rd.varnames = bindings;
term_t tt = Yap_NewSlots(1 PASS_REGS);
if ( !(rval = read_term(term, &rd PASS_LD)) && rd.has_exception )
rval = PL_raise_exception(rd.exception);
if ( !(rval = read_term(tt, &rd PASS_LD)) && rd.has_exception ) {
rval = PL_raise_exception(rd.exception);
return 0L;
}
free_read_data(&rd);
Sclose(stream);
LD->read_source = oldsrc;
// getchar();
return rval;
return Yap_GetFromSlot( tt PASS_REGS);
}
fail;
}
static
PRED_IMPL("atom_to_term", 3, atom_to_term, 0)
{ return atom_to_term(A1, A2, A3);

View File

@ -37,6 +37,16 @@
#else
#include <config.h>
#endif
#if __ANDROID__
#include <android/asset_manager.h>
#include <android/asset_manager_jni.h>
#include <android/log.h>
#else
inline void __android_log_print(int i, char *loc, char *msg, ...) {}
#define ANDROID_LOG_INFO 0
#define ANDROID_LOG_ERROR 0
#define ANDROID_LOG_DEBUG 0
#endif
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
This modules defines the SWI-Prolog I/O streams. These streams are
@ -545,7 +555,7 @@ S__fillbuf(IOSTREAM *s)
if ( s->flags & SIO_NBUF )
{ char chr;
ssize_t n;
__android_log_print(ANDROID_LOG_ERROR, "pl-stream.c", "calling read %p", s);
n = (*s->functions->read)(s->handle, &chr, 1);
if ( n == 1 )
{ c = char_to_int(chr);
@ -578,7 +588,8 @@ S__fillbuf(IOSTREAM *s)
len = s->bufsize;
}
n = (*s->functions->read)(s->handle, s->limitp, len);
__android_log_print(ANDROID_LOG_ERROR, "save.c", "saved state %p %u", s, len);
n = (*s->functions->read)(s->handle, s->limitp, len);
if ( n > 0 )
{ s->limitp += n;
c = char_to_int(*s->bufp++);
@ -738,7 +749,7 @@ unget_byte(int c, IOSTREAM *s)
*--s->bufp = c;
if ( p )
{ p->charno--; /* FIXME: not correct */
{ p->charno--; /* sz */
p->byteno--;
if ( c == '\n' )
p->lineno--;
@ -2875,7 +2886,14 @@ Sopen_file(const char *path, const char *how)
enum {lnone=0,lread,lwrite} lock = lnone;
IOSTREAM *s;
IOENC enc = ENC_UNKNOWN;
int wait = TRUE;
#if __ANDROID__
__android_log_print(ANDROID_LOG_INFO, "os-stream.c", "looking at asset %s", path);
if (strstr(path, "/assets/") == path) {
char * p = (char *)path + strlen("/assets/");
return Sopen_asset( p, how-1);
}
#endif
for( ; *how; how++)
{ switch(*how)
@ -2887,7 +2905,7 @@ Sopen_file(const char *path, const char *how)
flags &= ~SIO_RECORDPOS;
break;
case 'L': /* lock r: read, w: write */
wait = FALSE;
// wait = FALSE;
/*FALLTHROUGH*/
case 'l': /* lock r: read, w: write */
if ( *++how == 'r' )
@ -3181,6 +3199,196 @@ Sopen_pipe(const char *command, const char *type)
#endif /*HAVE_POPEN*/
#if __ANDROID__
/*******************************
* ASSET FILES *
*******************************/
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Asset files provide a mechanism for accesing file resources stored in
an Android application pack.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
static ssize_t
Swrite_asset(void *handle, char *buf, size_t size)
{
return -1L;
}
static ssize_t
Sread_asset(void *handle, char *buf, size_t size)
{
__android_log_print(ANDROID_LOG_ERROR, "os-stream.c", " size %d", size);
int res = AAsset_read((AAsset* )handle, (void* )buf, size);
__android_log_print(ANDROID_LOG_ERROR, "os-stream.c", "loaded %d", res);
if (res < 0) {
errno = ENOSPC; /* signal error */
}
return res;
}
static long
Sseek_asset(void *handle, long offset, int whence)
{ int res = AAsset_seek((AAsset* )handle, (off_t)offset, whence);
if (res == (off_t)-1) {
errno = ENOSPC; /* signal error */
}
return res;
}
static int64_t
Sseek64_asset(void *handle, int64_t offset, int whence)
{ off64_t res = AAsset_seek64((AAsset* )handle, (off64_t)offset, whence);
if (res == (off64_t)-1) {
errno = ENOSPC; /* signal error */
}
return res;
}
static int
Scontrol_asset(void *handle, int action, void *arg)
{ AAsset* h = (AAsset* ) handle;
off_t *rval = (off_t *)arg;
switch(action)
{
case SIO_GETSIZE:
*rval = AAsset_getLength(h);
return 0;
case SIO_GETFILENO:
{ off_t start = 0, end = AAsset_getLength(h);
int fd = AAsset_openFileDescriptor((AAsset*)handle, &start, &end);
if (fd == 0)
return -1;
*rval = fd;
return 0;
}
case SIO_SETENCODING:
case SIO_FLUSHOUTPUT:
return 0;
default:
return -1;
}
}
static int
Sclose_asset(void *handle)
{
AAsset_close((AAsset* )handle);
return 0;
}
IOFUNCTIONS Sassetfunctions =
{ Sread_asset,
Swrite_asset,
Sseek_asset,
Sclose_asset,
Scontrol_asset,
Sseek64_asset
};
#include <jni.h>
#include <string.h>
AAssetManager *assetManager;
JNIEnv *env;
void Java_org_swig_simple_SwigSimple_load(JNIEnv *env0, jobject obj, jobject mgr);
void Java_org_swig_simple_SwigSimple_load
(JNIEnv *env0, jobject obj, jobject mgr)
{
__android_log_print(ANDROID_LOG_INFO, "os-stream.c", "loading asset manager %p", mgr);
assetManager = AAssetManager_fromJava(env0, mgr);
env = env0;
if (assetManager == NULL) {
__android_log_print(ANDROID_LOG_INFO, "os-stream.c", "error loading asset manager");
} else {
__android_log_print(ANDROID_LOG_VERBOSE, "os-stream.c", "loaded asset manager");
}
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Sopen_asset(char **buffer, size_t *sizep, const char* mode)
Open an Android asset, essentially a read-only part of a ZIP archive.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
IOSTREAM *
Sopen_asset(char *bufp, const char *how)
{
AAsset* asset;
int flags = SIO_FILE|SIO_TEXT|SIO_RECORDPOS|SIO_FBUF;
__android_log_print(ANDROID_LOG_INFO, "os-stream.c", "looking at %s/%s", bufp, how);\
int op = *how++;
IOSTREAM *s;
IOENC enc = ENC_UNKNOWN;
AAssetManager* mgr = assetManager;
for( ; *how; how++)
{ switch(*how)
{ case 'b': /* binary */
flags &= ~SIO_TEXT;
enc = ENC_OCTET;
break;
case 'r': /* no record */
flags &= ~SIO_RECORDPOS;
break;
case 'L': /* lock r: read, w: write */
case 'l': /* lock r: read, w: write */
// read-only, nothing changes.
break;
default:
errno = EINVAL;
return NULL;
}
}
__android_log_print(ANDROID_LOG_INFO, "os-stream.c", "looking at %s/%c", bufp, op);\
#if O_LARGEFILES && defined(O_LARGEFILE)
oflags |= O_LARGEFILE;
#endif
switch(op)
{ case 'w':
return NULL;
case 'a':
return NULL;
case 'u':
return NULL;
case 'r':
__android_log_print(ANDROID_LOG_INFO, "os-stream.c", "loading asset %s", bufp);\
//const char *utf8 = (*env)->GetStringUTFChars(env, bufp, NULL);
asset = AAssetManager_open(mgr, bufp, AASSET_MODE_UNKNOWN);
flags |= SIO_INPUT;
break;
default:
errno = EINVAL;
return NULL;
}
__android_log_print(ANDROID_LOG_INFO, "os-stream.c", "got asset %p", asset);\
if ( !asset )
return NULL;
s = Snew((void *)asset, flags, &Sassetfunctions);
if ( enc != ENC_UNKNOWN )
s->encoding = enc;
return s;
}
#endif /* __ANDROID__ */
/*******************************
* MEMORY STREAMS *
*******************************/

@ -1 +1 @@
Subproject commit dec22cfcd9b99ffe18bb6716dcaa0761dbc29bce
Subproject commit 0a9fc69fecfb78fb07b4f0a624964ae33d4e7632

@ -1 +1 @@
Subproject commit 90510fe601057a9122b6abeb17b716fa16a7c1aa
Subproject commit 688bf6c3b2bc472ce8cb2fce58657cc38a496f07

View File

@ -18,6 +18,9 @@ SYM_REC_PTR insert_cpred(const char *, int, int(*)(void));
void exit(int);
#ifdef __YAP_PROLOG__
typedef int (*CPredicate)(void);
void
YAP_UserCPredicate(const char *name, CPredicate def, uintptr_t arity);
SYM_REC_PTR insert_cpred(const char *s, int n, int(*f)(void))
{

View File

@ -27,7 +27,7 @@ install-dummy::
install-pitf: $(SOLIBS) $(addprefix $(srcdir)/, $(LIBPL)) install-examples
mkdir -p $(DESTDIR)$(SOLIBDIR)
rm -f $(DESTDIR)$(SOLIBDIR)/python.@SO@
$(INSTALL_PROGRAM) $(SOLIBS) $(SOLIBDIR)
$(INSTALL_PROGRAM) $(SOLIBS) $(DESTDIR)$(SOLIBDIR)
mkdir -p $(DESTDIR)$(PLLIBDIR)
for f in $(LIBPL); do \
$(INSTALL_DATA) $(srcdir)/$$f $(DESTDIR)$(PLLIBDIR); \

View File

@ -11,7 +11,7 @@ srcdir=@srcdir@
CPPFLAGS=@CPPFLAGS@ -I../.. -I$(srcdir)/../../H -I$(srcdir)/../../include -I$(srcdir)/../../os -I$(srcdir)/../../OPTYap -I$(srcdir)/../../BEAM -I$(srcdir)/../../CXX
CXXFLAGS= @SHLIB_CXXFLAGS@ $(YAP_EXTRAS) $(DEFS) $(CPPFLAGS)
PROGRAMS= \
PROGRAMS= $(srcdir)/python/demo.py \
SWIG_FILES= \
$(srcdir)/yap.i
@ -19,11 +19,13 @@ SWIG_FILES= \
all: python java R
python: $(SWIG_FILES) python/_yap.so python/yap.py
cp $(srcdir)/python/demo.py python
python/_yap.so: python/yap_wrap.o
$(CXX) -shared $(LDSOFLAGS) -o python/_yap.so python/yap_wrap.o ../../yapi.o $(LIBS) @PYTHON_LIBS@ -L ../.. -lYap -lpthread
python/yap_wrap.c: $(srcdir)/yap.i
mkdir -p python
$(SWIG) -c++ -python -outdir python -o $@ $(DEFS) $(CPPFLAGS) -Wall $<
python/yap_wrap.o: python/yap_wrap.c
@ -41,14 +43,24 @@ jni/yap_wrap.cpp: $(srcdir)/yap.i
jni/yap_wrap.o: jni/yap_wrap.cpp
$(CXX) -c $(CXXFLAGS) @JPLCFLAGS@ $< -o $@
android: android/jni/yap_wrap.cpp
# depends on make install on top-level
# also, should have an android device running, say
# emulator -avd first &
#
# adb uninstall org.swig.simple ( if not the first time )
# adb install bin/SwigSimple-debug.apk
#
#
android: android/jni/yap_wrap.cpp
android/jni/yap_wrap.cpp: $(srcdir)/yap.i
android create project --target 1 --name SwigSimple --path ./android --activity SwigSimple --package org.swig.simple
( cd android ; mkdir -p jni;\
( cd android ; mkdir -p jni; mkdir -p assets/share/Yap; mkdir -p assets/lib/Yap;\
$(SWIG) -c++ -java -I$(srcdir)/../../CXX -package org.swig.simple -outdir src/org/swig/simple -o jni/yap_wrap.cpp $< ;\
cp $(srcdir)/android/SwigSimple.java src/org/swig/simple/ ;\
cp $(srcdir)/android/main.xml res/layout ;\
cp -r $(DESTDIR)$(PLLIBDIR)/* assets/share/Yap;\
cp -r $(DESTDIR)$(SOLIBDIR)/* assets/lib/Yap;\
cp ../Android.mk jni ;\
ndk-build; \
ant debug \