Merge branch 'wkalinin-csymbols'

* wkalinin-csymbols:
  Tests for C nested classes symbol table not being in global space
  C nested classes symbol table should be in global space
This commit is contained in:
William S Fulton 2014-05-12 07:54:36 +01:00
commit f6cae1af1b
4 changed files with 116 additions and 0 deletions

View file

@ -601,6 +601,7 @@ C_TEST_CASES += \
memberin_extend_c \
name \
nested \
nested_extend_c \
nested_structs \
newobject2 \
overload_extend \

View file

@ -0,0 +1,38 @@
import nested_extend_c.*;
public class nested_extend_c_runme {
static {
try {
System.loadLibrary("nested_extend_c");
} 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[]) throws Throwable
{
{
hiA hi = new hiA();
if (hi.hi_extend() != 'h')
throw new RuntimeException("test failed");
}
{
lowA low = new lowA();
if (low.low_extend() != 99)
throw new RuntimeException("test failed");
}
{
hiB hi = new hiB();
if (hi.hi_extend() != 'h')
throw new RuntimeException("test failed");
}
{
lowB low = new lowB();
if (low.low_extend() != 99)
throw new RuntimeException("test failed");
}
}
}

View file

@ -0,0 +1,74 @@
%module nested_extend_c
%extend hiA {
hiA() {
union hiA *self = (union hiA *)malloc(sizeof(union hiA));
self->c = 'h';
return self;
}
char hi_extend() {
return $self->c;
}
}
%extend lowA {
lowA() {
struct lowA *self = (struct lowA *)malloc(sizeof(struct lowA));
self->name = 0;
self->num = 99;
return self;
}
int low_extend() {
return $self->num;
}
}
%extend hiB {
hiB() {
union hiB *self = (union hiB *)malloc(sizeof(union hiB));
self->c = 'h';
return self;
}
char hi_extend() {
return $self->c;
}
}
%extend lowB {
lowB() {
struct lowB *self = (struct lowB *)malloc(sizeof(struct lowB));
self->name = 0;
self->num = 99;
return self;
}
int low_extend() {
return $self->num;
}
}
%inline %{
typedef struct NestedA {
int a;
union hiA {
char c;
int d;
} hiA_instance;
struct lowA {
char *name;
int num;
} lowA_instance;
} NestedA;
typedef struct {
int a;
union hiB {
char c;
int d;
} hiB_instance;
struct lowB {
char *name;
int num;
} lowB_instance;
} NestedB;
%}

View file

@ -3515,6 +3515,9 @@ cpp_class_decl : storage_class cpptype idcolon inherit LBRACE {
} else {
cplus_mode = CPLUS_PUBLIC;
}
if (!cparse_cplusplus) {
set_scope_to_global();
}
Swig_symbol_newscope();
Swig_symbol_setscopename($3);
Swig_inherit_base_symbols(bases);