fix cpp + defined variable name
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@6569 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
a88a68f942
commit
8a6b31c1a2
2 changed files with 13 additions and 1 deletions
|
|
@ -268,3 +268,10 @@ inline const char* mangle ## #@__VA_ARGS__ () {
|
||||||
#define one ONE
|
#define one ONE
|
||||||
#define two TWO
|
#define two TWO
|
||||||
#define three THREE(42)
|
#define three THREE(42)
|
||||||
|
|
||||||
|
|
||||||
|
%inline %{
|
||||||
|
int endif = 0;
|
||||||
|
int define = 0;
|
||||||
|
int defined = 0;
|
||||||
|
%}
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ static int ignore_missing = 0;
|
||||||
static int import_all = 0; /* Follow all includes, but as %import statements */
|
static int import_all = 0; /* Follow all includes, but as %import statements */
|
||||||
static int imported_depth = 0; /* Depth of %imported files */
|
static int imported_depth = 0; /* Depth of %imported files */
|
||||||
static int single_include = 1; /* Only include each file once */
|
static int single_include = 1; /* Only include each file once */
|
||||||
|
static int replace_defined = 0;
|
||||||
static Hash *included_files = 0;
|
static Hash *included_files = 0;
|
||||||
static List *dependencies = 0;
|
static List *dependencies = 0;
|
||||||
|
|
||||||
|
|
@ -833,7 +834,7 @@ Preprocessor_replace(DOH *s)
|
||||||
/* We found the end of a valid identifier */
|
/* We found the end of a valid identifier */
|
||||||
Ungetc(c,s);
|
Ungetc(c,s);
|
||||||
/* See if this is the special "defined" macro */
|
/* See if this is the special "defined" macro */
|
||||||
if (Cmp(id,"defined") == 0) {
|
if (replace_defined && Cmp(id,"defined") == 0) {
|
||||||
DOH *args;
|
DOH *args;
|
||||||
/* See whether or not a paranthesis has been used */
|
/* See whether or not a paranthesis has been used */
|
||||||
skip_whitespace(s,0);
|
skip_whitespace(s,0);
|
||||||
|
|
@ -1095,7 +1096,9 @@ Preprocessor_parse(String *s)
|
||||||
case 0: /* Initial state - in first column */
|
case 0: /* Initial state - in first column */
|
||||||
/* Look for C preprocessor directives. Otherwise, go directly to state 1 */
|
/* Look for C preprocessor directives. Otherwise, go directly to state 1 */
|
||||||
if (c == '#') {
|
if (c == '#') {
|
||||||
|
replace_defined = 1;
|
||||||
add_chunk(ns,chunk,allow);
|
add_chunk(ns,chunk,allow);
|
||||||
|
replace_defined = 0;
|
||||||
copy_location(s,chunk);
|
copy_location(s,chunk);
|
||||||
cpp_lines = 1;
|
cpp_lines = 1;
|
||||||
state = 40;
|
state = 40;
|
||||||
|
|
@ -1454,7 +1457,9 @@ Preprocessor_parse(String *s)
|
||||||
}
|
}
|
||||||
/* %#cpp - an embedded C preprocessor directive (we strip off the %) */
|
/* %#cpp - an embedded C preprocessor directive (we strip off the %) */
|
||||||
else if (c == '#') {
|
else if (c == '#') {
|
||||||
|
replace_defined = 1;
|
||||||
add_chunk(ns,chunk,allow);
|
add_chunk(ns,chunk,allow);
|
||||||
|
replace_defined = 0;
|
||||||
Putc(c,chunk);
|
Putc(c,chunk);
|
||||||
state = 107;
|
state = 107;
|
||||||
} else if (isidentifier(c)) {
|
} else if (isidentifier(c)) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue