mirror of https://github.com/swig/swig
fixed %template declared within class, next to template declaration
added a few tests for C# nested classes support
This commit is contained in:
parent
0cf116128b
commit
865408874f
|
@ -0,0 +1,66 @@
|
|||
using System;
|
||||
using nested_classNamespace;
|
||||
#pragma warning disable 219
|
||||
|
||||
public class runme {
|
||||
static void Main() {
|
||||
|
||||
Outer outer = new Outer();
|
||||
outer.a = 1;
|
||||
outer.b = 2;
|
||||
Outer.InnerStruct1 is1 = outer.makeInnerStruct1();
|
||||
Outer.InnerClass1 ic1 = outer.makeInnerClass1();
|
||||
Outer.InnerUnion1 iu1 = outer.makeInnerUnion1();
|
||||
|
||||
Outer.InnerStruct2 is2 = outer.makeInnerStruct2();
|
||||
Outer.InnerClass2 ic2 = outer.makeInnerClass2();
|
||||
Outer.InnerUnion2 iu2 = outer.makeInnerUnion2();
|
||||
|
||||
Outer.InnerClass4Typedef ic4 = outer.makeInnerClass4Typedef();
|
||||
Outer.InnerStruct4Typedef is4 = outer.makeInnerStruct4Typedef();
|
||||
Outer.InnerUnion4Typedef iu4 = outer.makeInnerUnion4Typedef();
|
||||
|
||||
Outer.InnerClass5Typedef ic5 = outer.makeInnerClass5();
|
||||
Outer.InnerStruct5Typedef is5 = outer.makeInnerStruct5();
|
||||
Outer.InnerUnion5Typedef iu5 = outer.makeInnerUnion5();
|
||||
|
||||
ic5 = outer.makeInnerClass5Typedef();
|
||||
is5 = outer.makeInnerStruct5Typedef();
|
||||
iu5 = outer.makeInnerUnion5Typedef();
|
||||
|
||||
{
|
||||
Outer.InnerMultiple im1 = outer.MultipleInstance1;
|
||||
Outer.InnerMultiple im2 = outer.MultipleInstance2;
|
||||
Outer.InnerMultiple im3 = outer.MultipleInstance3;
|
||||
Outer.InnerMultiple im4 = outer.MultipleInstance4;
|
||||
}
|
||||
|
||||
{
|
||||
Outer.InnerMultipleDerived im1 = outer.MultipleDerivedInstance1;
|
||||
Outer.InnerMultipleDerived im2 = outer.MultipleDerivedInstance2;
|
||||
Outer.InnerMultipleDerived im3 = outer.MultipleDerivedInstance3;
|
||||
Outer.InnerMultipleDerived im4 = outer.MultipleDerivedInstance4;
|
||||
}
|
||||
|
||||
{
|
||||
Outer.InnerMultipleDerived im1 = outer.MultipleDerivedInstance1;
|
||||
Outer.InnerMultipleDerived im2 = outer.MultipleDerivedInstance2;
|
||||
Outer.InnerMultipleDerived im3 = outer.MultipleDerivedInstance3;
|
||||
Outer.InnerMultipleDerived im4 = outer.MultipleDerivedInstance4;
|
||||
}
|
||||
|
||||
{
|
||||
Outer.InnerMultipleAnonTypedef1 mat1 = outer.makeInnerMultipleAnonTypedef1();
|
||||
Outer.InnerMultipleAnonTypedef1 mat2 = outer.makeInnerMultipleAnonTypedef2();
|
||||
SWIGTYPE_p_p_Outer__InnerMultipleAnonTypedef1 mat3 = outer.makeInnerMultipleAnonTypedef3();
|
||||
|
||||
Outer.InnerMultipleNamedTypedef1 mnt = outer.makeInnerMultipleNamedTypedef();
|
||||
Outer.InnerMultipleNamedTypedef1 mnt1 = outer.makeInnerMultipleNamedTypedef1();
|
||||
Outer.InnerMultipleNamedTypedef1 mnt2 = outer.makeInnerMultipleNamedTypedef2();
|
||||
SWIGTYPE_p_p_Outer__InnerMultipleNamedTypedef mnt3 = outer.makeInnerMultipleNamedTypedef3();
|
||||
}
|
||||
{
|
||||
Outer.InnerSameName isn = outer.makeInnerSameName();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
using System;
|
||||
using nested_structsNamespace;
|
||||
#pragma warning disable 219
|
||||
|
||||
public class runme {
|
||||
static void Main() {
|
||||
Outer outer = new Outer();
|
||||
nested_structs.setValues(outer, 10);
|
||||
|
||||
Outer_inner1 inner1 = outer.inner1;
|
||||
Outer_inner1 inner2 = outer.inner2;
|
||||
Outer_inner1 inner3 = outer.inner3;
|
||||
Outer_inner1 inner4 = outer.inner4;
|
||||
if (inner1.val != 10) throw new Exception("failed inner1");
|
||||
if (inner2.val != 20) throw new Exception("failed inner2");
|
||||
if (inner3.val != 20) throw new Exception("failed inner3");
|
||||
if (inner4.val != 40) throw new Exception("failed inner4");
|
||||
|
||||
Named inside1 = outer.inside1;
|
||||
Named inside2 = outer.inside2;
|
||||
Named inside3 = outer.inside3;
|
||||
Named inside4 = outer.inside4;
|
||||
if (inside1.val != 100) throw new Exception("failed inside1");
|
||||
if (inside2.val != 200) throw new Exception("failed inside2");
|
||||
if (inside3.val != 200) throw new Exception("failed inside3");
|
||||
if (inside4.val != 400) throw new Exception("failed inside4");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
using System;
|
||||
using nested_workaroundNamespace;
|
||||
#pragma warning disable 219
|
||||
|
||||
public class runme {
|
||||
static void Main() {
|
||||
{
|
||||
Inner inner = new Inner(5);
|
||||
Outer outer = new Outer();
|
||||
Inner newInner = outer.doubleInnerValue(inner);
|
||||
if (newInner.getValue() != 10)
|
||||
throw new Exception("inner failed");
|
||||
}
|
||||
|
||||
{
|
||||
Outer outer = new Outer();
|
||||
Inner inner = outer.createInner(3);
|
||||
Inner newInner = outer.doubleInnerValue(inner);
|
||||
if (outer.getInnerValue(newInner) != 6)
|
||||
throw new Exception("inner failed");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
using System;
|
||||
using template_nestedNamespace;
|
||||
#pragma warning disable 219
|
||||
|
||||
public class runme {
|
||||
static void Main() {
|
||||
new T_NormalTemplateNormalClass().tmethod(new NormalClass());
|
||||
new OuterClass().T_OuterTMethodNormalClass(new NormalClass());
|
||||
|
||||
TemplateFuncs tf = new TemplateFuncs();
|
||||
if (tf.T_TemplateFuncs1Int(-10) != -10)
|
||||
throw new Exception("it failed");
|
||||
if (tf.T_TemplateFuncs2Double(-12.3) != -12.3)
|
||||
throw new Exception("it failed");
|
||||
|
||||
T_NestedOuterTemplateDouble tn = new T_NestedOuterTemplateDouble();
|
||||
if (tn.hohum(-12.3) != -12.3)
|
||||
throw new Exception("it failed");
|
||||
OuterClass.T_OuterClassInner1Int inner1 = new OuterClass().useInner1(new OuterClass.T_OuterClassInner1Int());
|
||||
OuterClass.T_OuterClassInner2NormalClass inner2 = new OuterClass.T_OuterClassInner2NormalClass();
|
||||
inner2.embeddedVar = 2;
|
||||
OuterClass.T_OuterClassInner2NormalClass inner22 = new OuterClass().useInner2Again(inner2);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
|
||||
import derived_nested.*;
|
||||
|
||||
public class derived_nested_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("derived_nested");
|
||||
} 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[]) {
|
||||
BB outer = new BB();
|
||||
BB.DD d = new BB.DD();
|
||||
BB.EE e = new BB.EE();
|
||||
outer.getFf_instance().setZ(outer.getFf_instance().getX());
|
||||
outer.useEE(e);
|
||||
}
|
||||
}
|
|
@ -146,6 +146,10 @@ static Node *copy_node(Node *n) {
|
|||
Delete(pl);
|
||||
continue;
|
||||
}
|
||||
if (strcmp(ckey,"nested:outer") == 0) { /* don't copy outer classes links, they will be updated later */
|
||||
Setattr(nn, key, k.item);
|
||||
continue;
|
||||
}
|
||||
/* Looks okay. Just copy the data using Copy */
|
||||
ci = Copy(k.item);
|
||||
Setattr(nn, key, ci);
|
||||
|
@ -2662,7 +2666,7 @@ template_directive: SWIGTEMPLATE LPAREN idstringopt RPAREN idcolonnt LESSTHAN va
|
|||
}
|
||||
|
||||
templnode = copy_node(nn);
|
||||
update_nested_classes(templnode);
|
||||
update_nested_classes(templnode); /* update classes nested withing template */
|
||||
/* We need to set the node name based on name used to instantiate */
|
||||
Setattr(templnode,"name",tname);
|
||||
Delete(tname);
|
||||
|
@ -2698,7 +2702,10 @@ template_directive: SWIGTEMPLATE LPAREN idstringopt RPAREN idcolonnt LESSTHAN va
|
|||
Delete(temparms);
|
||||
if (currentOuterClass) {
|
||||
SetFlag(templnode, "nested");
|
||||
Setattr(templnode, "nested:outer", currentOuterClass);
|
||||
}
|
||||
else
|
||||
Delattr(templnode, "nested:outer");
|
||||
|
||||
add_symbols_copy(templnode);
|
||||
|
||||
|
|
Loading…
Reference in New Issue