further changes to better support SWI interface.

This commit is contained in:
Vítor Santos Costa 2008-12-17 14:47:05 +00:00
parent f19db29647
commit a2744ed186
6 changed files with 381 additions and 186 deletions

View File

@ -1179,6 +1179,22 @@ Yap_NWideStringToListOfAtoms(wchar_t *s, size_t len)
return t;
}
Term
Yap_NWideStringToDiffListOfAtoms(wchar_t *s, Term t0, size_t len)
{
register Term t;
wchar_t so[2];
wchar_t *cp = s + len;
so[1] = '\0';
t = t0;
while (cp > s) {
so[0] = *--cp;
t = MkPairTerm(MkAtomTerm(LookupWideAtom(so)), t);
}
return t;
}
Term
Yap_ArrayToList(register Term *tp, int nof)
{

View File

@ -431,6 +431,7 @@ X_API Term STD_PROTO(YAP_BufferToAtomList, (char *));
X_API Term STD_PROTO(YAP_NBufferToAtomList, (char *,size_t));
X_API Term STD_PROTO(YAP_WideBufferToAtomList, (wchar_t *));
X_API Term STD_PROTO(YAP_NWideBufferToAtomList, (wchar_t *, size_t));
X_API Term STD_PROTO(YAP_NWideBufferToAtomDiffList, (wchar_t *, Term, size_t));
X_API Term STD_PROTO(YAP_BufferToDiffList, (char *, Term));
X_API Term STD_PROTO(YAP_NBufferToDiffList, (char *, Term, size_t));
X_API Term STD_PROTO(YAP_WideBufferToDiffList, (wchar_t *, Term));
@ -499,6 +500,7 @@ X_API Term STD_PROTO(YAP_TermNil,(void));
X_API int STD_PROTO(YAP_AtomGetHold,(Atom));
X_API int STD_PROTO(YAP_AtomReleaseHold,(Atom));
X_API Agc_hook STD_PROTO(YAP_AGCRegisterHook,(Agc_hook));
X_API char *STD_PROTO(YAP_cwd,(void));
static int (*do_getf)(void);
@ -1363,6 +1365,19 @@ YAP_NWideBufferToAtomList(wchar_t *s, size_t len)
return t;
}
/* copy a string of size len to a buffer */
X_API Term
YAP_NWideBufferToAtomDiffList(wchar_t *s, Term t0, size_t len)
{
Term t;
BACKUP_H();
t = Yap_NWideStringToDiffListOfAtoms(s, t0, len);
RECOVER_H();
return t;
}
/* copy a string to a buffer */
X_API Term
YAP_BufferToDiffList(char *s, Term t0)

View File

@ -52,6 +52,7 @@ Term STD_PROTO(Yap_StringToListOfAtoms,(char *));
Term STD_PROTO(Yap_NStringToListOfAtoms,(char *, size_t));
Term STD_PROTO(Yap_WideStringToListOfAtoms,(wchar_t *));
Term STD_PROTO(Yap_NWideStringToListOfAtoms,(wchar_t *, size_t));
Term STD_PROTO(Yap_NWideStringToDiffListOfAtoms,(wchar_t *, Term, size_t));
struct hold_entry *STD_PROTO(Yap_InitAtomHold,(void));
int STD_PROTO(Yap_AtomGetHold,(Atom));
int STD_PROTO(Yap_AtomReleaseHold,(Atom));

View File

