Merge 192.168.1.79:github/yap-6.3
This commit is contained in:
commit
4db414a05a
10
C/errors.c
10
C/errors.c
@ -40,7 +40,9 @@ bool Yap_Warning(const char *s, ...) {
|
||||
Term ts[2];
|
||||
const char *fmt;
|
||||
char tmpbuf[MAXPATHLEN];
|
||||
yap_error_descriptor_t olde;
|
||||
|
||||
Yap_pushErrorContext(&olde);
|
||||
LOCAL_DoingUndefp = true;
|
||||
LOCAL_within_print_message = true;
|
||||
pred = RepPredProp(PredPropByFunc(FunctorPrintMessage,
|
||||
@ -53,20 +55,24 @@ bool Yap_Warning(const char *s, ...) {
|
||||
#else
|
||||
(void)vsprintf(tmpbuf, fmt, ap);
|
||||
#endif
|
||||
} else
|
||||
} else {
|
||||
Yap_popErrorContext(false);
|
||||
return false;
|
||||
}
|
||||
va_end(ap);
|
||||
if (pred->OpcodeOfPred == UNDEF_OPCODE || pred->OpcodeOfPred == FAIL_OPCODE) {
|
||||
fprintf(stderr, "warning message: %s\n", tmpbuf);
|
||||
LOCAL_DoingUndefp = false;
|
||||
LOCAL_within_print_message = false;
|
||||
Yap_popErrorContext(false);
|
||||
return false;
|
||||
}
|
||||
|
||||
ts[1] = MkAtomTerm(AtomWarning);
|
||||
ts[0] = MkAtomTerm(Yap_LookupAtom(tmpbuf));
|
||||
rc = Yap_execute_pred(pred, ts, true PASS_REGS);
|
||||
return rc;
|
||||
Yap_popErrorContext(false);
|
||||
return rc;
|
||||
}
|
||||
|
||||
void Yap_InitError__(const char *file, const char *function, int lineno, yap_error_number e, Term t, ...) {
|
||||
|
@ -27,7 +27,8 @@ PyObject *py_ModDict;
|
||||
|
||||
VFS_t pystream;
|
||||
|
||||
static void *py_open(VFS_t *me, int sno, const char *name,
|
||||
static void *
|
||||
py_open(VFS_t *me, int sno, const char *name,
|
||||
const char *io_mode) {
|
||||
#if HAVE_STRCASESTR
|
||||
if (strcasestr(name, "//python/") == name)
|
||||
@ -37,6 +38,7 @@ static void *py_open(VFS_t *me, int sno, const char *name,
|
||||
name += strlen("//python/");
|
||||
#endif
|
||||
StreamDesc *st = YAP_RepStreamFromId(sno);
|
||||
fprintf(stderr,"opened %p\n");
|
||||
// we assume object is already open, so there is no need to open it.
|
||||
PyObject *stream = string_to_python(name, true, NULL);
|
||||
if (stream == Py_None)
|
||||
@ -44,12 +46,16 @@ static void *py_open(VFS_t *me, int sno, const char *name,
|
||||
Py_INCREF(stream);
|
||||
st->u.private_data = stream;
|
||||
st->vfs = me;
|
||||
if (strchr(io_mode,'r'))
|
||||
st->status = Input_Stream_f;
|
||||
else
|
||||
st->status = Append_Stream_f | Output_Stream_f;
|
||||
Yap_DefaultStreamOps(st);
|
||||
return stream;
|
||||
}
|
||||
|
||||
static bool py_close(int sno) {
|
||||
static bool
|
||||
py_close(int sno) {
|
||||
return true;
|
||||
StreamDesc *s = YAP_GetStreamFromId(sno);
|
||||
PyObject *fclose = PyObject_GetAttrString(s->u.private_data, "close");
|
||||
@ -58,7 +64,8 @@ static bool py_close(int sno) {
|
||||
return v;
|
||||
}
|
||||
|
||||
static int py_put(int sno, int ch) {
|
||||
static int
|
||||
py_put(int sno, int ch) {
|
||||
// PyObject *pyw; // buffer
|
||||
// int pyw_kind;
|
||||
// PyObject *pyw_data;
|
||||
|
@ -182,7 +182,6 @@ class YAPShell:
|
||||
self.port = "call"
|
||||
# launch the query
|
||||
while self.answer(q):
|
||||
print( self.port )
|
||||
if self.port == "exit":
|
||||
# done
|
||||
q.close()
|
||||
|
@ -61,12 +61,12 @@ blankc('\n').
|
||||
blankc('\t').
|
||||
|
||||
enter_cell(_Self) :-
|
||||
%open('//python/input', read, _Input, []),
|
||||
open('//python/sys.stdout', append, _Output, []),
|
||||
open('//python/sys.stdout', append, _Error, []),
|
||||
%set_prolog_flag(user_input, _Input),
|
||||
set_prolog_flag(user_output, _Output),
|
||||
set_prolog_flag(user_error, _Error).
|
||||
open('//python/input', read, Input, []),
|
||||
open('//python/sys.stdout', append, Output, []),
|
||||
open('//python/sys.stdout', append, Error, []),
|
||||
set_prolog_flag(user_input, Input),
|
||||
set_prolog_flag(user_output, Output),
|
||||
set_prolog_flag(user_error, Error).
|
||||
|
||||
exit_cell(_Self) :-
|
||||
%close( user_input),
|
||||
@ -239,14 +239,21 @@ optype(yf,pos).
|
||||
|
||||
:- dynamic syntax_error/4, undo/1.
|
||||
|
||||
user:portray_message(_Severity, error(syntax_error(Cause),info(between(_,LN,_), _FileName, CharPos, Details))) :-
|
||||
nb_getval(jupyter_cell, on),
|
||||
assert( syntax_error(Cause,LN,CharPos,Details) ).
|
||||
user:portray_message(_Severity, error(style_check(_),_) ) :-
|
||||
nb_getval(jupyter_cell, on).
|
||||
|
||||
open_events(Self, Text, Stream) :-
|
||||
Self.errors := [],
|
||||
open_mem_read_stream( Text, Stream ),
|
||||
assert((user:portray_message(_Severity, error(syntax_error(Cause),info(between(_,LN,_), _FileName, CharPos, Details))) :-
|
||||
assert( syntax_error(Cause,LN,CharPos,Details) )
|
||||
)).
|
||||
Self.errors := [],
|
||||
nb_setval( jupyter, on),
|
||||
open_mem_read_stream( Text, Stream ).
|
||||
|
||||
:- initialization( nb_setval( jupyter, off ) ).
|
||||
|
||||
close_events( _Self ) :-
|
||||
nb_setval( jupyter, off ),
|
||||
retract( undo(G) ),
|
||||
call(G),
|
||||
fail.
|
||||
@ -255,3 +262,5 @@ close_events( Self ) :-
|
||||
Self.errors := [t(C,L,N,A)] + Self.errors,
|
||||
fail.
|
||||
close_events( _ ).
|
||||
|
||||
:- ( start_low_level_trace ).
|
||||
|
Reference in New Issue
Block a user