Skip to content

Commit

Permalink
Ni is now for exec, Ni! for eval()
Browse files Browse the repository at this point in the history
  • Loading branch information
BartJongejan committed Jul 21, 2015
1 parent aaa5e79 commit 38622cc
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
31 changes: 21 additions & 10 deletions src/bracmat.c
Expand Up @@ -1919,7 +1919,8 @@ typedef struct
#endif
#if _BRACMATEMBEDDED
#if defined PYTHONINTERFACE
#define NI O('N','i',0)
#define NI O('N','i', 0 )
#define NII O('N','i','!')
#endif
#endif

Expand Down Expand Up @@ -3387,7 +3388,8 @@ static int (*WinIn)(void) = NULL;
static void (*WinOut)(int c) = NULL;
static void (*WinFlush)(void) = NULL;
#if defined PYTHONINTERFACE
static const char * (*Ni)(const char *) = NULL;
static void (*Ni)(const char *) = NULL;
static const char * (*Nii)(const char *) = NULL;
#endif
static int mygetc(FILE * fpi)
{
Expand Down Expand Up @@ -14410,17 +14412,22 @@ static function_return_type functies(psk pkn)
#endif
#if _BRACMATEMBEDDED
#if defined PYTHONINTERFACE
CASE(NI) /* Ni$"Expression to be evaluated by Python"*/
CASE(NI) /* Ni$"Statements to be executed by Python" */
{
if(Ni)
if(Ni && !is_op(rknoop) && !HAS_VISIBLE_FLAGS_OR_MINUS(rknoop))
{
Ni((const char *)POBJ(rknoop));
return functionOk(pkn);
}
else
return functionFail(pkn);
}
CASE(NII) /* Ni!$"Expression to be evaluated by Python" */
{
if(Nii && !is_op(rknoop) && !HAS_VISIBLE_FLAGS_OR_MINUS(rknoop))
{
const char * val;
if (is_op(rknoop)
|| HAS_VISIBLE_FLAGS_OR_MINUS(rknoop)
)
return functionFail(pkn);
errno = 0;
val = Ni((const char *)POBJ(rknoop));
val = Nii((const char *)POBJ(rknoop));
wis(pkn);
pkn = scopy((const char *)val);
return functionOk(pkn);
Expand Down Expand Up @@ -17563,6 +17570,10 @@ int startProc(
{
Ni = init->Ni;
}
if(init->Nii)
{
Nii = init->Nii;
}
#endif
}
#endif
Expand Down
3 changes: 2 additions & 1 deletion src/bracmat.h
Expand Up @@ -9,7 +9,8 @@ typedef struct startStruct
void (*WinOut)(int c);
void (*WinFlush)(void);
#if defined PYTHONINTERFACE
const char * (*Ni)(const char * str);
void (*Ni)(const char * str); /* exec */
const char * (*Nii)(const char * str); /* eval() */
#endif
} startStruct;

Expand Down

0 comments on commit 38622cc

Please sign in to comment.