Renamining
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@102 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
230231d91f
commit
cc85906a83
3 changed files with 124 additions and 126 deletions
|
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
static char cvsroot[] = "$Header$";
|
static char cvsroot[] = "$Header$";
|
||||||
|
|
||||||
#include "swigcpp.h"
|
#include "preprocessor.h"
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
|
|
@ -42,7 +42,7 @@ static DOH *included_files = 0;
|
||||||
|
|
||||||
/* Handle an error */
|
/* Handle an error */
|
||||||
|
|
||||||
void cpp_error(DOH *file, int line, char *fmt, ...) {
|
static void cpp_error(DOH *file, int line, char *fmt, ...) {
|
||||||
va_list ap;
|
va_list ap;
|
||||||
if (silent_errors) return;
|
if (silent_errors) return;
|
||||||
va_start(ap,fmt);
|
va_start(ap,fmt);
|
||||||
|
|
@ -109,7 +109,7 @@ static DOH *cpp_include(DOH *fn) {
|
||||||
if (Getattr(included_files,fn)) return 0;
|
if (Getattr(included_files,fn)) return 0;
|
||||||
Setattr(included_files,fn,fn);
|
Setattr(included_files,fn,fn);
|
||||||
}
|
}
|
||||||
s = SWIG_include(fn);
|
s = Swig_include(fn);
|
||||||
if (!s) {
|
if (!s) {
|
||||||
Seek(fn,0,SEEK_SET);
|
Seek(fn,0,SEEK_SET);
|
||||||
cpp_error(Getfile(fn),Getline(fn),"Unable to find '%s'\n", fn);
|
cpp_error(Getfile(fn),Getline(fn),"Unable to find '%s'\n", fn);
|
||||||
|
|
@ -120,31 +120,31 @@ static DOH *cpp_include(DOH *fn) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
* void SWIG_cpp_init() - Initialize the preprocessor
|
* void Preprocessor_cpp_init() - Initialize the preprocessor
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
void SWIG_cpp_init() {
|
void Preprocessor_init() {
|
||||||
DOH *s;
|
DOH *s;
|
||||||
cpp = NewHash();
|
cpp = NewHash();
|
||||||
s = NewHash();
|
s = NewHash();
|
||||||
Setattr(cpp,"symbols",s);
|
Setattr(cpp,"symbols",s);
|
||||||
SWIG_expr_init(); /* Initialize the expression evaluator */
|
Preprocessor_expr_init(); /* Initialize the expression evaluator */
|
||||||
included_files = NewHash();
|
included_files = NewHash();
|
||||||
}
|
}
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
* void SWIG_cpp_include_all() - Instruct preprocessor to include all files
|
* void Preprocessor_include_all() - Instruct preprocessor to include all files
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
void SWIG_cpp_include_all(int a) {
|
void Preprocessor_include_all(int a) {
|
||||||
include_all = a;
|
include_all = a;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
* DOH *SWIG_cpp_define(DOH *str, int swigmacro)
|
* DOH *Preprocessor_define(DOH *str, int swigmacro)
|
||||||
*
|
*
|
||||||
* Defines a new C preprocessor symbol. swigmacro specifies whether or not the macro has
|
* Defines a new C preprocessor symbol. swigmacro specifies whether or not the macro has
|
||||||
* SWIG macro semantics.
|
* SWIG macro semantics.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
DOH *SWIG_cpp_define(DOH *str, int swigmacro)
|
DOH *Preprocessor_define(DOH *str, int swigmacro)
|
||||||
{
|
{
|
||||||
DOH *macroname = 0, *argstr = 0, *macrovalue = 0, *arglist = 0, *macro = 0, *symbols = 0, *file = 0, *s, *m1;
|
DOH *macroname = 0, *argstr = 0, *macrovalue = 0, *arglist = 0, *macro = 0, *symbols = 0, *file = 0, *s, *m1;
|
||||||
int c, line;
|
int c, line;
|
||||||
|
|
@ -261,11 +261,11 @@ macro_error:
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
* void SWIG_cpp_undef(DOH *str)
|
* void Preprocessor_undef(DOH *str)
|
||||||
*
|
*
|
||||||
* Undefines a macro.
|
* Undefines a macro.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
void SWIG_cpp_undef(DOH *str)
|
void Preprocessor_undef(DOH *str)
|
||||||
{
|
{
|
||||||
DOH *symbols;
|
DOH *symbols;
|
||||||
assert(cpp);
|
assert(cpp);
|
||||||
|
|
@ -384,12 +384,12 @@ get_filename(DOH *str) {
|
||||||
|
|
||||||
DOH *expanded_value = 0;
|
DOH *expanded_value = 0;
|
||||||
|
|
||||||
DOH *
|
static DOH *
|
||||||
expand_macro(DOH *name, DOH *args)
|
expand_macro(DOH *name, DOH *args)
|
||||||
{
|
{
|
||||||
DOH *symbols, *ns, *macro, *margs, *mvalue, *temp, *tempa, *e;
|
DOH *symbols, *ns, *macro, *margs, *mvalue, *temp, *tempa, *e;
|
||||||
DOH *swig_cpp_replace(DOH *);
|
DOH *Preprocessor_replace(DOH *);
|
||||||
DOH *SWIG_cpp_parse(DOH *);
|
DOH *Preprocessor_parse(DOH *);
|
||||||
int i, l;
|
int i, l;
|
||||||
|
|
||||||
symbols = Getattr(cpp,"symbols");
|
symbols = Getattr(cpp,"symbols");
|
||||||
|
|
@ -464,7 +464,7 @@ expand_macro(DOH *name, DOH *args)
|
||||||
Replace(ns,"\001","#",DOH_REPLACE_ANY); /* Put # back (non-standard C) */
|
Replace(ns,"\001","#",DOH_REPLACE_ANY); /* Put # back (non-standard C) */
|
||||||
|
|
||||||
/* Expand this macro even further */
|
/* Expand this macro even further */
|
||||||
e = swig_cpp_replace(ns);
|
e = Preprocessor_replace(ns);
|
||||||
Delattr(macro,"*expanded*");
|
Delattr(macro,"*expanded*");
|
||||||
if (Getattr(macro,"swigmacro")) {
|
if (Getattr(macro,"swigmacro")) {
|
||||||
DOH *g;
|
DOH *g;
|
||||||
|
|
@ -472,7 +472,7 @@ expand_macro(DOH *name, DOH *args)
|
||||||
Printf(f,"%%macro %s, \"%s\", %d {\n", name, Getfile(macro), Getline(macro));
|
Printf(f,"%%macro %s, \"%s\", %d {\n", name, Getfile(macro), Getline(macro));
|
||||||
Seek(e,0,SEEK_SET);
|
Seek(e,0,SEEK_SET);
|
||||||
copy_location(macro,e);
|
copy_location(macro,e);
|
||||||
g = SWIG_cpp_parse(e);
|
g = Preprocessor_parse(e);
|
||||||
Printf(f,"%s\n", g);
|
Printf(f,"%s\n", g);
|
||||||
Printf(f,"}\n");
|
Printf(f,"}\n");
|
||||||
e = f;
|
e = f;
|
||||||
|
|
@ -481,7 +481,7 @@ expand_macro(DOH *name, DOH *args)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
* DOH *swig_cpp_replace(DOH *s)
|
* DOH *Preprocessor_replace(DOH *s)
|
||||||
*
|
*
|
||||||
* Performs a macro substitution on a string s. Returns a new string with
|
* Performs a macro substitution on a string s. Returns a new string with
|
||||||
* substitutions applied. This function works by walking down s and looking
|
* substitutions applied. This function works by walking down s and looking
|
||||||
|
|
@ -490,7 +490,7 @@ expand_macro(DOH *name, DOH *args)
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
DOH *
|
DOH *
|
||||||
swig_cpp_replace(DOH *s)
|
Preprocessor_replace(DOH *s)
|
||||||
{
|
{
|
||||||
DOH *ns, *id, *symbols, *m;
|
DOH *ns, *id, *symbols, *m;
|
||||||
int c, i, state = 0;
|
int c, i, state = 0;
|
||||||
|
|
@ -727,7 +727,7 @@ static void add_chunk(DOH *ns, DOH *chunk, int allow) {
|
||||||
DOH *echunk;
|
DOH *echunk;
|
||||||
Seek(chunk,0,SEEK_SET);
|
Seek(chunk,0,SEEK_SET);
|
||||||
if (allow) {
|
if (allow) {
|
||||||
echunk = swig_cpp_replace(chunk);
|
echunk = Preprocessor_replace(chunk);
|
||||||
addline(ns,echunk,allow);
|
addline(ns,echunk,allow);
|
||||||
Delete(echunk);
|
Delete(echunk);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -737,7 +737,7 @@ static void add_chunk(DOH *ns, DOH *chunk, int allow) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
* DOH *SWIG_cpp_parse(DOH *s)
|
* DOH *Preprocessor_parse(DOH *s)
|
||||||
*
|
*
|
||||||
* Parses the string s. Returns a new string containing the preprocessed version.
|
* Parses the string s. Returns a new string containing the preprocessed version.
|
||||||
*
|
*
|
||||||
|
|
@ -750,7 +750,7 @@ static void add_chunk(DOH *ns, DOH *chunk, int allow) {
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
DOH *
|
DOH *
|
||||||
SWIG_cpp_parse(DOH *s)
|
Preprocessor_parse(DOH *s)
|
||||||
{
|
{
|
||||||
DOH *ns; /* New string containing the preprocessed text */
|
DOH *ns; /* New string containing the preprocessed text */
|
||||||
DOH *chunk, *symbols, *sval, *decl;
|
DOH *chunk, *symbols, *sval, *decl;
|
||||||
|
|
@ -936,12 +936,12 @@ SWIG_cpp_parse(DOH *s)
|
||||||
if (allow) {
|
if (allow) {
|
||||||
DOH *m, *v, *v1;
|
DOH *m, *v, *v1;
|
||||||
Seek(value,0,SEEK_SET);
|
Seek(value,0,SEEK_SET);
|
||||||
m = SWIG_cpp_define(value,0);
|
m = Preprocessor_define(value,0);
|
||||||
if ((m) && !(Getattr(m,"args"))) {
|
if ((m) && !(Getattr(m,"args"))) {
|
||||||
v = Copy(Getattr(m,"value"));
|
v = Copy(Getattr(m,"value"));
|
||||||
if (Len(v)) {
|
if (Len(v)) {
|
||||||
silent_errors = 1;
|
silent_errors = 1;
|
||||||
v1 = swig_cpp_replace(v);
|
v1 = Preprocessor_replace(v);
|
||||||
silent_errors = 0;
|
silent_errors = 0;
|
||||||
if (!check_id(v1)) {
|
if (!check_id(v1)) {
|
||||||
if (Len(comment) == 0)
|
if (Len(comment) == 0)
|
||||||
|
|
@ -954,7 +954,7 @@ SWIG_cpp_parse(DOH *s)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (Cmp(id,"undef") == 0) {
|
} else if (Cmp(id,"undef") == 0) {
|
||||||
if (allow) SWIG_cpp_undef(value);
|
if (allow) Preprocessor_undef(value);
|
||||||
} else if (Cmp(id,"ifdef") == 0) {
|
} else if (Cmp(id,"ifdef") == 0) {
|
||||||
cond_lines[level] = Getline(id);
|
cond_lines[level] = Getline(id);
|
||||||
level++;
|
level++;
|
||||||
|
|
@ -996,9 +996,9 @@ SWIG_cpp_parse(DOH *s)
|
||||||
level++;
|
level++;
|
||||||
if (allow) {
|
if (allow) {
|
||||||
start_level = level;
|
start_level = level;
|
||||||
sval = swig_cpp_replace(value);
|
sval = Preprocessor_replace(value);
|
||||||
Seek(sval,0,SEEK_SET);
|
Seek(sval,0,SEEK_SET);
|
||||||
val = SWIG_expr(sval,&e);
|
val = Preprocessor_expr(sval,&e);
|
||||||
if (e) {
|
if (e) {
|
||||||
Seek(value,0,SEEK_SET);
|
Seek(value,0,SEEK_SET);
|
||||||
/* cpp_error(Getfile(value),Getline(value),"Could not evaluate '%s'\n", value); */
|
/* cpp_error(Getfile(value),Getline(value),"Could not evaluate '%s'\n", value); */
|
||||||
|
|
@ -1018,9 +1018,9 @@ SWIG_cpp_parse(DOH *s)
|
||||||
allow = 0;
|
allow = 0;
|
||||||
mask = 0;
|
mask = 0;
|
||||||
} else if (level == start_level) {
|
} else if (level == start_level) {
|
||||||
sval = swig_cpp_replace(value);
|
sval = Preprocessor_replace(value);
|
||||||
Seek(sval,0,SEEK_SET);
|
Seek(sval,0,SEEK_SET);
|
||||||
val = SWIG_expr(sval,&e);
|
val = Preprocessor_expr(sval,&e);
|
||||||
if (e) {
|
if (e) {
|
||||||
Seek(value,0,SEEK_SET);
|
Seek(value,0,SEEK_SET);
|
||||||
/* cpp_error(Getfile(value),Getline(value),"Could not evaluate '%s'\n", value); */
|
/* cpp_error(Getfile(value),Getline(value),"Could not evaluate '%s'\n", value); */
|
||||||
|
|
@ -1041,8 +1041,8 @@ SWIG_cpp_parse(DOH *s)
|
||||||
fn = get_filename(value);
|
fn = get_filename(value);
|
||||||
s1 = cpp_include(fn);
|
s1 = cpp_include(fn);
|
||||||
if (s1) {
|
if (s1) {
|
||||||
Printf(ns,"%%includefile \"%s\" {\n", SWIG_last_file());
|
Printf(ns,"%%includefile \"%s\" {\n", Swig_last_file());
|
||||||
s2 = SWIG_cpp_parse(s1);
|
s2 = Preprocessor_parse(s1);
|
||||||
addline(ns,s2,allow);
|
addline(ns,s2,allow);
|
||||||
Printf(ns,"\n}\n");
|
Printf(ns,"\n}\n");
|
||||||
Delete(s2);
|
Delete(s2);
|
||||||
|
|
@ -1114,13 +1114,13 @@ SWIG_cpp_parse(DOH *s)
|
||||||
if (s1) {
|
if (s1) {
|
||||||
add_chunk(ns,chunk,allow);
|
add_chunk(ns,chunk,allow);
|
||||||
copy_location(s,chunk);
|
copy_location(s,chunk);
|
||||||
Printf(ns,"%sfile \"%s\" {\n", decl, SWIG_last_file());
|
Printf(ns,"%sfile \"%s\" {\n", decl, Swig_last_file());
|
||||||
if ((Cmp(decl,"%import") == 0) || (Cmp(decl,"%extern") == 0)) {
|
if ((Cmp(decl,"%import") == 0) || (Cmp(decl,"%extern") == 0)) {
|
||||||
SWIG_cpp_define("WRAPEXTERN 1", 0);
|
Preprocessor_define("WRAPEXTERN 1", 0);
|
||||||
}
|
}
|
||||||
s2 = SWIG_cpp_parse(s1);
|
s2 = Preprocessor_parse(s1);
|
||||||
if ((Cmp(decl,"%import") == 0) || (Cmp(decl,"%extern") == 0)) {
|
if ((Cmp(decl,"%import") == 0) || (Cmp(decl,"%extern") == 0)) {
|
||||||
SWIG_cpp_undef("WRAPEXTERN");
|
Preprocessor_undef("WRAPEXTERN");
|
||||||
}
|
}
|
||||||
addline(ns,s2,allow);
|
addline(ns,s2,allow);
|
||||||
Printf(ns,"\n}\n");
|
Printf(ns,"\n}\n");
|
||||||
|
|
@ -1167,7 +1167,7 @@ SWIG_cpp_parse(DOH *s)
|
||||||
}
|
}
|
||||||
if (allow) {
|
if (allow) {
|
||||||
Seek(value,0,SEEK_SET);
|
Seek(value,0,SEEK_SET);
|
||||||
SWIG_cpp_define(value,1);
|
Preprocessor_define(value,1);
|
||||||
}
|
}
|
||||||
Putc('\n',ns);
|
Putc('\n',ns);
|
||||||
addline(ns,value,0);
|
addline(ns,value,0);
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
* can be used and distributed.
|
* can be used and distributed.
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "swigcore.h"
|
#include "preprocessor.h"
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
* expr.c
|
* expr.c
|
||||||
|
|
@ -26,7 +26,7 @@
|
||||||
* the compiler that need to perform compile-time expression evaluation.
|
* the compiler that need to perform compile-time expression evaluation.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
static Scanner *scan = 0;
|
static SwigScanner *scan = 0;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int op;
|
int op;
|
||||||
|
|
@ -47,27 +47,27 @@ static char *errmsg = 0; /* Parsing error */
|
||||||
|
|
||||||
/* Initialize the precedence table for various operators. Low values have higher precedence */
|
/* Initialize the precedence table for various operators. Low values have higher precedence */
|
||||||
static void init_precedence() {
|
static void init_precedence() {
|
||||||
prec[TOKEN_NOT] = 10;
|
prec[SWIG_TOKEN_NOT] = 10;
|
||||||
prec[EXPR_UMINUS] = 10;
|
prec[EXPR_UMINUS] = 10;
|
||||||
prec[TOKEN_STAR] = 20;
|
prec[SWIG_TOKEN_STAR] = 20;
|
||||||
prec[TOKEN_SLASH] = 20;
|
prec[SWIG_TOKEN_SLASH] = 20;
|
||||||
prec[TOKEN_PERCENT] = 20;
|
prec[SWIG_TOKEN_PERCENT] = 20;
|
||||||
prec[TOKEN_PLUS] = 30;
|
prec[SWIG_TOKEN_PLUS] = 30;
|
||||||
prec[TOKEN_MINUS] = 30;
|
prec[SWIG_TOKEN_MINUS] = 30;
|
||||||
prec[TOKEN_LSHIFT] = 40;
|
prec[SWIG_TOKEN_LSHIFT] = 40;
|
||||||
prec[TOKEN_RSHIFT] = 40;
|
prec[SWIG_TOKEN_RSHIFT] = 40;
|
||||||
prec[TOKEN_AND] = 50;
|
prec[SWIG_TOKEN_AND] = 50;
|
||||||
prec[TOKEN_XOR] = 60;
|
prec[SWIG_TOKEN_XOR] = 60;
|
||||||
prec[TOKEN_OR] = 70;
|
prec[SWIG_TOKEN_OR] = 70;
|
||||||
prec[TOKEN_EQUALTO] = 80;
|
prec[SWIG_TOKEN_EQUALTO] = 80;
|
||||||
prec[TOKEN_NOTEQUAL] = 80;
|
prec[SWIG_TOKEN_NOTEQUAL] = 80;
|
||||||
prec[TOKEN_LESSTHAN] = 80;
|
prec[SWIG_TOKEN_LESSTHAN] = 80;
|
||||||
prec[TOKEN_GREATERTHAN] = 80;
|
prec[SWIG_TOKEN_GREATERTHAN] = 80;
|
||||||
prec[TOKEN_LTEQUAL] = 80;
|
prec[SWIG_TOKEN_LTEQUAL] = 80;
|
||||||
prec[TOKEN_GTEQUAL] = 80;
|
prec[SWIG_TOKEN_GTEQUAL] = 80;
|
||||||
prec[TOKEN_LNOT] = 90;
|
prec[SWIG_TOKEN_LNOT] = 90;
|
||||||
prec[TOKEN_LAND] = 100;
|
prec[SWIG_TOKEN_LAND] = 100;
|
||||||
prec[TOKEN_LOR] = 110;
|
prec[SWIG_TOKEN_LOR] = 110;
|
||||||
expr_init = 1;
|
expr_init = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -79,67 +79,67 @@ static void reduce_op() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
switch(stack[sp-1].value) {
|
switch(stack[sp-1].value) {
|
||||||
case TOKEN_STAR:
|
case SWIG_TOKEN_STAR:
|
||||||
stack[sp-2].value = stack[sp-2].value * stack[sp].value;
|
stack[sp-2].value = stack[sp-2].value * stack[sp].value;
|
||||||
sp -= 2;
|
sp -= 2;
|
||||||
break;
|
break;
|
||||||
case TOKEN_EQUALTO:
|
case SWIG_TOKEN_EQUALTO:
|
||||||
stack[sp-2].value = stack[sp-2].value == stack[sp].value;
|
stack[sp-2].value = stack[sp-2].value == stack[sp].value;
|
||||||
sp -= 2;
|
sp -= 2;
|
||||||
break;
|
break;
|
||||||
case TOKEN_NOTEQUAL:
|
case SWIG_TOKEN_NOTEQUAL:
|
||||||
stack[sp-2].value = stack[sp-2].value != stack[sp].value;
|
stack[sp-2].value = stack[sp-2].value != stack[sp].value;
|
||||||
sp -= 2;
|
sp -= 2;
|
||||||
break;
|
break;
|
||||||
case TOKEN_PLUS:
|
case SWIG_TOKEN_PLUS:
|
||||||
stack[sp-2].value = stack[sp-2].value + stack[sp].value;
|
stack[sp-2].value = stack[sp-2].value + stack[sp].value;
|
||||||
sp -= 2;
|
sp -= 2;
|
||||||
break;
|
break;
|
||||||
case TOKEN_MINUS:
|
case SWIG_TOKEN_MINUS:
|
||||||
stack[sp-2].value = stack[sp-2].value - stack[sp].value;
|
stack[sp-2].value = stack[sp-2].value - stack[sp].value;
|
||||||
sp -= 2;
|
sp -= 2;
|
||||||
break;
|
break;
|
||||||
case TOKEN_AND:
|
case SWIG_TOKEN_AND:
|
||||||
stack[sp-2].value = stack[sp-2].value & stack[sp].value;
|
stack[sp-2].value = stack[sp-2].value & stack[sp].value;
|
||||||
sp -= 2;
|
sp -= 2;
|
||||||
break;
|
break;
|
||||||
case TOKEN_LAND:
|
case SWIG_TOKEN_LAND:
|
||||||
stack[sp-2].value = stack[sp-2].value && stack[sp].value;
|
stack[sp-2].value = stack[sp-2].value && stack[sp].value;
|
||||||
sp -= 2;
|
sp -= 2;
|
||||||
break;
|
break;
|
||||||
case TOKEN_OR:
|
case SWIG_TOKEN_OR:
|
||||||
stack[sp-2].value = stack[sp-2].value | stack[sp].value;
|
stack[sp-2].value = stack[sp-2].value | stack[sp].value;
|
||||||
sp -= 2;
|
sp -= 2;
|
||||||
break;
|
break;
|
||||||
case TOKEN_LOR:
|
case SWIG_TOKEN_LOR:
|
||||||
stack[sp-2].value = stack[sp-2].value || stack[sp].value;
|
stack[sp-2].value = stack[sp-2].value || stack[sp].value;
|
||||||
sp -= 2;
|
sp -= 2;
|
||||||
break;
|
break;
|
||||||
case TOKEN_XOR:
|
case SWIG_TOKEN_XOR:
|
||||||
stack[sp-2].value = stack[sp-2].value ^ stack[sp].value;
|
stack[sp-2].value = stack[sp-2].value ^ stack[sp].value;
|
||||||
sp -= 2;
|
sp -= 2;
|
||||||
break;
|
break;
|
||||||
case TOKEN_LESSTHAN:
|
case SWIG_TOKEN_LESSTHAN:
|
||||||
stack[sp-2].value = stack[sp-2].value < stack[sp].value;
|
stack[sp-2].value = stack[sp-2].value < stack[sp].value;
|
||||||
sp -= 2;
|
sp -= 2;
|
||||||
break;
|
break;
|
||||||
case TOKEN_GREATERTHAN:
|
case SWIG_TOKEN_GREATERTHAN:
|
||||||
stack[sp-2].value = stack[sp-2].value > stack[sp].value;
|
stack[sp-2].value = stack[sp-2].value > stack[sp].value;
|
||||||
sp -= 2;
|
sp -= 2;
|
||||||
break;
|
break;
|
||||||
case TOKEN_LTEQUAL:
|
case SWIG_TOKEN_LTEQUAL:
|
||||||
stack[sp-2].value = stack[sp-2].value <= stack[sp].value;
|
stack[sp-2].value = stack[sp-2].value <= stack[sp].value;
|
||||||
sp -= 2;
|
sp -= 2;
|
||||||
break;
|
break;
|
||||||
case TOKEN_GTEQUAL:
|
case SWIG_TOKEN_GTEQUAL:
|
||||||
stack[sp-2].value = stack[sp-2].value >= stack[sp].value;
|
stack[sp-2].value = stack[sp-2].value >= stack[sp].value;
|
||||||
sp -= 2;
|
sp -= 2;
|
||||||
break;
|
break;
|
||||||
case TOKEN_NOT:
|
case SWIG_TOKEN_NOT:
|
||||||
stack[sp-1].value = ~stack[sp].value;
|
stack[sp-1].value = ~stack[sp].value;
|
||||||
sp--;
|
sp--;
|
||||||
break;
|
break;
|
||||||
case TOKEN_LNOT:
|
case SWIG_TOKEN_LNOT:
|
||||||
stack[sp-1].value = !stack[sp].value;
|
stack[sp-1].value = !stack[sp].value;
|
||||||
sp--;
|
sp--;
|
||||||
break;
|
break;
|
||||||
|
|
@ -147,19 +147,19 @@ static void reduce_op() {
|
||||||
stack[sp-1].value = -stack[sp].value;
|
stack[sp-1].value = -stack[sp].value;
|
||||||
sp--;
|
sp--;
|
||||||
break;
|
break;
|
||||||
case TOKEN_SLASH:
|
case SWIG_TOKEN_SLASH:
|
||||||
stack[sp-2].value = stack[sp-2].value / stack[sp].value;
|
stack[sp-2].value = stack[sp-2].value / stack[sp].value;
|
||||||
sp -= 2;
|
sp -= 2;
|
||||||
break;
|
break;
|
||||||
case TOKEN_PERCENT:
|
case SWIG_TOKEN_PERCENT:
|
||||||
stack[sp-2].value = stack[sp-2].value % stack[sp].value;
|
stack[sp-2].value = stack[sp-2].value % stack[sp].value;
|
||||||
sp -= 2;
|
sp -= 2;
|
||||||
break;
|
break;
|
||||||
case TOKEN_LSHIFT:
|
case SWIG_TOKEN_LSHIFT:
|
||||||
stack[sp-2].value = stack[sp-2].value << stack[sp].value;
|
stack[sp-2].value = stack[sp-2].value << stack[sp].value;
|
||||||
sp -= 2;
|
sp -= 2;
|
||||||
break;
|
break;
|
||||||
case TOKEN_RSHIFT:
|
case SWIG_TOKEN_RSHIFT:
|
||||||
stack[sp-2].value = stack[sp-2].value >> stack[sp].value;
|
stack[sp-2].value = stack[sp-2].value >> stack[sp].value;
|
||||||
sp -= 2;
|
sp -= 2;
|
||||||
break;
|
break;
|
||||||
|
|
@ -172,23 +172,23 @@ static void reduce_op() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
* void SWIG_expr_init()
|
* void Preprocessor_expr_init()
|
||||||
*
|
*
|
||||||
* Initialize the expression evaluator
|
* Initialize the expression evaluator
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void SWIG_expr_init() {
|
void Preprocessor_expr_init() {
|
||||||
if (!expr_init) init_precedence();
|
if (!expr_init) init_precedence();
|
||||||
if (!scan) scan = NewScanner();
|
if (!scan) scan = NewSwigScanner();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
* int SWIG_expr(DOH *s, int *error)
|
* int Preprocessor_expr(DOH *s, int *error)
|
||||||
*
|
*
|
||||||
* Evaluates an arithmetic expression in s.
|
* Evaluates an arithmetic expression in s.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
int SWIG_expr(DOH *s, int *error) {
|
int Preprocessor_expr(DOH *s, int *error) {
|
||||||
int token = 0;
|
int token = 0;
|
||||||
int op = 0;
|
int op = 0;
|
||||||
|
|
||||||
|
|
@ -198,8 +198,8 @@ int SWIG_expr(DOH *s, int *error) {
|
||||||
|
|
||||||
Seek(s,0,SEEK_SET);
|
Seek(s,0,SEEK_SET);
|
||||||
*error = 0;
|
*error = 0;
|
||||||
Scanner_clear(scan);
|
SwigScanner_clear(scan);
|
||||||
Scanner_push(scan,s);
|
SwigScanner_push(scan,s);
|
||||||
|
|
||||||
/* Put initial state onto the stack */
|
/* Put initial state onto the stack */
|
||||||
stack[sp].op = EXPR_TOP;
|
stack[sp].op = EXPR_TOP;
|
||||||
|
|
@ -210,32 +210,32 @@ int SWIG_expr(DOH *s, int *error) {
|
||||||
switch(stack[sp].op) {
|
switch(stack[sp].op) {
|
||||||
case EXPR_TOP:
|
case EXPR_TOP:
|
||||||
/* An expression. Can be a number or another expression enclosed in parens */
|
/* An expression. Can be a number or another expression enclosed in parens */
|
||||||
token = Scanner_token(scan);
|
token = SwigScanner_token(scan);
|
||||||
if (!token) {
|
if (!token) {
|
||||||
errmsg = "Expected an expression";
|
errmsg = "Expected an expression";
|
||||||
*error = 1;
|
*error = 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if ((token == TOKEN_INT) || (token == TOKEN_UINT) || (token == TOKEN_LONG) || (token == TOKEN_ULONG)) {
|
if ((token == SWIG_TOKEN_INT) || (token == SWIG_TOKEN_UINT) || (token == SWIG_TOKEN_LONG) || (token == SWIG_TOKEN_ULONG)) {
|
||||||
/* A number. Reduce EXPR_TOP to an EXPR_VALUE */
|
/* A number. Reduce EXPR_TOP to an EXPR_VALUE */
|
||||||
stack[sp].value = (long) atol(Char(Scanner_text(scan)));
|
stack[sp].value = (long) atol(Char(SwigScanner_text(scan)));
|
||||||
stack[sp].op = EXPR_VALUE;
|
stack[sp].op = EXPR_VALUE;
|
||||||
} else if (token == TOKEN_PLUS) { }
|
} else if (token == SWIG_TOKEN_PLUS) { }
|
||||||
else if ((token == TOKEN_MINUS) || (token == TOKEN_LNOT) || (token==TOKEN_NOT)) {
|
else if ((token == SWIG_TOKEN_MINUS) || (token == SWIG_TOKEN_LNOT) || (token==SWIG_TOKEN_NOT)) {
|
||||||
if (token == TOKEN_MINUS) token = EXPR_UMINUS;
|
if (token == SWIG_TOKEN_MINUS) token = EXPR_UMINUS;
|
||||||
stack[sp].value = token;
|
stack[sp].value = token;
|
||||||
stack[sp++].op = EXPR_OP;
|
stack[sp++].op = EXPR_OP;
|
||||||
stack[sp].op = EXPR_TOP;
|
stack[sp].op = EXPR_TOP;
|
||||||
} else if ((token == TOKEN_LPAREN)) {
|
} else if ((token == SWIG_TOKEN_LPAREN)) {
|
||||||
stack[sp++].op = EXPR_GROUP;
|
stack[sp++].op = EXPR_GROUP;
|
||||||
stack[sp].op = EXPR_TOP;
|
stack[sp].op = EXPR_TOP;
|
||||||
stack[sp].value = 0;
|
stack[sp].value = 0;
|
||||||
} else if (token == TOKEN_ENDLINE) { }
|
} else if (token == SWIG_TOKEN_ENDLINE) { }
|
||||||
else goto syntax_error;
|
else goto syntax_error;
|
||||||
break;
|
break;
|
||||||
case EXPR_VALUE:
|
case EXPR_VALUE:
|
||||||
/* A value is on the stack. We may reduce or evaluate depending on what the next token is */
|
/* A value is on the stack. We may reduce or evaluate depending on what the next token is */
|
||||||
token = Scanner_token(scan);
|
token = SwigScanner_token(scan);
|
||||||
if (!token) {
|
if (!token) {
|
||||||
/* End of input. Might have to reduce if an operator is on stack */
|
/* End of input. Might have to reduce if an operator is on stack */
|
||||||
while (sp > 0) {
|
while (sp > 0) {
|
||||||
|
|
@ -251,24 +251,24 @@ int SWIG_expr(DOH *s, int *error) {
|
||||||
}
|
}
|
||||||
/* Token must be an operator */
|
/* Token must be an operator */
|
||||||
switch(token) {
|
switch(token) {
|
||||||
case TOKEN_STAR:
|
case SWIG_TOKEN_STAR:
|
||||||
case TOKEN_EQUALTO:
|
case SWIG_TOKEN_EQUALTO:
|
||||||
case TOKEN_NOTEQUAL:
|
case SWIG_TOKEN_NOTEQUAL:
|
||||||
case TOKEN_PLUS:
|
case SWIG_TOKEN_PLUS:
|
||||||
case TOKEN_MINUS:
|
case SWIG_TOKEN_MINUS:
|
||||||
case TOKEN_AND:
|
case SWIG_TOKEN_AND:
|
||||||
case TOKEN_LAND:
|
case SWIG_TOKEN_LAND:
|
||||||
case TOKEN_OR:
|
case SWIG_TOKEN_OR:
|
||||||
case TOKEN_LOR:
|
case SWIG_TOKEN_LOR:
|
||||||
case TOKEN_XOR:
|
case SWIG_TOKEN_XOR:
|
||||||
case TOKEN_LESSTHAN:
|
case SWIG_TOKEN_LESSTHAN:
|
||||||
case TOKEN_GREATERTHAN:
|
case SWIG_TOKEN_GREATERTHAN:
|
||||||
case TOKEN_LTEQUAL:
|
case SWIG_TOKEN_LTEQUAL:
|
||||||
case TOKEN_GTEQUAL:
|
case SWIG_TOKEN_GTEQUAL:
|
||||||
case TOKEN_SLASH:
|
case SWIG_TOKEN_SLASH:
|
||||||
case TOKEN_PERCENT:
|
case SWIG_TOKEN_PERCENT:
|
||||||
case TOKEN_LSHIFT:
|
case SWIG_TOKEN_LSHIFT:
|
||||||
case TOKEN_RSHIFT:
|
case SWIG_TOKEN_RSHIFT:
|
||||||
if ((sp == 0) || (stack[sp-1].op == EXPR_GROUP)) {
|
if ((sp == 0) || (stack[sp-1].op == EXPR_GROUP)) {
|
||||||
/* No possibility of reduce. Push operator and expression */
|
/* No possibility of reduce. Push operator and expression */
|
||||||
sp++;
|
sp++;
|
||||||
|
|
@ -297,7 +297,7 @@ int SWIG_expr(DOH *s, int *error) {
|
||||||
stack[sp].value = 0;
|
stack[sp].value = 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TOKEN_RPAREN:
|
case SWIG_TOKEN_RPAREN:
|
||||||
if (sp == 0) goto extra_rparen;
|
if (sp == 0) goto extra_rparen;
|
||||||
|
|
||||||
/* Might have to reduce operators first */
|
/* Might have to reduce operators first */
|
||||||
|
|
@ -329,7 +329,7 @@ int SWIG_expr(DOH *s, int *error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return the expression error message */
|
/* Return the expression error message */
|
||||||
char *SWIG_expr_error() {
|
char *Preprocessor_expr_error() {
|
||||||
return errmsg;
|
return errmsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,24 +13,22 @@
|
||||||
* can be used and distributed.
|
* can be used and distributed.
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifndef _SWIGCPP_H
|
#ifndef _PREPROCESSOR_H
|
||||||
#define _SWIGCPP_H
|
#define _PREPROCESSOR_H
|
||||||
|
|
||||||
#include "swigcore.h"
|
#include "swig.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern int SWIG_expr(DOH *s, int *error);
|
extern int Preprocessor_expr(DOH *s, int *error);
|
||||||
extern char *SWIG_expr_error(void);
|
extern char *Preprocessor_expr_error(void);
|
||||||
extern void SWIG_expr_init();
|
extern DOH *Preprocessor_define(DOH *str, int swigmacro);
|
||||||
|
extern void Preprocessor_undef(DOH *name);
|
||||||
extern DOH *SWIG_cpp_define(DOH *str, int swigmacro);
|
extern void Preprocessor_init();
|
||||||
extern void SWIG_cpp_undef(DOH *name);
|
extern DOH *Preprocessor_parse(DOH *s);
|
||||||
extern void SWIG_cpp_init();
|
extern void Preprocessor_include_all(int);
|
||||||
extern DOH *SWIG_cpp_parse(DOH *s);
|
|
||||||
extern void SWIG_cpp_include_all(int);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue