commit
b624d17f3f
4 changed files with 37 additions and 4 deletions
|
|
@ -16,7 +16,9 @@ thread_local static int tsval;
|
||||||
extern thread_local int etval;
|
extern thread_local int etval;
|
||||||
thread_local extern int teval;
|
thread_local extern int teval;
|
||||||
extern "C" thread_local int ectval;
|
extern "C" thread_local int ectval;
|
||||||
|
extern "C" { thread_local int ectval2 = 56; }
|
||||||
extern "C++" thread_local int ecpptval;
|
extern "C++" thread_local int ecpptval;
|
||||||
|
extern "C++" { thread_local int ecpptval2 = 67; }
|
||||||
|
|
||||||
thread_local int ThreadLocals::stval = 11;
|
thread_local int ThreadLocals::stval = 11;
|
||||||
thread_local int ThreadLocals::tsval = 22;
|
thread_local int ThreadLocals::tsval = 22;
|
||||||
|
|
@ -30,6 +32,10 @@ thread_local const int ThreadLocals::tscval99;
|
||||||
// externs
|
// externs
|
||||||
thread_local int etval = 33;
|
thread_local int etval = 33;
|
||||||
thread_local int teval = 44;
|
thread_local int teval = 44;
|
||||||
|
extern "C" {
|
||||||
thread_local int ectval = 55;
|
thread_local int ectval = 55;
|
||||||
|
}
|
||||||
|
extern "C++" {
|
||||||
thread_local int ecpptval = 66;
|
thread_local int ecpptval = 66;
|
||||||
|
}
|
||||||
%}
|
%}
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ extern "C" {
|
||||||
void RealFunction(int value);
|
void RealFunction(int value);
|
||||||
typedef void Function1(int value); // Fails
|
typedef void Function1(int value); // Fails
|
||||||
typedef int Integer1;
|
typedef int Integer1;
|
||||||
|
int Integer3;
|
||||||
}
|
}
|
||||||
typedef void Function2(int value); // Works
|
typedef void Function2(int value); // Works
|
||||||
typedef int Integer2;
|
typedef int Integer2;
|
||||||
|
|
@ -27,5 +28,14 @@ Hook2_t hook2;
|
||||||
|
|
||||||
extern "C" typedef int Integer;
|
extern "C" typedef int Integer;
|
||||||
Integer int1;
|
Integer int1;
|
||||||
|
extern "C" int int2;
|
||||||
|
extern "C" { extern int int3; }
|
||||||
|
extern "C" { int int4 = 789; }
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
%{
|
||||||
|
extern "C" {
|
||||||
|
int int2 = 123;
|
||||||
|
int int3 = 456;
|
||||||
|
}
|
||||||
|
%}
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,6 @@
|
||||||
import extern_c
|
import extern_c
|
||||||
|
|
||||||
extern_c.RealFunction(2)
|
extern_c.RealFunction(2)
|
||||||
|
assert extern_c.cvar.int2 == 123
|
||||||
|
assert extern_c.cvar.int3 == 456
|
||||||
|
assert extern_c.cvar.int4 == 789
|
||||||
|
|
|
||||||
|
|
@ -3134,14 +3134,22 @@ c_declaration : c_decl {
|
||||||
Setattr($$,"name",$2);
|
Setattr($$,"name",$2);
|
||||||
appendChild($$,n);
|
appendChild($$,n);
|
||||||
while (n) {
|
while (n) {
|
||||||
SwigType *decl = Getattr(n,"decl");
|
String *s = Getattr(n, "storage");
|
||||||
if (SwigType_isfunction(decl) && !Equal(Getattr(n, "storage"), "typedef")) {
|
if (s) {
|
||||||
|
if (Strstr(s, "thread_local")) {
|
||||||
|
Insert(s,0,"externc ");
|
||||||
|
} else if (!Equal(s, "typedef")) {
|
||||||
|
Setattr(n,"storage","externc");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
Setattr(n,"storage","externc");
|
Setattr(n,"storage","externc");
|
||||||
}
|
}
|
||||||
n = nextSibling(n);
|
n = nextSibling(n);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Swig_warning(WARN_PARSE_UNDEFINED_EXTERN,cparse_file, cparse_line,"Unrecognized extern type \"%s\".\n", $2);
|
if (!Equal($2,"C++")) {
|
||||||
|
Swig_warning(WARN_PARSE_UNDEFINED_EXTERN,cparse_file, cparse_line,"Unrecognized extern type \"%s\".\n", $2);
|
||||||
|
}
|
||||||
$$ = new_node("extern");
|
$$ = new_node("extern");
|
||||||
Setattr($$,"name",$2);
|
Setattr($$,"name",$2);
|
||||||
appendChild($$,firstChild($5));
|
appendChild($$,firstChild($5));
|
||||||
|
|
@ -5087,7 +5095,13 @@ extern_string : EXTERN string {
|
||||||
|
|
||||||
storage_class : EXTERN { $$ = "extern"; }
|
storage_class : EXTERN { $$ = "extern"; }
|
||||||
| extern_string { $$ = $1; }
|
| extern_string { $$ = $1; }
|
||||||
| extern_string THREAD_LOCAL { $$ = "thread_local"; }
|
| extern_string THREAD_LOCAL {
|
||||||
|
if (Equal($1, "extern")) {
|
||||||
|
$$ = "extern thread_local";
|
||||||
|
} else {
|
||||||
|
$$ = "externc thread_local";
|
||||||
|
}
|
||||||
|
}
|
||||||
| extern_string TYPEDEF { $$ = "typedef"; }
|
| extern_string TYPEDEF { $$ = "typedef"; }
|
||||||
| STATIC { $$ = "static"; }
|
| STATIC { $$ = "static"; }
|
||||||
| TYPEDEF { $$ = "typedef"; }
|
| TYPEDEF { $$ = "typedef"; }
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue