diff --git a/C/dbase.c b/C/dbase.c index 9bbc370fa..57e52a05f 100644 --- a/C/dbase.c +++ b/C/dbase.c @@ -33,8 +33,9 @@ static char SccsId[] = "%W% %G%"; /** @defgroup Internal_Database Internal Data Base -@ingroup builtins -@{ + + @ingroup builtins + @{ Some programs need global information for, e.g. counting or collecting data obtained by backtracking. As a rule, to keep this information, the diff --git a/os/iopreds.c b/os/iopreds.c index f526e122b..01e2406f8 100644 --- a/os/iopreds.c +++ b/os/iopreds.c @@ -1237,10 +1237,11 @@ static Int do_open(Term file_name, Term t2, Term tlist USES_REGS) { encoding_t encoding; Term tenc; char io_mode[8]; - file_name = Deref( file_name); - if (IsVarTerm(file_name)) { - Yap_ThrowError(INSTANTIATION_ERROR, file_name, "while opening a list of options"); - } + file_name = Deref(file_name); + if (IsVarTerm(file_name)) { + Yap_ThrowError(INSTANTIATION_ERROR, file_name, + "while opening a list of options"); + } // open mode if (IsVarTerm(t2)) { Yap_Error(INSTANTIATION_ERROR, t2, "open/3"); @@ -1583,18 +1584,19 @@ int Yap_OpenStream(Term tin, const char *io_mode, Term user_name, vfsp->open(vfsp, fname, io_mode, sno)) { // read, write, append user_name = st->user_name; + st->vfs = vfsp; UNLOCK(st->streamlock); } else { st->file = fopen(fname, io_mode); if (st->file == NULL) { - UNLOCK(st->streamlock); - if (errno == ENOENT && !strchr(io_mode, 'r')) { - PlIOError(EXISTENCE_ERROR_SOURCE_SINK, tin, "%s: %s", fname, - strerror(errno)); - } else { - PlIOError(PERMISSION_ERROR_OPEN_SOURCE_SINK, tin, "%s: %s", fname, - strerror(errno)); - } + UNLOCK(st->streamlock); + if (errno == ENOENT && !strchr(io_mode, 'r')) { + PlIOError(EXISTENCE_ERROR_SOURCE_SINK, tin, "%s: %s", fname, + strerror(errno)); + } else { + PlIOError(PERMISSION_ERROR_OPEN_SOURCE_SINK, tin, "%s: %s", fname, + strerror(errno)); + } } st->vfs = NULL; } @@ -1644,9 +1646,9 @@ int Yap_OpenStream(Term tin, const char *io_mode, Term user_name, Yap_ThrowError(DOMAIN_ERROR_SOURCE_SINK, tin, "open"); } } - if (!strchr(io_mode, 'b') && binary_file(fname)) { - flags |= Binary_Stream_f; - } + if (!strchr(io_mode, 'b') && binary_file(fname)) { + flags |= Binary_Stream_f; + } Yap_initStream(sno, st->file, fname, io_mode, user_name, LOCAL_encoding, flags, vfsp); __android_log_print(ANDROID_LOG_INFO, "YAPDroid", "exists %s <%d>", fname, @@ -1761,8 +1763,8 @@ int Yap_CheckTextStream__(const char *file, const char *f, int line, Term arg, return sno; } -int Yap_CheckTextWriteStream__(const char *file, const char *f, int line, Term arg, - const char *msg) { +int Yap_CheckTextWriteStream__(const char *file, const char *f, int line, + Term arg, const char *msg) { int sno, kind = Output_Stream_f; if ((sno = CheckStream__(file, f, line, arg, kind, msg)) < 0) return -1; @@ -1779,8 +1781,8 @@ int Yap_CheckTextWriteStream__(const char *file, const char *f, int line, Term a return sno; } -int Yap_CheckTextReadStream__(const char *file, const char *f, int line, Term arg, - const char *msg) { +int Yap_CheckTextReadStream__(const char *file, const char *f, int line, + Term arg, const char *msg) { int sno, kind = Input_Stream_f; if ((sno = CheckStream__(file, f, line, arg, kind, msg)) < 0) return -1; diff --git a/packages/python/pyio.c b/packages/python/pyio.c index b7c1950d0..28cf54a04 100644 --- a/packages/python/pyio.c +++ b/packages/python/pyio.c @@ -10,9 +10,8 @@ YAP_Term TermErrStream, TermOutStream; static unsigned char *outbuf, *errbuf; -static void pyflush( StreamDesc *st) -{ - #if 0 +static void pyflush(StreamDesc *st) { +#if 0 st->u.w_irl.ptr[0] = '\0'; fprintf(stderr,"%s\n", st->u.w_irl.buf); term_t tg = python_acquire_GIL(); @@ -20,12 +19,11 @@ static void pyflush( StreamDesc *st) PySys_WriteStdout("%s", st->u.w_irl.buf); } else { PySys_WriteStderr("%s", st->u.w_irl.buf); - + } python_release_GIL(tg); st->u.w_irl.ptr = st->u.w_irl.buf; - #endif - +#endif } static int py_putc(int sno, int ch) { @@ -43,7 +41,7 @@ static int py_putc(int sno, int ch) { } return ch; } - #endif +#endif char s[2]; PyObject *err; s[0] = ch; @@ -96,31 +94,27 @@ static void *py_open(VFS_t *me, const char *name, const char *io_mode, // } else if (strcmp(name, "input") == 0) { //pystream = PyObject_Call(pystream, PyTuple_New(0), NULL); } else */ - { - st->user_name = YAP_MkAtomTerm(st->name); - } - st->u.private_data = pystream; + { st->user_name = YAP_MkAtomTerm(st->name); } + st->u.private_data = pystream; st->vfs = me; st->file = NULL; python_release_GIL(ctk); return st; } - static void py_flush(int sno) { StreamDesc *s = YAP_GetStreamFromId(sno); term_t tg = python_acquire_GIL(); PyObject *flush = PyObject_GetAttrString(s->u.private_data, "flush"); - pyflush(s); + pyflush(s); PyObject_CallFunction(flush, NULL); python_release_GIL(tg); } - static bool py_close(int sno) { StreamDesc *st = YAP_RepStreamFromId(sno); - if (st->status & (Output_Stream_f|Append_Stream_f)) - py_flush(sno); + if (st->status & (Output_Stream_f | Append_Stream_f)) + py_flush(sno); if (strcmp(st->name, "sys.stdout") && strcmp(st->name, "sys.stderr")) { Py_XDECREF(st->u.private_data); st->u.w_irl.buf = st->u.w_irl.ptr = NULL; @@ -137,13 +131,14 @@ static bool getLine(int inp) { term_t ctk = python_acquire_GIL(); Py_ssize_t size; PyObject *prompt = PyUnicode_FromString("?- "), - *msg = PyUnicode_FromString(" **input** "); + *msg = PyUnicode_FromString(" **input** "), + *o = PyObject_GetAttrString(rl_iostream->u.private_data, "read"); /* window of vulnerability opened */ - myrl_line = PyUnicode_AsUTF8AndSize(PyObject_CallFunctionObjArgs( - rl_instream->u.private_data, msg, prompt, NULL), &size); + myrl_line = PyUnicode_AsUTF8AndSize( + PyObject_CallFunctionObjArgs(o, msg, prompt, NULL), &size); python_release_GIL(ctk); rl_instream->u.irl.ptr = rl_instream->u.irl.buf = - (const unsigned char *)malloc(size); + (const unsigned char *)malloc(size); memcpy((void *)rl_instream->u.irl.buf, myrl_line, size); return true; } diff --git a/packages/python/yap_kernel/yap_ipython/prolog/jupyter.yap b/packages/python/yap_kernel/yap_ipython/prolog/jupyter.yap index abbf43f96..abc85b04e 100644 --- a/packages/python/yap_kernel/yap_ipython/prolog/jupyter.yap +++ b/packages/python/yap_kernel/yap_ipython/prolog/jupyter.yap @@ -26,13 +26,13 @@ jupyter_query(Caller, Cell, Line ) :- jupyter_cell(Caller, Cell, Line). -jupyter_cell(_Caller, Cell, _) :- +jupyter_cell(_Caller, Cell, _Line) :- jupyter_consult(Cell), %stack_dump, fail. +jupyter_cell( _Caller, _, '' ) :- !. jupyter_cell( _Caller, _, Line ) :- blank( Line ), !. -jupyter_cell( _Caller, _, '' ) :- !. jupyter_cell( Caller, _, Line ) :- Self := Caller.query, python_query(Self,Line). @@ -54,19 +54,13 @@ jupyter_consult(Text) :- jupyter_consult(Cell) :- % Name = 'Inp', % stream_property(Stream, file_name(Name) ), - setup_call_cleanup( +% setup_call_cleanup( open_mem_read_stream( Cell, Stream), - load_files(user:'jupyter cell',[stream(Stream)]), - close(Stream) - ). + load_files(user:'jupyter cell',[stream(Stream)]). blank(Text) :- atom_codes(Text, L), - maplist( blankc, L). - -blankc(' '). -blankc('\n'). -blankc('\t'). + maplist( code_type(space), L). :- dynamic cell_stream/1. diff --git a/pl/arith.yap b/pl/arith.yap index 533f1c2db..ab4a3f264 100644 --- a/pl/arith.yap +++ b/pl/arith.yap @@ -36,6 +36,7 @@ /** @defgroup CompilerAnalysis Internal Clause Rewriting @ingroup YAPCompilerSettings + @{ YAP supports several clause optimisation mechanisms, that are designed to improve execution of arithmetic @@ -59,7 +60,6 @@ */ -%% @{ /** @pred expand_exprs(- _O_,+ _N_) Control term expansion during compilation. diff --git a/pl/arithpreds.yap b/pl/arithpreds.yap index d06964a82..033cfdb97 100644 --- a/pl/arithpreds.yap +++ b/pl/arithpreds.yap @@ -15,14 +15,13 @@ * * *************************************************************************/ -%% @{ /** @file arithpreds.yap @addtogroup arithmetic_preds - + @{ */ :- system_module(arithmetic_predicates, [ diff --git a/pl/atoms.yap b/pl/atoms.yap index 14d21737a..1e2bc621b 100644 --- a/pl/atoms.yap +++ b/pl/atoms.yap @@ -26,7 +26,7 @@ /** * @addtogroup Predicates_on_Atoms - * + * @{ */ /** @pred atom_concat(+ As, ? A) diff --git a/pl/boot.yap b/pl/boot.yap index 5173424ca..794583e36 100644 --- a/pl/boot.yap +++ b/pl/boot.yap @@ -19,11 +19,11 @@ @file boot.yap @brief YAP bootstrap -@{ @addtogroup TopLevel Top-Level and Boot Predicates @ingroup builtins + @{ */ diff --git a/pl/bootutils.yap b/pl/bootutils.yap index ca97c0bdf..a4b3901de 100644 --- a/pl/bootutils.yap +++ b/pl/bootutils.yap @@ -3,6 +3,7 @@ @short utilities @addtogroup Internal_Database + @{ */ /** @pred recordaifnot(+ _K_, _T_,- _R_) @@ -41,3 +42,4 @@ recordzifnot(K,T,R) :- recordzifnot(K,T,R) :- recordz(K,T,R). +%% @} diff --git a/pl/builtins.yap b/pl/builtins.yap index 23d37f050..a0fe95c07 100644 --- a/pl/builtins.yap +++ b/pl/builtins.yap @@ -21,8 +21,7 @@ @addtogroup YAPControl Control Predicates @ingroup builtins - -@{ + @{ */ diff --git a/pl/callcount.yap b/pl/callcount.yap index f3891412c..d3ba19a37 100644 --- a/pl/callcount.yap +++ b/pl/callcount.yap @@ -39,11 +39,11 @@ implementation. */ -%% @{ - -/** @defgroup Call_Counting Counting Calls -@ingroup Profiling - +/** + @defgroup Call_Counting Counting Calls + @ingroup Profiling + @{ + Predicates compiled with YAP's flag call_counting set to `on` update counters on the numbers of calls and of retries. Counters are actually decreasing counters, so that they can be diff --git a/pl/checker.yap b/pl/checker.yap index 02bb5836f..0b45d6000 100644 --- a/pl/checker.yap +++ b/pl/checker.yap @@ -22,12 +22,11 @@ '$syntax_check_multiple'/2, '$syntax_check_single_var'/2]). -%% @{ - /** -@defgroup YAPStyle Checker - @ingroup YAPCompilerSettings + @defgroup YAPStyle Checker + @ingroup YAPCompilerSettings + @{ YAP implements a style-checker thay currently verifies whether: diff --git a/pl/control.yap b/pl/control.yap index 650e81969..34616d13f 100644 --- a/pl/control.yap +++ b/pl/control.yap @@ -83,11 +83,9 @@ @addtogroup YAPControl @ingroup builtins - +@{ */ -%% @{ - /** @pred forall(: _Cond_,: _Action_) diff --git a/pl/dbload.yap b/pl/dbload.yap index 4eb4a05e3..45a8e201e 100644 --- a/pl/dbload.yap +++ b/pl/dbload.yap @@ -30,10 +30,9 @@ %% % @defgroup YAPBigLoad Loading Large Tables % @ingroup YAPConsulting -% +% @{ % @brief Fast and Exo Loading % -% @{ /*! * @pred load_mega_clause( +Stream ) is detail diff --git a/pl/debug.yap b/pl/debug.yap index c90b36297..df53eec52 100644 --- a/pl/debug.yap +++ b/pl/debug.yap @@ -24,6 +24,7 @@ /** @defgroup Deb_Interaction Interacting with the debugger +@{ @ingroup YAPProgramming Debugging with YAP is similar to debugging with C-Prolog. Both systems @@ -237,6 +238,8 @@ be lost. */ + + /*----------------------------------------------------------------------------- spy diff --git a/pl/depth_bound.yap b/pl/depth_bound.yap index 1e4d8c96b..fb5c0b6c7 100644 --- a/pl/depth_bound.yap +++ b/pl/depth_bound.yap @@ -18,6 +18,7 @@ /** @defgroup DepthLimited Depth Limited Search +@{ @ingroup extensions YAP implements various extensions to the default Prolog search. One of @@ -27,9 +28,12 @@ the most iseful s restricting the maximum search depth. :- system_module( '$_depth_bound', [depth_bound_call/2], []). -%depth_bound_call(A,D) :- -%write(depth_bound_call(A,D)), nl, fail. +%% @pred depth_bound_call(A,D) +% +% CallError _A_ with maximum stack_el depth_reduction _B_. +% depth_bound_call(A,D) :- '$execute_under_depth_limit'(A,D). +%% @} diff --git a/pl/eam.yap b/pl/eam.yap index b294b9d15..e9e1cd71b 100755 --- a/pl/eam.yap +++ b/pl/eam.yap @@ -23,6 +23,7 @@ * * @brief Extended Abstract Machine * @defgroup EAM Extended Abstract Machine + * @{ * @ingroup extensions * * @@ -54,3 +55,5 @@ eamconsult(File):- eam, eam, %fails if eam is disable assert((user:term_expansion((A :- B),(A :- C)):- eamtrans(B,C))), eam, ( consult(File) ; true), eam, abolish(user:term_expansion,2). + +%% @} diff --git a/pl/hacks.yap b/pl/hacks.yap index f720d5b96..1ad678150 100644 --- a/pl/hacks.yap +++ b/pl/hacks.yap @@ -32,6 +32,7 @@ code_location/3]). /** + * @namespace yap_hacks * * @defgroup Hacks Low-level access * @ingroup builtins diff --git a/pl/listing.yap b/pl/listing.yap index d1a33a693..49816a9d9 100644 --- a/pl/listing.yap +++ b/pl/listing.yap @@ -25,27 +25,27 @@ */ -:- system_module( '$_listing', [listing/0, +/*:- system_module( '$_listing', [listing/0, listing/1, portray_clause/1, portray_clause/2], []). +*/ /** - * @defgroup Listing List predicates in a module - * @{ + * @defgroup listingGroup List predicates in a module + * * @ingroup builtins * + * @{ */ :- use_system_module( '$_errors', ['$do_error'/2]). - -:- use_system_module( '$_preds', ['$clause'/4, '$current_predicate'/4]). -/* listing : Listing clauses in the database - -*/ +/** @brief listing : Listing clauses in the database + * + */ /** @pred listing @@ -347,3 +347,5 @@ portray_clause(Clause) :- '$list_transform'(L,M). '$list_transform'([_|L],M) :- '$list_transform'(L,M). + +%% @}