now 'defined' as variable name is fixed

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@6573 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Marcelo Matus 2004-10-30 21:28:36 +00:00
commit 53306bdc3e
3 changed files with 33 additions and 14 deletions

View file

@ -270,9 +270,17 @@ inline const char* mangle ## #@__VA_ARGS__ () {
#define three THREE(42)
#if defined(one)
/* hello */
#else
/* chiao */
#endif;
#ifdef SWIGRUBY
%rename(ddefined) defined;
#endif
%inline %{
int endif = 0;
int define = 0;
/* this is not working */
/* int defined = 0; */
const int endif = 1;
const int define = 1;
const int defined = 1;
%}

View file

@ -0,0 +1,10 @@
import preproc
if preproc.endif != 1:
raise RuntimeError
if preproc.define != 1:
raise RuntimeError
if preproc.defined != 1:
raise RuntimeError

View file

@ -27,7 +27,6 @@ static int ignore_missing = 0;
static int import_all = 0; /* Follow all includes, but as %import statements */
static int imported_depth = 0; /* Depth of %imported files */
static int single_include = 1; /* Only include each file once */
static int replace_defined = 1;
static Hash *included_files = 0;
static List *dependencies = 0;
@ -834,31 +833,33 @@ Preprocessor_replace(DOH *s)
/* We found the end of a valid identifier */
Ungetc(c,s);
/* See if this is the special "defined" macro */
if (replace_defined && Cmp(id,"defined") == 0) {
DOH *args;
if (Cmp(id,"defined") == 0) {
DOH *args = 0;
/* See whether or not a paranthesis has been used */
skip_whitespace(s,0);
c = Getc(s);
if (c == '(') {
Seek(s,-1,SEEK_CUR);
args = find_args(s);
} else {
DOH *arg = 0;
} else if (isidchar(c)) {
DOH *arg = NewString("");
args = NewList();
arg = NewString("");
if (isidchar(c)) Putc(c,arg);
while ((c = Getc(s)) != EOF) {
Putc(c,arg);
while (((c = Getc(s)) != EOF)) {
if (!isidchar(c)) {
Seek(s,-1,SEEK_CUR);
break;
}
Putc(c,arg);
}
Append(args,arg);
if (Len(arg)) Append(args,arg);
Delete(arg);
} else {
Seek(s,-1,SEEK_CUR);
}
if ((!args) || (!Len(args))) {
Swig_error(Getfile(id),Getline(id),"No arguments given to defined()\n");
/* This is not a defined() macro. */
Printf(ns,"%s",id);
state = 0;
break;
}