@ -36,9 +36,9 @@
#endif
#endif
typedef unsigned long fid_t;
typedef unsigned long term_t;
typedef void *module_t;
typedef void *record_t;
typedef unsigned long atom_t;
typedef YAP_Term *predicate_t;
typedef struct open_query_struct *qid_t;
@ -52,9 +52,12 @@ typedef unsigned __int64 uint64_t;
#else
#include <inttypes.h> /* more portable than stdint.h */
#endif
typedef uintptr_t PL_fid_t; /* opaque foreign context handle */
typedef void *function_t;
#define fid_t PL_fid_t /* avoid AIX name-clash */
typedef struct _PL_extension
{ char *predicate_name; /* Name of the predicate */
short arity; /* Arity of the predicate */
@ -255,7 +258,10 @@ extern X_API int PL_unify_nil(term_t);
extern X_API int PL_unify_pointer(term_t, void *);
extern X_API int PL_unify_string_chars(term_t, const char *);
extern X_API int PL_unify_term(term_t,...);
extern X_API int PL_unify_chars(term_t, int, size_t, const char *);
extern X_API int PL_unify_chars_diff(term_t, term_t, int, size_t, const char *);
extern X_API int PL_unify_wchars(term_t, int, size_t, const pl_wchar_t *);
extern X_API int PL_unify_wchars_diff(term_t, term_t, int, size_t, const pl_wchar_t *);
/* end PL_unify_* functions =============================*/
/* begin PL_is_* functions =============================*/
extern X_API int PL_is_atom(term_t);
@ -269,12 +275,14 @@ extern X_API int PL_is_number(term_t);
extern X_API int PL_is_string(term_t);
extern X_API int PL_is_variable(term_t);
extern X_API int PL_term_type(term_t);
extern X_API int PL_is_inf(term_t);
/* end PL_is_* functions =============================*/
extern X_API void PL_halt(int);
extern X_API int PL_initialise(int, char **);
extern X_API int PL_is_initialised(int *, char ***);
extern X_API void PL_close_foreign_frame(fid_t);
extern X_API void PL_discard_foreign_frame(fid_t);
extern X_API void PL_rewind_foreign_frame(fid_t);
extern X_API fid_t PL_open_foreign_frame(void);
extern X_API int PL_raise_exception(term_t);
extern X_API void PL_register_atom(atom_t);
@ -301,6 +309,9 @@ extern X_API PL_engine_t PL_create_engine(const PL_thread_attr_t *);
extern X_API int PL_destroy_engine(PL_engine_t);
extern X_API int PL_set_engine(PL_engine_t,PL_engine_t *);
extern X_API int PL_get_string_chars(term_t, char **, int *);
extern X_API record_t PL_record(term_t);
extern X_API void PL_recorded(record_t, term_t);
extern X_API void PL_erase(record_t);
extern X_API int PL_action(int,...);
extern X_API void *PL_malloc(int);
extern X_API void PL_free(void *);
@ -335,8 +346,12 @@ extern X_API int PL_open_stream(term_t t, IOSTREAM *s); /* compat */
extern X_API int PL_get_stream_handle(term_t t, IOSTREAM **s);
#endif
extern X_API char *PL_cwd(void);
extern X_API const char *PL_cwd(void);
void swi_install(void);
X_API int PL_error(const char *pred, int arity, const char *msg, int id, ...);
#endif /* _FLI_H_INCLUDED */

View File

@ -344,6 +344,9 @@ extern X_API YAP_Term PROTO(YAP_WideBufferToAtomList,(CONST wchar_t *));
/* int BufferToAtomList(const char *) */
extern X_API YAP_Term PROTO(YAP_NWideBufferToAtomList,(CONST wchar_t *, size_t len));
/* int BufferToDiffList(const char *) */
extern X_API YAP_Term PROTO(YAP_NWideBufferToAtomDiffList,(CONST wchar_t *, YAP_Term, size_t len));
/* int BufferToDiffList(const char *) */
extern X_API YAP_Term PROTO(YAP_BufferToDiffList,(CONST char *));
@ -354,7 +357,7 @@ extern X_API YAP_Term PROTO(YAP_NBufferToDiffList,(CONST char *, size_t len));
extern X_API YAP_Term PROTO(YAP_WideBufferToDiffList,(CONST wchar_t *));
/* int BufferToDiffList(const char *) */
extern X_API YAP_Term PROTO(YAP_NWideBufferToDiffList,(CONST wchar_t *, size_t len));
extern X_API YAP_Term PROTO(YAP_NWideBufferToDiffList,(CONST wchar_t *, YAP_Term, size_t len));
/* YAP_Term BufferToTerm(const char *) */
extern X_API YAP_Term PROTO(YAP_ReadBuffer,(CONST char *,YAP_Term *));

File diff suppressed because it is too large Load Diff