Fix multiple declarations of nested structs (C code)
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11753 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
7cb4e902d5
commit
a9ccc5a866
6 changed files with 176 additions and 80 deletions
|
|
@ -80,7 +80,6 @@ CPP_TEST_BROKEN += \
|
|||
exception_partial_info \
|
||||
extend_variable \
|
||||
li_std_vector_ptr \
|
||||
nested_structs \
|
||||
overload_complicated \
|
||||
template_default_pointer \
|
||||
template_expr
|
||||
|
|
@ -461,6 +460,7 @@ C_TEST_CASES += \
|
|||
long_long \
|
||||
name \
|
||||
nested \
|
||||
nested_structs \
|
||||
newobject2 \
|
||||
overload_extend \
|
||||
overload_extendc \
|
||||
|
|
|
|||
37
Examples/test-suite/java/nested_structs_runme.java
Normal file
37
Examples/test-suite/java/nested_structs_runme.java
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
|
||||
import nested_structs.*;
|
||||
|
||||
public class nested_structs_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("nested_structs");
|
||||
} 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[]) {
|
||||
Outer outer = new Outer();
|
||||
nested_structs.setValues(outer, 10);
|
||||
|
||||
Outer_inner1 inner1 = outer.getInner1();
|
||||
Outer_inner2 inner2 = outer.getInner2();
|
||||
Outer_inner3 inner3 = outer.getInner3();
|
||||
Outer_inner4 inner4 = outer.getInner4();
|
||||
if (inner1.getVal() != 10) throw new RuntimeException("failed inner1");
|
||||
if (inner2.getVal() != 20) throw new RuntimeException("failed inner2");
|
||||
if (inner3.getVal() != 20) throw new RuntimeException("failed inner3");
|
||||
if (inner4.getVal() != 40) throw new RuntimeException("failed inner4");
|
||||
|
||||
Outer_inside1 inside1 = outer.getInside1();
|
||||
Outer_inside2 inside2 = outer.getInside2();
|
||||
Outer_inside3 inside3 = outer.getInside3();
|
||||
Outer_inside4 inside4 = outer.getInside4();
|
||||
if (inside1.getVal() != 100) throw new RuntimeException("failed inside1");
|
||||
if (inside2.getVal() != 200) throw new RuntimeException("failed inside2");
|
||||
if (inside3.getVal() != 200) throw new RuntimeException("failed inside3");
|
||||
if (inside4.getVal() != 400) throw new RuntimeException("failed inside4");
|
||||
}
|
||||
}
|
||||
|
|
@ -104,6 +104,11 @@ struct Outer {
|
|||
InnerStruct4* getInnerStruct4() { return 0; }
|
||||
InnerClass4* getInnerClass4() { return 0; }
|
||||
InnerUnion4* getInnerUnion4() { return 0; }
|
||||
|
||||
///////////////////////////////////////////
|
||||
struct InnerMultiple {
|
||||
Integer x;
|
||||
} MultipleInstance1, MultipleInstance2;
|
||||
};
|
||||
|
||||
%}
|
||||
|
|
|
|||
|
|
@ -2,11 +2,26 @@
|
|||
|
||||
// bug #491476
|
||||
%inline %{
|
||||
struct {
|
||||
struct {
|
||||
int a;
|
||||
} a, b;
|
||||
} a;
|
||||
struct Outer {
|
||||
struct {
|
||||
int val;
|
||||
} inner1, inner2, *inner3, inner4[1];
|
||||
struct Named {
|
||||
int val;
|
||||
} inside1, inside2, *inside3, inside4[1];
|
||||
} outer;
|
||||
|
||||
void setValues(struct Outer *outer, int val) {
|
||||
outer->inner1.val = val;
|
||||
outer->inner2.val = val * 2;
|
||||
outer->inner3 = &outer->inner2;
|
||||
outer->inner4[0].val = val * 4;
|
||||
|
||||
val = val * 10;
|
||||
outer->inside1.val = val;
|
||||
outer->inside2.val = val * 2;
|
||||
outer->inside3 = &outer->inside2;
|
||||
outer->inside4[0].val = val * 4;
|
||||
}
|
||||
%}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue