Permalink
Browse files

Merge branch 'wkalinin-csymbols-2' - %extend and nested structs

* wkalinin-csymbols-2:
  Add runtime test for %extend and nested union
  test fixed
  %extend symbols for nested structs get into a wrong C symbol table
  • Loading branch information...
2 parents 6612997 + 5f3ee10 commit 81d023ac05ded52a36220f8e806335fdada16437 @wsfulton wsfulton committed Jun 2, 2014
@@ -34,5 +34,12 @@ public static void main(String argv[]) throws Throwable
if (low.low_extend() != 99)
throw new RuntimeException("test failed");
}
+ {
+ FOO_bar foobar = new FOO_bar();
+ foobar.setD(1234);
+ if (foobar.getD() != 1234)
+ throw new RuntimeException("test failed");
+ foobar.bar_extend();
+ }
}
}
@@ -10,6 +10,7 @@
char hi_extend() {
return $self->c;
}
+ static const long swig_size = sizeof(union hiA);
}
%extend lowA {
lowA() {
@@ -21,6 +22,7 @@
int low_extend() {
return $self->num;
}
+ static const long swig_size = sizeof(struct lowA);
}
%extend hiB {
@@ -32,6 +34,7 @@
char hi_extend() {
return $self->c;
}
+ static const long swig_size = sizeof(union hiB);
}
%extend lowB {
lowB() {
@@ -43,13 +46,17 @@
int low_extend() {
return $self->num;
}
+ static const long swig_size = sizeof(struct lowB);
}
%extend FOO_bar {
void bar_extend() {
$self->d = 1;
}
};
+%extend NestedA {
+ static const long swig_size = sizeof(struct NestedA);
+}
#endif
View
@@ -362,7 +362,15 @@ void Swig_nested_name_unnamed_c_structs(Node *n) {
Delete(bases);
}
Setattr(classhash, name, c);
+
+ // Merge the extension into the symbol table
+ if (Node *am = Getattr(Swig_extend_hash(), name)) {
+ Swig_extend_merge(c, am);
+ Swig_extend_append_previous(c, am);
+ Delattr(Swig_extend_hash(), name);
+ }
Swig_symbol_popscope();
+
// process declarations following this type (assign correct new type)
SwigType *ty = Copy(name);
Node *decl = nextSibling(c);
@@ -376,12 +384,6 @@ void Swig_nested_name_unnamed_c_structs(Node *n) {
decl = nextSibling(decl);
}
Delete(ty);
- if (Node *am = Getattr(Swig_extend_hash(), name)) {
- // Merge the extension into the symbol table
- Swig_extend_merge(c, am);
- Swig_extend_append_previous(c, am);
- Delattr(Swig_extend_hash(), name);
- }
Swig_symbol_setscope(Swig_symbol_global_scope());
add_symbols_c(c);

0 comments on commit 81d023a

Please sign in to comment.