fix writebuffer interface
This commit is contained in:
parent
fa2c5ee114
commit
8d779f68ea
@ -478,7 +478,7 @@ X_API void STD_PROTO(YAP_EndConsult,(IOSTREAM *));
|
||||
X_API Term STD_PROTO(YAP_Read, (IOSTREAM *));
|
||||
X_API void STD_PROTO(YAP_Write, (Term, IOSTREAM *, int));
|
||||
X_API Term STD_PROTO(YAP_CopyTerm, (Term));
|
||||
X_API Term STD_PROTO(YAP_WriteBuffer, (Term, char *, unsigned int, int));
|
||||
X_API int STD_PROTO(YAP_WriteBuffer, (Term, char *, size_t, int));
|
||||
X_API char *STD_PROTO(YAP_CompileClause, (Term));
|
||||
X_API void STD_PROTO(YAP_PutValue, (Atom,Term));
|
||||
X_API Term STD_PROTO(YAP_GetValue, (Atom));
|
||||
@ -2799,8 +2799,8 @@ YAP_CopyTerm(Term t)
|
||||
return tn;
|
||||
}
|
||||
|
||||
X_API Term
|
||||
YAP_WriteBuffer(Term t, char *buf, unsigned int sze, int flags)
|
||||
X_API int
|
||||
YAP_WriteBuffer(Term t, char *buf, size_t sze, int flags)
|
||||
{
|
||||
BACKUP_MACHINE_REGS();
|
||||
t = Yap_TermToString(t, buf, sze, flags);
|
||||
|
@ -278,11 +278,11 @@ int STD_PROTO(Yap_GetCharForSIGINT,(void));
|
||||
Int STD_PROTO(Yap_StreamToFileNo,(Term));
|
||||
Term STD_PROTO(Yap_OpenStream,(FILE *,char *,Term,int));
|
||||
Term STD_PROTO(Yap_StringToTerm,(char *,Term *));
|
||||
Term STD_PROTO(Yap_TermToString,(Term,char *,unsigned int,int));
|
||||
int STD_PROTO(Yap_GetFreeStreamD,(void));
|
||||
int STD_PROTO(Yap_GetFreeStreamDForReading,(void));
|
||||
int Yap_TermToString(Term t, char *s, size_t sz, int flags);
|
||||
int Yap_GetFreeStreamD(void);
|
||||
int Yap_GetFreeStreamDForReading(void);
|
||||
|
||||
Term STD_PROTO(Yap_WStringToList,(wchar_t *));
|
||||
Term Yap_WStringToList(wchar_t *);
|
||||
Term STD_PROTO(Yap_WStringToListOfAtoms,(wchar_t *));
|
||||
Atom STD_PROTO(Yap_LookupWideAtom,(wchar_t *));
|
||||
|
||||
|
26
docs/yap.tex
26
docs/yap.tex
@ -9651,12 +9651,21 @@ applying the predicate @var{Pred} to all list elements on which
|
||||
Calls @var{Pred} on all elements of @code{List} and collects a result in
|
||||
@var{X} and @var{Y}.
|
||||
|
||||
@item foldl3(:@var{Pred}, +@var{List}, ?@var{X0}, ?@var{X}, ?@var{Y0}, ?@var{Y}, ?@var{Z0}, ?@var{Z})
|
||||
@item foldl2(:@var{Pred}, +@var{List}, ?@var{List1}, ?@var{X0}, ?@var{X}, ?@var{Y0}, ?@var{Y})
|
||||
@findex foldl2/7
|
||||
@snindex foldl2/7
|
||||
@cnindex foldl2/7
|
||||
Calls @var{Pred} on all elements of @code{List} and collects a result in
|
||||
@var{X} and @var{Y}.
|
||||
|
||||
@item foldl3(:@var{Pred}, +@var{List1}, ?@var{List2}, ?@var{X0},
|
||||
?@var{X}, ?@var{Y0}, ?@var{Y}, ?@var{Z0}, ?@var{Z})
|
||||
|
||||
@findex foldl3/6
|
||||
@snindex foldl3/6
|
||||
@cnindex foldl3/6
|
||||
Calls @var{Pred} on all elements of @code{List} and collects a result in
|
||||
@var{X}, @var{Y} and @var{Z}.
|
||||
Calls @var{Pred} on all elements of @code{List} and collects a
|
||||
result in @var{X}, @var{Y} and @var{Z}.
|
||||
|
||||
@item scanl(:@var{Pred}, +@var{List}, +@var{V0}, ?@var{Values})
|
||||
@findex scanl/4
|
||||
@ -17725,14 +17734,15 @@ characters. The term is written according to a mask of the following
|
||||
flags in the @code{flag} argument: @code{YAP_WRITE_QUOTED},
|
||||
@code{YAP_WRITE_HANDLE_VARS}, @code{YAP_WRITE_USE_PORTRAY}, and @code{YAP_WRITE_IGNORE_OPS}.
|
||||
|
||||
@item @code{void} YAP_WriteBuffer(@code{YAP_Term} @var{t}, @code{char *}
|
||||
@var{buff}, @code{unsigned int}
|
||||
@item @code{int} YAP_WriteBuffer(@code{YAP_Term} @var{t}, @code{char *}
|
||||
@var{buff}, @code{size_t}
|
||||
@var{size}, @code{int} @var{flags})
|
||||
@findex YAP_WriteBuffer/4
|
||||
Write a YAP_Term @var{t} to buffer @var{buff} with size @var{size}. The
|
||||
term is written according to a mask of the following flags in the
|
||||
@code{flag} argument: @code{YAP_WRITE_QUOTED},
|
||||
@code{YAP_WRITE_HANDLE_VARS}, and @code{YAP_WRITE_IGNORE_OPS}.
|
||||
flag are currently ignored. This function can fail, say, if the term
|
||||
cannot be encoded in ISO-LATIN8. The code always uses
|
||||
@code{YAP_WRITE_HANDLE_VARS}. You may also use @code{YAP_WRITE_QUOTED},
|
||||
and @code{YAP_WRITE_IGNORE_OPS} together.
|
||||
|
||||
@item @code{void} YAP_InitConsult(@code{int} @var{mode}, @code{char *} @var{filename})
|
||||
@findex YAP_InitConsult/2
|
||||
|
@ -2868,19 +2868,20 @@ Yap_read_term(term_t t, IOSTREAM *st, term_t *excep, term_t vs)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
Term
|
||||
Yap_TermToString(Term t, char *s, unsigned int sz, int flags)
|
||||
int
|
||||
Yap_TermToString(Term t, char *s, size_t sz, int flags)
|
||||
{
|
||||
CACHE_REGS
|
||||
IOSTREAM *stream = Sopen_string(NULL, s, sz, "w");
|
||||
int out;
|
||||
unsigned swi_flags;
|
||||
|
||||
if (!stream)
|
||||
return FALSE;
|
||||
Yap_StartSlots( PASS_REGS1 );
|
||||
out = PL_write_term(stream, Yap_InitSlot(t PASS_REGS), 1200, 0);
|
||||
swi_flags = CVT_WRITE;
|
||||
if (flags & (YAP_WRITE_QUOTED|YAP_WRITE_IGNORE_OPS)) {
|
||||
swi_flags = CVT_WRITE_CANONICAL;
|
||||
}
|
||||
out = PL_get_nchars(Yap_InitSlot(t PASS_REGS), &sz, &s, swi_flags);
|
||||
Yap_CloseSlots( PASS_REGS1 );
|
||||
Sclose(stream);
|
||||
return out;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user