Fixes detecting if a variable is extern when using 'extern thread_local'

This commit is contained in:
William S Fulton 2013-02-08 07:38:10 +00:00
commit 7fcfdeee08
5 changed files with 18 additions and 17 deletions

View file

@ -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");

View file

@ -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");

View file

@ -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);
}
}

View file

@ -262,6 +262,17 @@ void Swig_filename_unescape(String *filename) {
#endif
}
/* -----------------------------------------------------------------------------
* 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()
*

View file

@ -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);