diff options
author | William S Fulton <wsf@fultondesigns.co.uk> | 2013-02-08 07:38:10 +0000 |
---|---|---|
committer | William S Fulton <wsf@fultondesigns.co.uk> | 2013-02-08 07:38:10 +0000 |
commit | 7fcfdeee0837fb240fb30c521a9471de6e0e7bfa (patch) | |
tree | 0d17ad2556ac0f64bda3703226bc1457a806c4d3 | |
parent | b725625e6fc29fc38e561f1c8455f4559add4d5e (diff) | |
download | swig-7fcfdeee0837fb240fb30c521a9471de6e0e7bfa.tar.gz |
Fixes detecting if a variable is extern when using 'extern thread_local'
-rw-r--r-- | Source/Modules/cffi.cxx | 11 | ||||
-rw-r--r-- | Source/Modules/clisp.cxx | 4 | ||||
-rw-r--r-- | Source/Modules/lang.cxx | 8 | ||||
-rw-r--r-- | Source/Swig/misc.c | 11 | ||||
-rw-r--r-- | Source/Swig/swig.h | 1 |
5 files changed, 18 insertions, 17 deletions
diff --git a/Source/Modules/cffi.cxx b/Source/Modules/cffi.cxx index 29de9f9ed..0b1153d61 100644 --- a/Source/Modules/cffi.cxx +++ b/Source/Modules/cffi.cxx @@ -506,11 +506,6 @@ int CFFI::functionWrapper(Node *n) { void CFFI::emit_defun(Node *n, String *name) { - - // String *storage=Getattr(n,"storage"); - // if(!storage || (Strcmp(storage,"extern") && Strcmp(storage,"externc"))) - // return SWIG_OK; - String *func_name = Getattr(n, "sym:name"); ParmList *pl = Getattr(n, "parms"); @@ -583,12 +578,6 @@ int CFFI::constantWrapper(Node *n) { } int CFFI::variableWrapper(Node *n) { - // String *storage=Getattr(n,"storage"); - // Printf(stdout,"\"%s\" %s)\n",storage,Getattr(n, "sym:name")); - - // if(!storage || (Strcmp(storage,"extern") && Strcmp(storage,"externc"))) - // return SWIG_OK; - String *var_name = Getattr(n, "sym:name"); String *lisp_type = Swig_typemap_lookup("cin", n, "", 0); String *lisp_name = lispify_name(n, var_name, "'variable"); diff --git a/Source/Modules/clisp.cxx b/Source/Modules/clisp.cxx index 4290b5452..7dfa74539 100644 --- a/Source/Modules/clisp.cxx +++ b/Source/Modules/clisp.cxx @@ -148,7 +148,7 @@ int CLISP::top(Node *n) { int CLISP::functionWrapper(Node *n) { is_function = 1; String *storage = Getattr(n, "storage"); - if (!extern_all_flag && (!storage || (Strcmp(storage, "extern") && Strcmp(storage, "externc")))) + if (!extern_all_flag && (!storage || (!Swig_storage_isextern(n) && Strcmp(storage, "externc")))) return SWIG_OK; String *func_name = Getattr(n, "sym:name"); @@ -220,7 +220,7 @@ int CLISP::variableWrapper(Node *n) { // SwigType *type=; String *storage = Getattr(n, "storage"); - if (!extern_all_flag && (!storage || (Strcmp(storage, "extern") && Strcmp(storage, "externc")))) + if (!extern_all_flag && (!storage || (!Swig_storage_isextern(n) && Strcmp(storage, "externc")))) return SWIG_OK; String *var_name = Getattr(n, "sym:name"); diff --git a/Source/Modules/lang.cxx b/Source/Modules/lang.cxx index b4ad9c879..5aa18a251 100644 --- a/Source/Modules/lang.cxx +++ b/Source/Modules/lang.cxx @@ -955,7 +955,7 @@ int Language::cDeclaration(Node *n) { if (AddExtern) { if (f_header) { - if ((Cmp(storage, "extern") == 0) || (ForceExtern && !storage)) { + if (Swig_storage_isextern(n) || (ForceExtern && !storage)) { /* we don't need the 'extern' part in the C/C++ declaration, and it produces some problems when namespace and SUN Studio is used. @@ -1017,12 +1017,12 @@ int Language::cDeclaration(Node *n) { if (Getattr(n, "nested")) SetFlag(n, "feature:immutable"); if (!CurrentClass) { - if ((Cmp(storage, "extern") == 0) || ForceExtern) { - f_header = Swig_filebyname("header"); + if (Swig_storage_isextern(n) || ForceExtern) { if (AddExtern) { + f_header = Swig_filebyname("header"); if (f_header) { String *str = SwigType_str(ty, name); - Printf(f_header, "extern %s;\n", str); + Printf(f_header, "%s %s;\n", Getattr(n, "storage"), str); Delete(str); } } diff --git a/Source/Swig/misc.c b/Source/Swig/misc.c index 1b8d79daf..297d1ccdc 100644 --- a/Source/Swig/misc.c +++ b/Source/Swig/misc.c @@ -263,6 +263,17 @@ void Swig_filename_unescape(String *filename) { } /* ----------------------------------------------------------------------------- + * Swig_storage_isextern() + * + * Determine if the storage class specifier is extern (but not externc) + * ----------------------------------------------------------------------------- */ + +int Swig_storage_isextern(Node *n) { + const String *storage = Getattr(n, "storage"); + return storage ? Strcmp(storage, "extern") == 0 || Strncmp(storage, "extern ", 7) == 0 : 0; +} + +/* ----------------------------------------------------------------------------- * Swig_storage_isstatic_custom() * * Determine if the storage class specifier is static diff --git a/Source/Swig/swig.h b/Source/Swig/swig.h index eccc18308..85d8c0b3e 100644 --- a/Source/Swig/swig.h +++ b/Source/Swig/swig.h @@ -315,6 +315,7 @@ extern int ParmList_is_compactdefargs(ParmList *p); extern void Swig_filename_correct(String *filename); extern String *Swig_filename_escape(String *filename); extern void Swig_filename_unescape(String *filename); + extern int Swig_storage_isextern(Node *n); extern int Swig_storage_isstatic_custom(Node *n, const_String_or_char_ptr storage); extern int Swig_storage_isstatic(Node *n); extern String *Swig_string_escape(String *s); |