more SWI compatibility changes.

This commit is contained in:
Vítor Santos Costa 2011-02-11 01:22:07 +00:00
parent 02c791fc3d
commit b475be5692
7 changed files with 22 additions and 17 deletions

View File

@ -1514,12 +1514,10 @@ YAP_ExecuteFirst(PredEntry *pe, CPredicate exec_code)
} else if (val == 1) { /* TRUE */
cut_succeed();
} else {
/*
if ((val & REDO_PTR) == REDO_PTR)
if ((val & REDO_PTR) == REDO_PTR)
ctx->context = (int *)(val & ~REDO_PTR);
else
else
ctx->context = (int *)((val & ~REDO_PTR)>>FRG_REDO_BITS);
*/
return TRUE;
}
} else {

View File

@ -24,6 +24,12 @@
#include "swi.h"
static PL_blob_t unregistered_blob_atom =
{ PL_BLOB_MAGIC,
PL_BLOB_NOCOPY|PL_BLOB_TEXT,
"unregistered"
};
PL_EXPORT(int)
PL_is_blob(term_t t, PL_blob_t **type)
@ -75,13 +81,13 @@ PL_blob_data(atom_t a, size_t *len, struct PL_blob_t **type)
if ( len )
*len = wcslen(x->WStrOfAE);
if ( type )
*type = SWI_Blobs;
*type = &unregistered_blob_atom;
return x->WStrOfAE;
}
if ( len )
*len = strlen(x->StrOfAE);
if ( type )
*type = SWI_Blobs;
*type = &unregistered_blob_atom;
return x->StrOfAE;
}
if ( len )
@ -112,7 +118,7 @@ YAP_find_blob_type(YAP_Atom at)
{
AtomEntry *a = RepAtom((Atom)at);
if (!IsBlob(a)) {
return SWI_Blobs;
return &unregistered_blob_atom;
}
return RepBlobProp(a->PropsOfAE)->blob_t;
}

View File

@ -2115,11 +2115,9 @@ X_API int
PL_recorded(record_t db, term_t ts)
{
Term t = YAP_Recorded((void *)db);
fprintf(stderr,"PL_recorded %ld\n", t);
if (t == ((CELL)0))
return FALSE;
Yap_PutInSlot(ts,t);
fprintf(stderr,"PL_recorded\n");
return TRUE;
}

View File

@ -419,7 +419,6 @@ do_char_type(term_t chr, term_t class, control_t h, int how)
default:
succeed;
}
if ( !(fid = PL_open_foreign_frame()) )
goto error;
@ -800,11 +799,11 @@ PRED_IMPL("setlocale", 3, setlocale, 0)
*******************************/
BeginPredDefs(ctype)
PRED_DEF("swi_char_type", 2, char_type, PL_FA_NONDETERMINISTIC)
PRED_DEF("swi_code_type", 2, code_type, PL_FA_NONDETERMINISTIC)
PRED_DEF("swi_setlocale", 3, setlocale, 0)
PRED_DEF("swi_downcase_atom", 2, downcase_atom, 0)
PRED_DEF("swi_upcase_atom", 2, upcase_atom, 0)
PRED_DEF("char_type", 2, char_type, PL_FA_NONDETERMINISTIC)
PRED_DEF("code_type", 2, code_type, PL_FA_NONDETERMINISTIC)
PRED_DEF("setlocale", 3, setlocale, 0)
PRED_DEF("downcase_atom", 2, downcase_atom, 0)
PRED_DEF("upcase_atom", 2, upcase_atom, 0)
PRED_DEF("swi_normalize_space", 2, normalize_space, 0)
EndPredDefs

View File

@ -126,7 +126,7 @@ PL_get_text__LD(term_t l, PL_chars_t *text, int flags ARG_LD)
{ word w = valHandle(l);
if ( (flags & CVT_ATOM) && isAtom(w) )
{ if ( !get_atom_text(w, text) )
{ if ( !get_atom_text(atomFromTerm(w), text) )
goto maybe_write;
} else if ( (flags & CVT_STRING) && isString(w) )
{ if ( !get_string_text(w, text PASS_LD) )

View File

@ -222,6 +222,9 @@ _PL_unify_atomic(term_t t, PL_atomic_t a)
word lookupAtom(const char *s, size_t len)
{
/* dirty trick to ensure s is null terminated */
char *st = (char *)s;
st[len] = '\0';
if (len >= strlen(s)) {
return (word)YAP_LookupAtom(s);
} else {

View File

@ -121,7 +121,8 @@ PL_blob_t* YAP_find_blob_type(YAP_Atom at);
#define valReal(w) YAP_FloatOfTerm((w))
#define valFloat(w) YAP_FloatOfTerm((w))
#define AtomLength(w) YAP_AtomNameLength(w)
#define atomValue(atom) YAP_AtomOfTerm(atom)
#define atomValue(atom) YAP_AtomFromSWIAtom(atom)
#define atomFromTerm(term) YAP_AtomOfTerm(term)
#define atomName(atom) ((char *)YAP_AtomName(atom))
#define nameOfAtom(atom) ((char *)YAP_AtomName(atom))
#define atomLength(atom) YAP_AtomNameLength(atom)