Merge branch 'master' of https://github.com/vscosta/yap-6.3
This commit is contained in:
commit
f78ddb6724
5
C/text.c
5
C/text.c
@ -338,6 +338,11 @@ unsigned char *Yap_readText(seq_tv_t *inp, size_t *lengp) {
|
|||||||
return latin2utf8(inp, lengp);
|
return latin2utf8(inp, lengp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (IsStringTerm(inp->val.t) && inp->type & YAP_STRING_STRING) {
|
||||||
|
// this is a term, extract to a buffer, and representation is wide
|
||||||
|
//Yap_DebugPlWriteln(inp->val.t);
|
||||||
|
return UStringOfTerm(inp->val.t);
|
||||||
|
}
|
||||||
if (((inp->type & (YAP_STRING_CODES | YAP_STRING_ATOMS)) ==
|
if (((inp->type & (YAP_STRING_CODES | YAP_STRING_ATOMS)) ==
|
||||||
(YAP_STRING_CODES | YAP_STRING_ATOMS)) && IsPairTerm(inp->val.t)) {
|
(YAP_STRING_CODES | YAP_STRING_ATOMS)) && IsPairTerm(inp->val.t)) {
|
||||||
//Yap_DebugPlWriteln(inp->val.t);
|
//Yap_DebugPlWriteln(inp->val.t);
|
||||||
|
@ -209,8 +209,12 @@ X_API int PL_get_nchars(term_t l, size_t *lengthp, char **s, unsigned flags) {
|
|||||||
} else {
|
} else {
|
||||||
out.enc = ENC_ISO_LATIN1;
|
out.enc = ENC_ISO_LATIN1;
|
||||||
}
|
}
|
||||||
if (flags & BUF_MALLOC)
|
if (flags & BUF_MALLOC) {
|
||||||
out.type |= YAP_STRING_MALLOC;
|
out.type |= YAP_STRING_MALLOC;
|
||||||
|
out.val.c = *s;
|
||||||
|
} else {
|
||||||
|
out.val.c = NULL;
|
||||||
|
}
|
||||||
if (lengthp) {
|
if (lengthp) {
|
||||||
out.type |= YAP_STRING_NCHARS;
|
out.type |= YAP_STRING_NCHARS;
|
||||||
out.max = *lengthp;
|
out.max = *lengthp;
|
||||||
@ -232,8 +236,12 @@ int PL_get_wchars(term_t l, size_t *lengthp, wchar_t **s, unsigned flags) {
|
|||||||
inp.val.t = Yap_GetFromSlot(l);
|
inp.val.t = Yap_GetFromSlot(l);
|
||||||
inp.type = cvtFlags(flags);
|
inp.type = cvtFlags(flags);
|
||||||
out.type = YAP_STRING_WCHARS;
|
out.type = YAP_STRING_WCHARS;
|
||||||
if (flags & BUF_MALLOC)
|
if (flags & BUF_MALLOC) {
|
||||||
out.type |= YAP_STRING_MALLOC;
|
out.type |= YAP_STRING_MALLOC;
|
||||||
|
out.val.w = *s;
|
||||||
|
} else {
|
||||||
|
out.val.w = NULL;
|
||||||
|
}
|
||||||
if (lengthp) {
|
if (lengthp) {
|
||||||
out.type |= YAP_STRING_NCHARS;
|
out.type |= YAP_STRING_NCHARS;
|
||||||
out.max = *lengthp;
|
out.max = *lengthp;
|
||||||
|
12
packages/python/examples/plot.yap
Normal file
12
packages/python/examples/plot.yap
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
|
||||||
|
:- [library(python)].
|
||||||
|
|
||||||
|
main :-
|
||||||
|
Plt = matplotlib.pyplot,
|
||||||
|
:= import( Plt ),
|
||||||
|
:= (
|
||||||
|
Plt.plot([1,2,3,4]),
|
||||||
|
Plt.ylabel(`some numbers`),
|
||||||
|
Plt.show()
|
||||||
|
).
|
||||||
|
|
@ -634,7 +634,7 @@ static int python_import(term_t mname, term_t mod) {
|
|||||||
s = stpcpy(s, sa);
|
s = stpcpy(s, sa);
|
||||||
*s++ = '.';
|
*s++ = '.';
|
||||||
} else if (!PL_get_nchars(mname, &len, &s,
|
} else if (!PL_get_nchars(mname, &len, &s,
|
||||||
CVT_ALL | CVT_EXCEPTION | ENC_ISO_UTF8)) {
|
CVT_ALL | CVT_EXCEPTION | REP_UTF8)) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
|
@ -110,7 +110,10 @@ Data types are
|
|||||||
:- use_module(library(charsio)).
|
:- use_module(library(charsio)).
|
||||||
:- dynamic python_mref_cache/2, python_obj_cache/2.
|
:- dynamic python_mref_cache/2, python_obj_cache/2.
|
||||||
|
|
||||||
:= import( F ) :- python_import(F).
|
:= (P1,P2) :- !,
|
||||||
|
:= P1,
|
||||||
|
:= P2.
|
||||||
|
:= import( F ) :- !, python_import(F).
|
||||||
:= F :- python(F,_).
|
:= F :- python(F,_).
|
||||||
|
|
||||||
V := F :- var(V), !, python(F,V0),
|
V := F :- var(V), !, python(F,V0),
|
||||||
|
Reference in New Issue
Block a user