Add support for thread_local when specified with other legitimate storage class specifiers - extern and static
This commit is contained in:
parent
c6bc7b881f
commit
b725625e6f
15 changed files with 145 additions and 24 deletions
|
|
@ -1,11 +1,29 @@
|
|||
/* This testcase checks whether SWIG correctly parses the 'thread_local'
|
||||
keyword before the member type and name. */
|
||||
/* This testcase checks whether SWIG correctly parses the 'thread_local' storage specifier */
|
||||
|
||||
%module cpp0x_thread_local
|
||||
|
||||
%inline %{
|
||||
struct A {
|
||||
thread_local int val;
|
||||
struct ThreadLocals {
|
||||
// thread_local int tval; // members must also be declared static
|
||||
static thread_local int stval;
|
||||
thread_local static int tsval;
|
||||
static thread_local const int stcval88 = 88;
|
||||
thread_local static const int tscval99 = 99;
|
||||
};
|
||||
thread_local int tval;
|
||||
static thread_local int stval;
|
||||
thread_local static int tsval;
|
||||
extern thread_local int etval;
|
||||
thread_local extern int teval;
|
||||
|
||||
thread_local int ThreadLocals::stval = 11;
|
||||
thread_local int ThreadLocals::tsval = 22;
|
||||
thread_local const int ThreadLocals::stcval88;
|
||||
thread_local const int ThreadLocals::tscval99;
|
||||
%}
|
||||
|
||||
%{
|
||||
// externs
|
||||
thread_local int etval = 33;
|
||||
thread_local int teval = 44;
|
||||
%}
|
||||
|
|
|
|||
43
Examples/test-suite/java/cpp0x_thread_local_runme.java
Normal file
43
Examples/test-suite/java/cpp0x_thread_local_runme.java
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
import cpp0x_thread_local.*;
|
||||
|
||||
public class cpp0x_thread_local_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("cpp0x_thread_local");
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String argv[])
|
||||
{
|
||||
if (ThreadLocals.getStval() != 11)
|
||||
throw new RuntimeException();
|
||||
if (ThreadLocals.getTsval() != 22)
|
||||
throw new RuntimeException();
|
||||
if (ThreadLocals.tscval99 != 99)
|
||||
throw new RuntimeException();
|
||||
|
||||
cpp0x_thread_local.setEtval(-11);
|
||||
if (cpp0x_thread_local.getEtval() != -11)
|
||||
throw new RuntimeException();
|
||||
|
||||
cpp0x_thread_local.setStval(-22);
|
||||
if (cpp0x_thread_local.getStval() != -22)
|
||||
throw new RuntimeException();
|
||||
|
||||
cpp0x_thread_local.setTsval(-33);
|
||||
if (cpp0x_thread_local.getTsval() != -33)
|
||||
throw new RuntimeException();
|
||||
|
||||
cpp0x_thread_local.setEtval(-44);
|
||||
if (cpp0x_thread_local.getEtval() != -44)
|
||||
throw new RuntimeException();
|
||||
|
||||
cpp0x_thread_local.setTeval(-55);
|
||||
if (cpp0x_thread_local.getTeval() != -55)
|
||||
throw new RuntimeException();
|
||||
}
|
||||
}
|
||||
30
Examples/test-suite/python/cpp0x_thread_local_runme.py
Normal file
30
Examples/test-suite/python/cpp0x_thread_local_runme.py
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
from cpp0x_thread_local import *
|
||||
|
||||
t = ThreadLocals()
|
||||
if t.stval != 11:
|
||||
raise RuntimeError
|
||||
if t.tsval != 22:
|
||||
raise RuntimeError
|
||||
if t.tscval99 != 99:
|
||||
raise RuntimeError
|
||||
|
||||
cvar.etval = -11
|
||||
if cvar.etval != -11:
|
||||
raise RuntimeError
|
||||
|
||||
cvar.stval = -22
|
||||
if cvar.stval != -22:
|
||||
raise RuntimeError
|
||||
|
||||
cvar.tsval = -33
|
||||
if cvar.tsval != -33:
|
||||
raise RuntimeError
|
||||
|
||||
cvar.etval = -44
|
||||
if cvar.etval != -44:
|
||||
raise RuntimeError
|
||||
|
||||
cvar.teval = -55
|
||||
if cvar.teval != -55:
|
||||
raise RuntimeError
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue