Merge branch 'master' of https://github.com/vscosta/yap-6.3
This commit is contained in:
commit
f1372f72b5
@ -2149,14 +2149,13 @@ X_API YAP_Term YAP_CopyTerm(Term t) {
|
||||
X_API char *YAP_WriteBuffer(Term t, char *buf, size_t sze, int flags) {
|
||||
CACHE_REGS
|
||||
seq_tv_t inp, out;
|
||||
size_t length = sze;
|
||||
char *b;
|
||||
|
||||
BACKUP_MACHINE_REGS();
|
||||
inp.val.t = t;
|
||||
inp.type = YAP_STRING_TERM;
|
||||
out.type = YAP_STRING_CHARS;
|
||||
out.val.c = buf;
|
||||
out.max = sze-1;
|
||||
out.enc = LOCAL_encoding;
|
||||
if (!Yap_CVT_Text(&inp, &out PASS_REGS))
|
||||
return NULL;
|
||||
|
@ -98,6 +98,7 @@ check_include_file(sys/types.h HAVE_SYS_TYPES_H)
|
||||
check_include_file(sys/ucontext.h HAVE_SYS_UCONTEXT_H)
|
||||
check_include_file(sys/un.h HAVE_SYS_UN_H)
|
||||
check_include_file(sys/wait.h HAVE_SYS_WAIT_H)
|
||||
check_include_file(termios.h HAVE_TERMIOS_H)
|
||||
check_include_file(time.h HAVE_TIME_H)
|
||||
check_include_file(ucontext.h HAVE_UCONTEXT_H)
|
||||
check_include_file(unistd.h HAVE_UNISTD_H)
|
||||
@ -363,6 +364,7 @@ check_function_exists(strnlen HAVE_STRNLEN)
|
||||
check_function_exists(strtod HAVE_STRTOD)
|
||||
check_function_exists(struct_time_tm_gmtoff HAVE_STRUCT_TIME_TM_GMTOFF)
|
||||
check_function_exists(system HAVE_SYSTEM)
|
||||
check_function_exists(tcflush HAVE_TCFLUSH)
|
||||
check_function_exists(time HAVE_TIME)
|
||||
check_function_exists(timegm HAVE_TIMEGM)
|
||||
check_function_exists(times HAVE_TIMES)
|
||||
|
@ -1365,6 +1365,11 @@ signal. */
|
||||
#cmakedefine HAVE_STRTOD ${HAVE_STRTOD}
|
||||
#endif
|
||||
|
||||
/* Define to 1 if you have the `tcflush' function. */
|
||||
#ifndef HAVE_TCFLUSH
|
||||
#cmakedefine HAVE_TCFLUSH ${HAVE_TCFLUSH}
|
||||
#endif
|
||||
|
||||
/* Define is struct tm has tm_gmtoff */
|
||||
#ifndef HAVE_STRUCT_TIME_TM_GMTOFF
|
||||
#cmakedefine HAVE_STRUCT_TIME_TM_GMTOFF ${HAVE_STRUCT_TIME_TM_GMTOFF}
|
||||
@ -1442,6 +1447,11 @@ signal. */
|
||||
#cmakedefine HAVE_SYS_SYSCALL_H ${HAVE_SYS_SYSCALL_H}
|
||||
#endif
|
||||
|
||||
/* Define to 1 if you have the <termios.h> header file. */
|
||||
#ifndef HAVE_TERMIOS_H
|
||||
#cmakedefine HAVE_TERMIOS_H ${HAVE_TERMIOS_H}
|
||||
#endif
|
||||
|
||||
/* Define to 1 if you have the <sys/times.h> header file. */
|
||||
#ifndef HAVE_SYS_TIMES_H
|
||||
#cmakedefine HAVE_SYS_TIMES_H ${HAVE_SYS_TIMES_H}
|
||||
|
@ -14,7 +14,7 @@ $( document ).ready(function() {
|
||||
$('li > a[href="functions_func.html"] > span').before("<i class='fa fa-list'></i> ");
|
||||
$('li > a[href="functions_vars.html"] > span').before("<i class='fa fa-list'></i> ");
|
||||
$('li > a[href="functions_enum.html"] > span').before("<i class='fa fa-list'></i> ");
|
||||
$('li > a[href="functions_eval.html"] > span').before("<i class='fa fa-list'></i> ");
|
||||
$('li > a[href="functions_YapEval.html"] > span').before("<i class='fa fa-list'></i> ");
|
||||
$('img[src="ftv2ns.png"]').replaceWith('<span class="label label-danger">N</span> ');
|
||||
$('img[src="ftv2cl.png"]').replaceWith('<span class="label label-danger">C</span> ');
|
||||
|
||||
|
@ -14,7 +14,7 @@ $( document ).ready(function() {
|
||||
$('li > a[href="functions_func.html"] > span').before("<i class='fa fa-list'></i> ");
|
||||
$('li > a[href="functions_vars.html"] > span').before("<i class='fa fa-list'></i> ");
|
||||
$('li > a[href="functions_enum.html"] > span').before("<i class='fa fa-list'></i> ");
|
||||
$('li > a[href="functions_eval.html"] > span').before("<i class='fa fa-list'></i> ");
|
||||
$('li > a[href="functions_YapEval.html"] > span').before("<i class='fa fa-list'></i> ");
|
||||
$('img[src="ftv2ns.png"]').replaceWith('<span class="label label-danger">N</span> ');
|
||||
$('img[src="ftv2cl.png"]').replaceWith('<span class="label label-danger">C</span> ');
|
||||
|
||||
|
18
os/console.c
18
os/console.c
@ -45,14 +45,12 @@ static int ConsolePutc(int, int);
|
||||
bool Yap_DoPrompt(StreamDesc *s) {
|
||||
if (s->status & Tty_Stream_f) {
|
||||
if (GLOBAL_Stream[0].status & Tty_Stream_f &&
|
||||
s->name == GLOBAL_Stream[0].name)
|
||||
return true;
|
||||
if (GLOBAL_Stream[1].status & Tty_Stream_f &&
|
||||
s->name == GLOBAL_Stream[1].name)
|
||||
return true;
|
||||
if (GLOBAL_Stream[2].status & Tty_Stream_f &&
|
||||
s->name == GLOBAL_Stream[2].name)
|
||||
return true;
|
||||
s->name == GLOBAL_Stream[0].name &&
|
||||
((GLOBAL_Stream[1].status & Tty_Stream_f ||
|
||||
s->name == GLOBAL_Stream[1].name) ||
|
||||
(GLOBAL_Stream[2].status & Tty_Stream_f &&
|
||||
s->name == GLOBAL_Stream[2].name)))
|
||||
return LOCAL_newline;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -62,6 +60,10 @@ bool Yap_DoPrompt(StreamDesc *s) {
|
||||
int console_post_process_read_char(int ch, StreamDesc *s) {
|
||||
/* the character is also going to be output by the console handler */
|
||||
console_count_output_char(ch, GLOBAL_Stream + StdErrStream);
|
||||
if (ch == '\r') {
|
||||
s->linepos = 0;
|
||||
LOCAL_newline = true;
|
||||
} else
|
||||
if (ch == '\n') {
|
||||
CACHE_REGS
|
||||
++s->linecount;
|
||||
|
@ -134,7 +134,8 @@ extern void Yap_InitSocketLayer(void);
|
||||
extern void Yap_InitMems(void);
|
||||
extern void Yap_InitConsole(void);
|
||||
extern void Yap_InitReadlinePreds(void);
|
||||
bool Yap_InitReadline(Term);
|
||||
extern bool Yap_InitReadline(Term);
|
||||
extern bool Yap_readline_clear_pending_input (StreamDesc *s);
|
||||
extern void Yap_InitChtypes(void);
|
||||
extern void Yap_InitCharsio(void);
|
||||
extern void Yap_InitFormat(void);
|
||||
|
@ -251,6 +251,15 @@ void Yap_ReadlineFlush(int sno) {
|
||||
}
|
||||
}
|
||||
|
||||
bool Yap_readline_clear_pending_input(StreamDesc *s) {
|
||||
rl_clear_pending_input();
|
||||
if (s->u.irl.buf) {
|
||||
free( ( void *)s->u.irl.buf );
|
||||
}
|
||||
s->u.irl.ptr = s->u.irl.buf = NULL;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Yap_ReadlineOps(StreamDesc *s) {
|
||||
if (s->status & Tty_Stream_f) {
|
||||
if (GLOBAL_Stream[0].status & (Input_Stream_f | Tty_Stream_f) &&
|
||||
|
35
os/streams.c
35
os/streams.c
@ -68,6 +68,9 @@ static char SccsId[] = "%W% %G%";
|
||||
#if HAVE_SIGNAL_H
|
||||
#include <signal.h>
|
||||
#endif
|
||||
#if HAVE_TERMIOS_H
|
||||
#include <termios.h>
|
||||
#endif
|
||||
#ifdef _WIN32
|
||||
#if HAVE_IO_H
|
||||
/* Windows */
|
||||
@ -146,6 +149,34 @@ int GetFreeStreamD(void) {
|
||||
|
||||
int Yap_GetFreeStreamD(void) { return GetFreeStreamD(); }
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
static bool clearInput(int sno)
|
||||
{
|
||||
if (!(GLOBAL_Stream[sno].status & Tty_Stream_f))
|
||||
return true;
|
||||
#if USE_READLINE
|
||||
if (GLOBAL_Stream[sno].status & Readline_Stream_f)
|
||||
return Yap_readline_clear_pending_input (GLOBAL_Stream+sno);
|
||||
#endif
|
||||
#if HAVE_TCFLUSH
|
||||
return tcflush(fileno(GLOBAL_Stream[sno].file), TCIOFLUSH) == 0;
|
||||
#elif MSC_VER
|
||||
return fflush(GLOBAL_Stream[sno].file) == 0;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
static Int clear_input( USES_REGS1 )
|
||||
{
|
||||
int sno = Yap_CheckStream(ARG1, Input_Stream_f | Socket_Stream_f,
|
||||
"clear_input/1");
|
||||
if (sno != -1)
|
||||
UNLOCK(GLOBAL_Stream[sno].streamlock);
|
||||
return clearInput(sno);
|
||||
}
|
||||
|
||||
static Term lineCount(int sno) {
|
||||
Term tout;
|
||||
/* one has to be somewhat more careful because of terminals */
|
||||
@ -1017,6 +1048,8 @@ static Int set_output(USES_REGS1) { /* '$show_stream_position'(+Stream,Pos) */
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static Int p_user_file_name(USES_REGS1) {
|
||||
Term tout;
|
||||
int sno =
|
||||
@ -1436,6 +1469,8 @@ void Yap_InitIOStreams(void) {
|
||||
Yap_InitCPred("set_input", 1, set_input, SafePredFlag | SyncPredFlag);
|
||||
Yap_InitCPred("set_output", 1, set_output, SafePredFlag | SyncPredFlag);
|
||||
Yap_InitCPred("$stream", 1, p_stream, SafePredFlag | TestPredFlag);
|
||||
Yap_InitCPred("$clear_input", 1, clear_input, SafePredFlag | TestPredFlag);
|
||||
|
||||
#if HAVE_SELECT
|
||||
Yap_InitCPred("stream_select", 3, p_stream_select,
|
||||
SafePredFlag | SyncPredFlag);
|
||||
|
@ -82,7 +82,7 @@ namespace generic_gecode
|
||||
|
||||
struct GenericRestartDFS: GenericEngine
|
||||
{
|
||||
RBS<DFS,GenericSpace> engine;
|
||||
RBS<GenericSpace,DFS> engine;
|
||||
GenericRestartDFS(GenericSpace* s,Search::Options& opt) : engine(s,opt) {}
|
||||
virtual GenericSpace* next(void) { return engine.next(); }
|
||||
};
|
||||
@ -96,7 +96,7 @@ namespace generic_gecode
|
||||
|
||||
struct GenericRestartBAB: GenericEngine
|
||||
{
|
||||
RBS<BAB,GenericSpace> engine;
|
||||
RBS<GenericSpace,BAB> engine;
|
||||
GenericRestartBAB(GenericSpace* s,Search::Options& opt) : engine(s,opt) {}
|
||||
virtual GenericSpace* next(void) { return engine.next(); }
|
||||
};
|
||||
|
@ -16,7 +16,7 @@
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//=============================================================================
|
||||
|
||||
#include "gecode4-common.icc"
|
||||
#include "gecode5-common.icc"
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
using namespace generic_gecode;
|
||||
|
@ -1,21 +0,0 @@
|
||||
|
||||
:- use_module( library(python) ).
|
||||
|
||||
:- := import( collections ).
|
||||
:- := import( yap ).
|
||||
:- e := yap.'YAPEngine'().
|
||||
|
||||
main :-
|
||||
system_predicate(N/A),
|
||||
args(0,A,L),
|
||||
N := namedtuple( N, L),
|
||||
fail.
|
||||
main :-
|
||||
:= e.call( writeln( 1 ) ).
|
||||
|
||||
args(N, N, []) :- !.
|
||||
args(I0,IF,[AI|Ais]) :-
|
||||
I is I0+1,
|
||||
number_string(I, IS),
|
||||
string_concat("A", IS, AI),
|
||||
args(I, IF, Ais).
|
@ -53,7 +53,7 @@ PyObject *term_to_python(term_t t, bool eval, PyObject *o) {
|
||||
*/
|
||||
} else
|
||||
{
|
||||
PyObject *o = PythonLookupSpecial(s);
|
||||
o = PythonLookupSpecial(s);
|
||||
}
|
||||
if (o) {
|
||||
Py_INCREF( o );
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -115,8 +115,6 @@ PyObject *PythonLookup(const char *s, PyObject *oo) {
|
||||
|
||||
PyObject *find_obj(PyObject *ob, term_t l, bool eval) {
|
||||
YAP_Term hd, yt;
|
||||
bool may_be_package = true;
|
||||
|
||||
|
||||
py_Context = NULL;
|
||||
yt = YAP_GetFromSlot(l);
|
||||
@ -582,7 +580,7 @@ static long get_len_of_range(long lo, long hi, long step) {
|
||||
return n;
|
||||
}
|
||||
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
#if PY_MAJOR_VERSION >= 3 && defined(USE_NAMEDTUPLES)
|
||||
static PyStructSequence_Field pnull[] = {
|
||||
{"A1", NULL}, {"A2", NULL}, {"A3", NULL}, {"A4", NULL},
|
||||
{"A5", NULL}, {"A6", NULL}, {"A7", NULL}, {"A8", NULL},
|
||||
|
@ -77,7 +77,8 @@ static void install_py_constants(void) {
|
||||
Py_INCREF(py_Builtin);
|
||||
py_ModDict = PyObject_GetAttrString(py_Sys, "modules");
|
||||
py_Yapex = PyImport_ImportModule("yapex");
|
||||
PyObject *py_Yap = PyImport_ImportModule("yap");
|
||||
// PyObject *py_Yap =
|
||||
PyImport_ImportModule("yap");
|
||||
Py_INCREF(py_Yapex);
|
||||
//py_F2P = PyObject_GetAttrString(py_Yap, "globals");
|
||||
py_F2P = NULL;
|
||||
|
@ -1,44 +0,0 @@
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
|
||||
try:
|
||||
from jupyter_client.kernelspec import install_kernel_spec
|
||||
except ImportError:
|
||||
from IPython.kernel.kernelspec import install_kernel_spec
|
||||
from IPython.utils.tempdir import TemporaryDirectory
|
||||
|
||||
|
||||
kernel_json = {
|
||||
"argv": [sys.executable,
|
||||
"-m", "yap_kernel",
|
||||
"-f", "{connection_file}"],
|
||||
"display_name": "yap",
|
||||
"mimetype": "text/x-prolog",
|
||||
"language": "prolog",
|
||||
"name": "yap",
|
||||
}
|
||||
|
||||
def install_my_kernel_spec(user=False):
|
||||
with TemporaryDirectory() as td:
|
||||
os.chmod(td, 0o755) # Starts off as 700, not user readable
|
||||
with open(os.path.join(td, 'kernel.json'), 'w') as f:
|
||||
json.dump(kernel_json, f, sort_keys=True)
|
||||
# TODO: Copy resources once they're specified
|
||||
|
||||
print('Installing IPython kernel spec')
|
||||
install_kernel_spec(td, 'yap', user=False, replace=True)
|
||||
|
||||
def _is_root():
|
||||
return True
|
||||
try:
|
||||
return os.geteuid() == 0
|
||||
except AttributeError:
|
||||
return False # assume not an admin on non-Unix platforms
|
||||
|
||||
def main(argv=[]):
|
||||
user = '--user' in argv or not _is_root()
|
||||
install_my_kernel_spec(user=user)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main(argv=sys.argv)
|
@ -847,12 +847,14 @@ number of steps.
|
||||
format(user_error,'.~n', []).
|
||||
|
||||
'$another' :-
|
||||
'$clear_input'(user_input),
|
||||
format(user_error,' ? ',[]),
|
||||
get0(user_input,C),
|
||||
get_code(user_input,C),
|
||||
'$do_another'(C).
|
||||
|
||||
'$do_another'(C) :-
|
||||
( C== 0'; -> skip(user_input,10), %'
|
||||
( C=:= ";" ->
|
||||
skip(user_input,10), %
|
||||
% '$add_nl_outside_console',
|
||||
fail
|
||||
;
|
||||
@ -1390,6 +1392,7 @@ Command = (H --> B) ->
|
||||
|
||||
|
||||
'$enter_command'(Stream, Mod, Status) :-
|
||||
'$clear_input'(Stream),
|
||||
prompt1(': '), prompt(_,' '),
|
||||
Options = [module(Mod), syntax_errors(dec10),variable_names(Vars), term_position(Pos)],
|
||||
(
|
||||
|
Reference in New Issue
Block a user