Merge branch 'master' into doxygen
The way Python docstrings are indented has changed on master, so use the standard inspect module in Python autodoc unit test to ignore the differences in their indentation level between -builtin and non-builtin cases to make the test still pass with the branch version, which avoids the use of different (but almost identical) values in the test itself.
This commit is contained in:
commit
e668c47b70
1094 changed files with 39390 additions and 11483 deletions
|
|
@ -5,7 +5,7 @@
|
|||
LANGUAGE = java
|
||||
JAVA = @JAVA@
|
||||
JAVAC = @JAVAC@
|
||||
JAVAFLAGS = -Xcheck:jni
|
||||
JAVAFLAGS = @JAVAFLAGS@
|
||||
JAVA_CLASSPATH_SEP := @JAVA_CLASSPATH_SEP@
|
||||
SCRIPTSUFFIX = _runme.java
|
||||
|
||||
|
|
@ -28,6 +28,7 @@ CPP_TEST_CASES = \
|
|||
java_director_assumeoverride \
|
||||
java_director_exception_feature \
|
||||
java_director_exception_feature_nspace \
|
||||
java_director_ptrclass \
|
||||
java_enums \
|
||||
java_jnitypes \
|
||||
java_lib_arrays_dimensionless \
|
||||
|
|
@ -38,7 +39,7 @@ CPP_TEST_CASES = \
|
|||
java_prepost \
|
||||
java_throws \
|
||||
java_typemaps_proxy \
|
||||
java_typemaps_typewrapper
|
||||
java_typemaps_typewrapper \
|
||||
# li_boost_intrusive_ptr
|
||||
|
||||
CPP11_TEST_CASES = \
|
||||
|
|
@ -59,12 +60,13 @@ JAVA_PACKAGEOPT = -package $(JAVA_PACKAGE)
|
|||
SWIGOPT += $(JAVA_PACKAGEOPT)
|
||||
|
||||
# Custom tests - tests with additional commandline options
|
||||
java_nspacewithoutpackage.%: JAVA_PACKAGEOPT =
|
||||
java_director_exception_feature_nspace.%: JAVA_PACKAGE = $*Package
|
||||
nspace.%: JAVA_PACKAGE = $*Package
|
||||
nspace_extend.%: JAVA_PACKAGE = $*Package
|
||||
director_nspace.%: JAVA_PACKAGE = $*Package
|
||||
director_nspace_director_name_collision.%: JAVA_PACKAGE = $*Package
|
||||
java_director_exception_feature_nspace.%: JAVA_PACKAGE = $*Package
|
||||
java_nspacewithoutpackage.%: JAVA_PACKAGEOPT =
|
||||
multiple_inheritance_nspace.%: JAVA_PACKAGE = $*Package
|
||||
nspace.%: JAVA_PACKAGE = $*Package
|
||||
nspace_extend.%: JAVA_PACKAGE = $*Package
|
||||
doxygen_misc_constructs.%: INCLUDES = -I../$(srcdir)/..
|
||||
|
||||
# Rules for the different types of tests
|
||||
|
|
|
|||
|
|
@ -20,5 +20,11 @@ public class char_binary_runme {
|
|||
|
||||
if (t.strlen(hil0) != 4)
|
||||
throw new RuntimeException("bad multi-arg typemap");
|
||||
|
||||
if (t.ustrlen(hile) != 4)
|
||||
throw new RuntimeException("bad multi-arg typemap");
|
||||
|
||||
if (t.ustrlen(hil0) != 4)
|
||||
throw new RuntimeException("bad multi-arg typemap");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,5 +18,9 @@ public class constant_directive_runme {
|
|||
throw new RuntimeException("fail");
|
||||
if (constant_directive.TYPE1_CONSTANT3.getVal() != 3)
|
||||
throw new RuntimeException("fail");
|
||||
if (constant_directive.TYPE1CONST_CONSTANT1.getVal() != 1)
|
||||
throw new RuntimeException("fail");
|
||||
if (constant_directive.TYPE1CPTR_CONSTANT1.getVal() != 1)
|
||||
throw new RuntimeException("fail");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
82
Examples/test-suite/java/cpp11_li_std_array_runme.java
Normal file
82
Examples/test-suite/java/cpp11_li_std_array_runme.java
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
import cpp11_li_std_array.*;
|
||||
|
||||
public class cpp11_li_std_array_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("cpp11_li_std_array");
|
||||
} 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);
|
||||
}
|
||||
}
|
||||
|
||||
private static ArrayInt6 ToArray6(int [] a) {
|
||||
ArrayInt6 ai = new ArrayInt6();
|
||||
if (a.length != 6)
|
||||
throw new RuntimeException("a is incorrect size");
|
||||
for (int i=0; i<6; ++i)
|
||||
ai.set(i, a[i]);
|
||||
return ai;
|
||||
}
|
||||
|
||||
private static void compareContainers(ArrayInt6 actual, int[] expected) {
|
||||
if (actual.size() != expected.length)
|
||||
throw new RuntimeException("Sizes are different: " + actual.size() + " " + expected.length);
|
||||
for (int i=0; i<actual.size(); ++i) {
|
||||
int actualValue = actual.get(i);
|
||||
int expectedValue = expected[i];
|
||||
if (actualValue != expectedValue)
|
||||
throw new RuntimeException("Value is wrong for element " + i + ". Expected " + expectedValue + " got: " + actualValue);
|
||||
}
|
||||
if (actual.isEmpty())
|
||||
throw new RuntimeException("ai should not be empty");
|
||||
}
|
||||
|
||||
public static void main(String argv[]) {
|
||||
ArrayInt6 ai = new ArrayInt6();
|
||||
compareContainers(ai, new int[] {0, 0, 0, 0, 0, 0});
|
||||
|
||||
int[] vals = {10, 20, 30, 40, 50, 60};
|
||||
for (int i=0; i<ai.size(); ++i)
|
||||
ai.set(i, vals[i]);
|
||||
compareContainers(ai, vals);
|
||||
|
||||
// Check return
|
||||
compareContainers(cpp11_li_std_array.arrayOutVal(), new int[] {-2, -1, 0, 0, 1, 2});
|
||||
compareContainers(cpp11_li_std_array.arrayOutConstRef(), new int[] {-2, -1, 0, 0, 1, 2});
|
||||
compareContainers(cpp11_li_std_array.arrayOutRef(), new int[] {-2, -1, 0, 0, 1, 2});
|
||||
compareContainers(cpp11_li_std_array.arrayOutPtr(), new int[] {-2, -1, 0, 0, 1, 2});
|
||||
|
||||
// Check passing arguments
|
||||
ai = cpp11_li_std_array.arrayInVal(ToArray6(new int[] {9, 8, 7, 6, 5, 4}));
|
||||
compareContainers(ai, new int[] {90, 80, 70, 60, 50, 40});
|
||||
|
||||
ai = cpp11_li_std_array.arrayInConstRef(ToArray6(new int[] {9, 8, 7, 6, 5, 4}));
|
||||
compareContainers(ai, new int[] {90, 80, 70, 60, 50, 40});
|
||||
|
||||
ai = new ArrayInt6(ToArray6(new int[] {9, 8, 7, 6, 5, 4}));
|
||||
cpp11_li_std_array.arrayInRef(ai);
|
||||
compareContainers(ai, new int[] {90, 80, 70, 60, 50, 40});
|
||||
|
||||
ai = new ArrayInt6(ToArray6(new int[] {9, 8, 7, 6, 5, 4}));
|
||||
cpp11_li_std_array.arrayInPtr(ai);
|
||||
compareContainers(ai, new int[] {90, 80, 70, 60, 50, 40});
|
||||
|
||||
// fill
|
||||
ai.fill(111);
|
||||
compareContainers(ai, new int[] {111, 111, 111, 111, 111, 111});
|
||||
|
||||
// out of range errors
|
||||
try {
|
||||
ai.set((int)ai.size(), 0);
|
||||
throw new RuntimeException("Out of range exception not caught");
|
||||
} catch(IndexOutOfBoundsException e) {
|
||||
}
|
||||
try {
|
||||
ai.set(-1, 0);
|
||||
throw new RuntimeException("Out of range exception not caught");
|
||||
} catch(IndexOutOfBoundsException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -140,7 +140,7 @@ public class director_classes_runme {
|
|||
Package packag = klass.getPackage();
|
||||
String simpleName = null;
|
||||
if (packag != null)
|
||||
simpleName = fullName.replaceAll(packag.getName() + ".", "");
|
||||
simpleName = fullName.replaceAll(packag.getName() + "\\.", "");
|
||||
else
|
||||
simpleName = fullName;
|
||||
return simpleName;
|
||||
|
|
|
|||
48
Examples/test-suite/java/director_pass_by_value_runme.java
Normal file
48
Examples/test-suite/java/director_pass_by_value_runme.java
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
|
||||
import director_pass_by_value.*;
|
||||
|
||||
public class director_pass_by_value_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("director_pass_by_value");
|
||||
} 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);
|
||||
}
|
||||
}
|
||||
|
||||
private static void WaitForGC() {
|
||||
System.gc();
|
||||
System.runFinalization();
|
||||
try {
|
||||
java.lang.Thread.sleep(10);
|
||||
} catch (java.lang.InterruptedException e) {
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String argv[]) {
|
||||
Caller caller = new Caller();
|
||||
caller.call_virtualMethod(new director_pass_by_value_Derived());
|
||||
{
|
||||
int countdown = 5;
|
||||
while (true) {
|
||||
WaitForGC();
|
||||
if (--countdown == 0)
|
||||
break;
|
||||
};
|
||||
}
|
||||
// bug was the passByVal 'global' object was destroyed after the call to virtualMethod had finished.
|
||||
int ret = director_pass_by_value_runme.passByVal.getVal();
|
||||
if (ret != 0x12345678)
|
||||
throw new RuntimeException("Bad return value, got " + Integer.toHexString(ret));
|
||||
}
|
||||
|
||||
static PassedByValue passByVal;
|
||||
}
|
||||
|
||||
class director_pass_by_value_Derived extends DirectorPassByValueAbstractBase {
|
||||
public void virtualMethod(PassedByValue pbv) {
|
||||
director_pass_by_value_runme.passByVal = pbv;
|
||||
}
|
||||
}
|
||||
|
|
@ -12,18 +12,35 @@ public class director_smartptr_runme {
|
|||
}
|
||||
}
|
||||
|
||||
public static void main(String argv[]) {
|
||||
director_smartptr_MyBarFoo myBarFoo =
|
||||
new director_smartptr_MyBarFoo();
|
||||
private static void check(String got, String expected) {
|
||||
if (!got.equals(expected))
|
||||
throw new RuntimeException("Failed, got: " + got + " expected: " + expected);
|
||||
}
|
||||
|
||||
public static void main(String argv[]) {
|
||||
director_smartptr.FooBar fooBar = new director_smartptr.FooBar();
|
||||
|
||||
director_smartptr.Foo myBarFoo = new director_smartptr_MyBarFoo();
|
||||
check(myBarFoo.ping(), "director_smartptr_MyBarFoo.ping()");
|
||||
check(director_smartptr.Foo.callPong(myBarFoo), "director_smartptr_MyBarFoo.pong();director_smartptr_MyBarFoo.ping()");
|
||||
check(director_smartptr.Foo.callUpcall(myBarFoo, fooBar), "override;Bar::Foo2::Foo2Bar()");
|
||||
|
||||
director_smartptr.Foo myFoo = myBarFoo.makeFoo();
|
||||
check(myFoo.pong(), "Foo::pong();Foo::ping()");
|
||||
check(director_smartptr.Foo.callPong(myFoo), "Foo::pong();Foo::ping()");
|
||||
check(myFoo.upcall(fooBar), "Bar::Foo2::Foo2Bar()");
|
||||
|
||||
director_smartptr.Foo myFoo2 = new director_smartptr.Foo().makeFoo();
|
||||
check(myFoo2.pong(), "Foo::pong();Foo::ping()");
|
||||
check(director_smartptr.Foo.callPong(myFoo2), "Foo::pong();Foo::ping()");
|
||||
}
|
||||
}
|
||||
|
||||
class director_smartptr_MyBarFoo extends director_smartptr.Foo {
|
||||
|
||||
@Override
|
||||
public String ping() {
|
||||
return "director_smartptr_MyBarFoo.ping();";
|
||||
return "director_smartptr_MyBarFoo.ping()";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -32,17 +49,12 @@ class director_smartptr_MyBarFoo extends director_smartptr.Foo {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String fooBar(director_smartptr.FooBar fooBar) {
|
||||
return fooBar.FooBarDo();
|
||||
public String upcall(director_smartptr.FooBar fooBarPtr) {
|
||||
return "override;" + fooBarPtr.FooBarDo();
|
||||
}
|
||||
|
||||
@Override
|
||||
public director_smartptr.Foo makeFoo() {
|
||||
return new director_smartptr.Foo();
|
||||
}
|
||||
|
||||
@Override
|
||||
public director_smartptr.FooBar makeFooBar() {
|
||||
return new director_smartptr.FooBar();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
47
Examples/test-suite/java/java_director_ptrclass_runme.java
Normal file
47
Examples/test-suite/java/java_director_ptrclass_runme.java
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
|
||||
import java_director_ptrclass.*;
|
||||
|
||||
public class java_director_ptrclass_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("java_director_ptrclass");
|
||||
} 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[]) {
|
||||
Foo f = new Foo();
|
||||
Foo ft = new TouchingFoo();
|
||||
Baz b = new Baz();
|
||||
if (b.GetTouched()) {
|
||||
throw new RuntimeException ( "Baz should not have been touched yet." );
|
||||
}
|
||||
|
||||
Baz b2 = f.FinalMaybeTouch(b);
|
||||
|
||||
if (b2.GetTouched() || b.GetTouched()) {
|
||||
throw new RuntimeException ( "Baz should not have been touched by Foo." );
|
||||
}
|
||||
|
||||
Baz b3 = ft.FinalMaybeTouch(b);
|
||||
|
||||
if (!b.GetTouched() || !b3.GetTouched() || !b2.GetTouched()) {
|
||||
throw new RuntimeException ( "Baz was not touched by TouchingFoo. This" +
|
||||
" might mean the directorin typemap is not" +
|
||||
" parsing the typemap(jstype, Bar) in its" +
|
||||
" 'descriptor' kwarg correctly." );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class TouchingFoo extends Foo {
|
||||
@Override
|
||||
public Baz MaybeTouch(Baz baz_ptr) {
|
||||
baz_ptr.SetTouched();
|
||||
return baz_ptr;
|
||||
}
|
||||
}
|
||||
|
||||
88
Examples/test-suite/java/li_carrays_cpp_runme.java
Normal file
88
Examples/test-suite/java/li_carrays_cpp_runme.java
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
import li_carrays_cpp.*;
|
||||
|
||||
public class li_carrays_cpp_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("li_carrays_cpp");
|
||||
} 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
|
||||
{
|
||||
// array_class
|
||||
{
|
||||
int length = 5;
|
||||
XYArray xyArray = new XYArray(length);
|
||||
for (int i=0; i<length; i++) {
|
||||
XY xy = xyArray.getitem(i);
|
||||
xy.setX(i*10);
|
||||
xy.setY(i*100);
|
||||
xyArray.setitem(i, xy);
|
||||
}
|
||||
for (int i=0; i<length; i++) {
|
||||
Assert(xyArray.getitem(i).getX(), i*10);
|
||||
Assert(xyArray.getitem(i).getY(), i*100);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
// global array variable
|
||||
int length = 3;
|
||||
XY xyArrayPointer = li_carrays_cpp.getGlobalXYArray();
|
||||
XYArray xyArray = XYArray.frompointer(xyArrayPointer);
|
||||
for (int i=0; i<length; i++) {
|
||||
XY xy = xyArray.getitem(i);
|
||||
xy.setX(i*10);
|
||||
xy.setY(i*100);
|
||||
xyArray.setitem(i, xy);
|
||||
}
|
||||
for (int i=0; i<length; i++) {
|
||||
Assert(xyArray.getitem(i).getX(), i*10);
|
||||
Assert(xyArray.getitem(i).getY(), i*100);
|
||||
}
|
||||
}
|
||||
|
||||
// array_functions
|
||||
{
|
||||
int length = 5;
|
||||
AB abArray = li_carrays_cpp.new_ABArray(length);
|
||||
for (int i=0; i<length; i++) {
|
||||
AB ab = li_carrays_cpp.ABArray_getitem(abArray, i);
|
||||
ab.setA(i*10);
|
||||
ab.setB(i*100);
|
||||
li_carrays_cpp.ABArray_setitem(abArray, i, ab);
|
||||
}
|
||||
for (int i=0; i<length; i++) {
|
||||
Assert(li_carrays_cpp.ABArray_getitem(abArray, i).getA(), i*10);
|
||||
Assert(li_carrays_cpp.ABArray_getitem(abArray, i).getB(), i*100);
|
||||
}
|
||||
li_carrays_cpp.delete_ABArray(abArray);
|
||||
}
|
||||
|
||||
{
|
||||
// global array variable
|
||||
int length = 3;
|
||||
AB abArray = li_carrays_cpp.getGlobalABArray();
|
||||
for (int i=0; i<length; i++) {
|
||||
AB ab = li_carrays_cpp.ABArray_getitem(abArray, i);
|
||||
ab.setA(i*10);
|
||||
ab.setB(i*100);
|
||||
li_carrays_cpp.ABArray_setitem(abArray, i, ab);
|
||||
}
|
||||
for (int i=0; i<length; i++) {
|
||||
Assert(li_carrays_cpp.ABArray_getitem(abArray, i).getA(), i*10);
|
||||
Assert(li_carrays_cpp.ABArray_getitem(abArray, i).getB(), i*100);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void Assert(int val1, int val2) {
|
||||
// System.out.println("val1=" + val1 + " val2=" + val2);
|
||||
if (val1 != val2)
|
||||
throw new RuntimeException("Mismatch. val1=" + val1 + " val2=" + val2);
|
||||
}
|
||||
}
|
||||
24
Examples/test-suite/java/li_cdata_cpp_runme.java
Normal file
24
Examples/test-suite/java/li_cdata_cpp_runme.java
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
import li_cdata_cpp.*;
|
||||
|
||||
public class li_cdata_cpp_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("li_cdata_cpp");
|
||||
} 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
|
||||
{
|
||||
byte[] s = "ABC abc".getBytes();
|
||||
SWIGTYPE_p_void m = li_cdata_cpp.malloc(256);
|
||||
li_cdata_cpp.memmove(m, s);
|
||||
byte[] ss = li_cdata_cpp.cdata(m, 7);
|
||||
String ss_string = new String(ss);
|
||||
if (!ss_string.equals("ABC abc"))
|
||||
throw new RuntimeException("failed got: " + ss_string);
|
||||
}
|
||||
}
|
||||
|
|
@ -3,7 +3,8 @@
|
|||
// unsigned long long types map correctly to long and BigInteger respectively.
|
||||
|
||||
import long_long.*;
|
||||
import java.math.*;
|
||||
import java.math.BigInteger;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class long_long_runme {
|
||||
|
||||
|
|
@ -54,12 +55,57 @@ public class long_long_runme {
|
|||
check_ull(testNumber);
|
||||
testNumber = testNumber.add(BigInteger.ONE);
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
long_long.setUll(null);
|
||||
throw new RuntimeException("null check failed");
|
||||
} catch (NullPointerException e) {
|
||||
}
|
||||
|
||||
// UnsignedToSigned - checks that a cast from unsigned long long to long long in C
|
||||
// gives expected value (including -ve numbers)
|
||||
|
||||
long[] nums = {
|
||||
0x00,
|
||||
0xFF, 0x80, 0x7F, 0x01,
|
||||
-0xFF, -0x80, -0x7F, -0x01,
|
||||
0x100, 0x10000,
|
||||
-0x100, -0x10000,
|
||||
0xFFFF, 0xFF80, 0xFF7F, 0xFF01, 0xFF00,
|
||||
-0xFFFF, -0xFF80, -0xFF7F, -0xFF01, -0xFF00,
|
||||
0x7FFF, 0x7F80, 0x7F7F, 0x7F01, 0x7F00,
|
||||
-0x7FFF, -0x7F80, -0x7F7F, -0x7F01, -0x7F00,
|
||||
0x80FF, 0x8080, 0x807F, 0x8001, 0x8000,
|
||||
-0x80FF, -0x8080, -0x807F, -0x8001, -0x8000,
|
||||
Integer.MAX_VALUE, Integer.MIN_VALUE,
|
||||
Integer.MAX_VALUE+1, Integer.MIN_VALUE-1,
|
||||
Long.MAX_VALUE, Long.MIN_VALUE,
|
||||
};
|
||||
|
||||
ArrayList<BigInteger> bigIntegers = new ArrayList<BigInteger>();
|
||||
for (int i=0; i<nums.length; ++i) {
|
||||
BigInteger bi = new BigInteger(new Long(nums[i]).toString());
|
||||
bigIntegers.add(bi);
|
||||
}
|
||||
|
||||
{
|
||||
BigInteger bi = new BigInteger(new Long(Long.MAX_VALUE).toString());
|
||||
bigIntegers.add(bi.add(BigInteger.ONE));
|
||||
bi = new BigInteger(new Long(Long.MIN_VALUE).toString());
|
||||
bigIntegers.add(bi.subtract(BigInteger.ONE));
|
||||
}
|
||||
|
||||
boolean failed = false;
|
||||
for (int i=0; i<bigIntegers.size(); ++i) {
|
||||
BigInteger bi = (BigInteger)bigIntegers.get(i);
|
||||
long longReturn = long_long.UnsignedToSigned(bi);
|
||||
if (bi.longValue() != longReturn) {
|
||||
System.err.println("Conversion to long failed, in:" + bi + " out:" + longReturn);
|
||||
failed = true;
|
||||
}
|
||||
}
|
||||
if (failed)
|
||||
throw new RuntimeException("There were UnsignedToSigned failures");
|
||||
}
|
||||
|
||||
public static void check_ll(long ll) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,253 @@
|
|||
import multiple_inheritance_abstract.*;
|
||||
|
||||
public class multiple_inheritance_abstract_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("multiple_inheritance_abstract");
|
||||
} 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);
|
||||
}
|
||||
}
|
||||
|
||||
//Test base class as a parameter in java
|
||||
int jcbase1b(CBase1 cb1){
|
||||
return cb1.cbase1y();
|
||||
}
|
||||
int jabase1(ABase1 ab1){
|
||||
return ab1.abase1();
|
||||
}
|
||||
int jcbase2(CBase2 cb2){
|
||||
return cb2.cbase2();
|
||||
}
|
||||
|
||||
public static void check(boolean fail, String msg) {
|
||||
if (fail)
|
||||
throw new RuntimeException(msg);
|
||||
}
|
||||
|
||||
public static void main(String argv[]) {
|
||||
//Test Derived1
|
||||
Derived1 d1=new Derived1();
|
||||
check(d1.cbase1y()!=3, "Derived1::cbase1y() failed");
|
||||
check(d1.cbase2()!=4, "Derived1::cbase2() failed");
|
||||
|
||||
//Test Derived2
|
||||
Derived2 d2=new Derived2();
|
||||
check(d2.cbase1y()!=6, "Derived2::cbase1y() failed");
|
||||
check(d2.abase1()!=5, "Derived2::abase1() failed");
|
||||
|
||||
//Test Derived3
|
||||
Derived3 d3=new Derived3();
|
||||
check(d3.cbase1y()!=7, "Derived3::cbase1y() failed");
|
||||
check(d3.cbase2()!=8, "Derived3::cbase2() failed");
|
||||
check(d3.abase1()!=9, "Derived3::abase1() failed");
|
||||
|
||||
//Test Bottom1
|
||||
Bottom1 b1=new Bottom1();
|
||||
check(b1.cbase1y()!=103, "Bottom1::cbase1y() failed");
|
||||
check(b1.cbase2()!=104, "Bottom1::cbase2() failed");
|
||||
|
||||
//Test Bottom2
|
||||
Bottom2 b2=new Bottom2();
|
||||
check(b2.cbase1y()!=206, "Bottom2::cbase1y() failed");
|
||||
check(b2.abase1()!=205, "Bottom2::abase1() failed");
|
||||
|
||||
//Test Bottom3
|
||||
Bottom3 b3=new Bottom3();
|
||||
check(b3.cbase1y()!=307, "Bottom3::cbase1y() failed");
|
||||
check(b3.cbase2()!=308, "Bottom3::cbase2() failed");
|
||||
check(b3.abase1()!=309, "Bottom3::abase1() failed");
|
||||
|
||||
//Test interfaces from c++ classes
|
||||
CBase1 cb1=new CBase1SwigImpl();
|
||||
CBase2 cb2=new CBase2SwigImpl();
|
||||
check(cb1.cbase1y()!=1, "CBase1::cbase1y() failed");
|
||||
check(cb2.cbase2()!=2, "CBase2::cbase2() failed");
|
||||
|
||||
//Test abstract class as return value
|
||||
ABase1 ab1=d3.cloneit();
|
||||
check(ab1.abase1()!=9, "Derived3::abase1() through ABase1 failed");
|
||||
|
||||
//Test concrete base class as return value
|
||||
CBase1 cb6=d2.cloneit();
|
||||
CBase2 cb7=d1.cloneit();
|
||||
check(cb6.cbase1y()!=6, "Derived2::cbase1y() through CBase1 failed");
|
||||
check(cb7.cbase2()!=4, "Derived1:cbase2() through ABase1 failed");
|
||||
|
||||
//Test multi inheritance
|
||||
CBase1 cb3=new Derived1();
|
||||
CBase1 cb4=new Derived3();
|
||||
CBase2 cb5=new Derived3();
|
||||
ABase1 ab6=new Derived2();
|
||||
check(cb3.cbase1y()!=3, "Derived1::cbase1y() through CBase1 failed");
|
||||
check(cb4.cbase1y()!=7, "Derived3::cbase1y() through CBase1 failed");
|
||||
check(cb5.cbase2()!=8, "Derived3::cbase2() through CBase2 failed");
|
||||
check(ab6.abase1()!=5, "Derived2::abase1() through ABase1 failed");
|
||||
|
||||
//Test base classes as parameter in java
|
||||
multiple_inheritance_abstract_runme mhar=new multiple_inheritance_abstract_runme();
|
||||
check(mhar.jcbase1b(d1)!=3, "jcbase1b() through Derived1 as parameter failed");
|
||||
check(mhar.jcbase1b(d2)!=6, "jcbase1b() through Derived2 as parameter failed");
|
||||
check(mhar.jcbase1b(d3)!=7, "jcbase1b() through Derived3 as parameter failed");
|
||||
check(mhar.jcbase2(d1)!=4, "jcbase2() through Derived1 as parameter failed");
|
||||
check(mhar.jcbase2(d3)!=8, "jcbase2() through Derived3 as parameter failed");
|
||||
check(mhar.jabase1(d2)!=5, "jabase1() through Derived2 as parameter failed");
|
||||
check(mhar.jabase1(d3)!=9, "jabase1() through Derived3 as parameter failed");
|
||||
|
||||
//Value parameters
|
||||
//Test CBase1 CBase2 as parameters (note slicing for Derived and Bottom classes)
|
||||
check(multiple_inheritance_abstract.InputValCBase1(d1)!=1, "InputValCBase1(), Derived1 as a parameter failed");
|
||||
check(multiple_inheritance_abstract.InputValCBase1(d2)!=1, "InputValCBase1(), Derived2 as a parameter failed");
|
||||
check(multiple_inheritance_abstract.InputValCBase1(d3)!=1, "InputValCBase1(), Derived3 as a parameter failed");
|
||||
check(multiple_inheritance_abstract.InputValCBase2(d3)!=2, "InputValCBase2(), Derived3 as a parameter failed");
|
||||
check(multiple_inheritance_abstract.InputValCBase2(d1)!=2, "InputValCBase2(), Derived1 as a parameter failed");
|
||||
check(multiple_inheritance_abstract.InputValCBase1(cb1)!=1, "InputValCBase1(), CBase1 as a parameter failed");
|
||||
check(multiple_inheritance_abstract.InputValCBase2(cb2)!=2, "InputValCBase2(), CBase2 as a parameter failed");
|
||||
check(multiple_inheritance_abstract.InputValCBase1(b1)!=1, "InputValCBase1(), Bottom1 as a parameter failed");
|
||||
check(multiple_inheritance_abstract.InputValCBase1(b2)!=1, "InputValCBase1(), Bottom2 as a parameter failed");
|
||||
check(multiple_inheritance_abstract.InputValCBase1(b3)!=1, "InputValCBase1(), Bottom3 as a parameter failed");
|
||||
check(multiple_inheritance_abstract.InputValCBase2(b3)!=2, "InputValCBase2(), Bottom3 as a parameter failed");
|
||||
check(multiple_inheritance_abstract.InputValCBase2(b1)!=2, "InputValCBase2(), Bottom1 as a parameter failed");
|
||||
|
||||
//Pointer parameters
|
||||
//Test ABase1 as a parameter
|
||||
check(multiple_inheritance_abstract.InputPtrABase1(d2)!=5, "InputPtrABase1() through Derived2 as a parameter failed");
|
||||
check(multiple_inheritance_abstract.InputPtrABase1(d3)!=9, "InputPtrABase1() through Derived3 as a parameter failed");
|
||||
check(multiple_inheritance_abstract.InputPtrABase1(b2)!=205, "InputPtrABase1() through Bottom2 as a parameter failed");
|
||||
check(multiple_inheritance_abstract.InputPtrABase1(b3)!=309, "InputPtrABase1() through Bottom3 as a parameter failed");
|
||||
|
||||
//Test CBase1 CBase2 as parameters
|
||||
check(multiple_inheritance_abstract.InputPtrCBase1(d1)!=3, "InputPtrCBase1(), Derived1 as a parameter failed");
|
||||
check(multiple_inheritance_abstract.InputPtrCBase1(d2)!=6, "InputPtrCBase1(), Derived2 as a parameter failed");
|
||||
check(multiple_inheritance_abstract.InputPtrCBase1(d3)!=7, "InputPtrCBase1(), Derived3 as a parameter failed");
|
||||
check(multiple_inheritance_abstract.InputPtrCBase2(d3)!=8, "InputPtrCBase2(), Derived3 as a parameter failed");
|
||||
check(multiple_inheritance_abstract.InputPtrCBase2(d1)!=4, "InputPtrCBase2(), Derived1 as a parameter failed");
|
||||
check(multiple_inheritance_abstract.InputPtrCBase1(cb1)!=1, "InputPtrCBase1(), CBase1 as a parameter failed");
|
||||
check(multiple_inheritance_abstract.InputPtrCBase2(cb2)!=2, "InputPtrCBase2(), CBase2 as a parameter failed");
|
||||
check(multiple_inheritance_abstract.InputPtrCBase1(b1)!=103, "InputPtrCBase1(), Bottom1 as a parameter failed");
|
||||
check(multiple_inheritance_abstract.InputPtrCBase1(b2)!=206, "InputPtrCBase1(), Bottom2 as a parameter failed");
|
||||
check(multiple_inheritance_abstract.InputPtrCBase1(b3)!=307, "InputPtrCBase1(), Bottom3 as a parameter failed");
|
||||
check(multiple_inheritance_abstract.InputPtrCBase2(b3)!=308, "InputPtrCBase2(), Bottom3 as a parameter failed");
|
||||
check(multiple_inheritance_abstract.InputPtrCBase2(b1)!=104, "InputPtrCBase2(), Bottom1 as a parameter failed");
|
||||
|
||||
//Reference parameters
|
||||
//Test ABase1 as a parameter
|
||||
check(multiple_inheritance_abstract.InputRefABase1(d2)!=5, "InputRefABase1() through Derived2 as a parameter failed");
|
||||
check(multiple_inheritance_abstract.InputRefABase1(d3)!=9, "InputRefABase1() through Derived3 as a parameter failed");
|
||||
check(multiple_inheritance_abstract.InputRefABase1(b2)!=205, "InputRefABase1() through Bottom2 as a parameter failed");
|
||||
check(multiple_inheritance_abstract.InputRefABase1(b3)!=309, "InputRefABase1() through Bottom3 as a parameter failed");
|
||||
|
||||
//Test CBase1 CBase2 as parameters
|
||||
check(multiple_inheritance_abstract.InputRefCBase1(d1)!=3, "InputRefCBase1(), Derived1 as a parameter failed");
|
||||
check(multiple_inheritance_abstract.InputRefCBase1(d2)!=6, "InputRefCBase1(), Derived2 as a parameter failed");
|
||||
check(multiple_inheritance_abstract.InputRefCBase1(d3)!=7, "InputRefCBase1(), Derived3 as a parameter failed");
|
||||
check(multiple_inheritance_abstract.InputRefCBase2(d3)!=8, "InputRefCBase2(), Derived3 as a parameter failed");
|
||||
check(multiple_inheritance_abstract.InputRefCBase2(d1)!=4, "InputRefCBase2(), Derived1 as a parameter failed");
|
||||
check(multiple_inheritance_abstract.InputRefCBase1(cb1)!=1, "InputRefCBase1(), CBase1 as a parameter failed");
|
||||
check(multiple_inheritance_abstract.InputRefCBase2(cb2)!=2, "InputRefCBase2(), CBase2 as a parameter failed");
|
||||
check(multiple_inheritance_abstract.InputRefCBase1(b1)!=103, "InputRefCBase1(), Bottom1 as a parameter failed");
|
||||
check(multiple_inheritance_abstract.InputRefCBase1(b2)!=206, "InputRefCBase1(), Bottom2 as a parameter failed");
|
||||
check(multiple_inheritance_abstract.InputRefCBase1(b3)!=307, "InputRefCBase1(), Bottom3 as a parameter failed");
|
||||
check(multiple_inheritance_abstract.InputRefCBase2(b3)!=308, "InputRefCBase2(), Bottom3 as a parameter failed");
|
||||
check(multiple_inheritance_abstract.InputRefCBase2(b1)!=104, "InputRefCBase2(), Bottom1 as a parameter failed");
|
||||
|
||||
//Const reference pointer parameters
|
||||
//Test ABase1 as a parameter
|
||||
check(multiple_inheritance_abstract.InputCPtrRefABase1(d2)!=5, "InputCPtrRefABase1() through Derived2 as a parameter failed");
|
||||
check(multiple_inheritance_abstract.InputCPtrRefABase1(d3)!=9, "InputCPtrRefABase1() through Derived3 as a parameter failed");
|
||||
check(multiple_inheritance_abstract.InputCPtrRefABase1(b2)!=205, "InputCPtrRefABase1() through Bottom2 as a parameter failed");
|
||||
check(multiple_inheritance_abstract.InputCPtrRefABase1(b3)!=309, "InputCPtrRefABase1() through Bottom3 as a parameter failed");
|
||||
|
||||
//Test CBase1 CBase2 as parameters
|
||||
check(multiple_inheritance_abstract.InputCPtrRefCBase1(d1)!=3, "InputCPtrRefCBase1(), Derived1 as a parameter failed");
|
||||
check(multiple_inheritance_abstract.InputCPtrRefCBase1(d2)!=6, "InputCPtrRefCBase1(), Derived2 as a parameter failed");
|
||||
check(multiple_inheritance_abstract.InputCPtrRefCBase1(d3)!=7, "InputCPtrRefCBase1(), Derived3 as a parameter failed");
|
||||
check(multiple_inheritance_abstract.InputCPtrRefCBase2(d3)!=8, "InputCPtrRefCBase2(), Derived3 as a parameter failed");
|
||||
check(multiple_inheritance_abstract.InputCPtrRefCBase2(d1)!=4, "InputCPtrRefCBase2(), Derived1 as a parameter failed");
|
||||
check(multiple_inheritance_abstract.InputCPtrRefCBase1(cb1)!=1, "InputCPtrRefCBase1(), CBase1 as a parameter failed");
|
||||
check(multiple_inheritance_abstract.InputCPtrRefCBase2(cb2)!=2, "InputCPtrRefCBase2(), CBase2 as a parameter failed");
|
||||
check(multiple_inheritance_abstract.InputCPtrRefCBase1(b1)!=103, "InputCPtrRefCBase1(), Bottom1 as a parameter failed");
|
||||
check(multiple_inheritance_abstract.InputCPtrRefCBase1(b2)!=206, "InputCPtrRefCBase1(), Bottom2 as a parameter failed");
|
||||
check(multiple_inheritance_abstract.InputCPtrRefCBase1(b3)!=307, "InputCPtrRefCBase1(), Bottom3 as a parameter failed");
|
||||
check(multiple_inheritance_abstract.InputCPtrRefCBase2(b3)!=308, "InputCPtrRefCBase2(), Bottom3 as a parameter failed");
|
||||
check(multiple_inheritance_abstract.InputCPtrRefCBase2(b1)!=104, "InputCPtrRefCBase2(), Bottom1 as a parameter failed");
|
||||
|
||||
//Derived classes as parameters
|
||||
check(multiple_inheritance_abstract.InputValDerived1(d1)!=3+4, "InputValDerived1() failed");
|
||||
check(multiple_inheritance_abstract.InputValDerived2(d2)!=6+5, "InputValDerived2() failed");
|
||||
check(multiple_inheritance_abstract.InputValDerived3(d3)!=7+8+9, "InputValDerived3() failed");
|
||||
|
||||
check(multiple_inheritance_abstract.InputRefDerived1(d1)!=3+4, "InputRefDerived1() failed");
|
||||
check(multiple_inheritance_abstract.InputRefDerived2(d2)!=6+5, "InputRefDerived2() failed");
|
||||
check(multiple_inheritance_abstract.InputRefDerived3(d3)!=7+8+9, "InputRefDerived3() failed");
|
||||
|
||||
check(multiple_inheritance_abstract.InputPtrDerived1(d1)!=3+4, "InputPtrDerived1() failed");
|
||||
check(multiple_inheritance_abstract.InputPtrDerived2(d2)!=6+5, "InputPtrDerived2() failed");
|
||||
check(multiple_inheritance_abstract.InputPtrDerived3(d3)!=7+8+9, "InputPtrDerived3() failed");
|
||||
|
||||
check(multiple_inheritance_abstract.InputCPtrRefDerived1(d1)!=3+4, "InputCPtrRefDerived1() failed");
|
||||
check(multiple_inheritance_abstract.InputCPtrRefDerived2(d2)!=6+5, "InputCPtrRefDerived2() failed");
|
||||
check(multiple_inheritance_abstract.InputCPtrRefDerived3(d3)!=7+8+9, "InputCPtrRefDerived3() failed");
|
||||
|
||||
//Bottom classes as Derived parameters
|
||||
check(multiple_inheritance_abstract.InputValDerived1(b1)!=3+4, "InputValDerived1() failed");
|
||||
check(multiple_inheritance_abstract.InputValDerived2(b2)!=6+5, "InputValDerived2() failed");
|
||||
check(multiple_inheritance_abstract.InputValDerived3(b3)!=7+8+9, "InputValDerived3() failed");
|
||||
|
||||
check(multiple_inheritance_abstract.InputRefDerived1(b1)!=103+104, "InputRefDerived1() failed");
|
||||
check(multiple_inheritance_abstract.InputRefDerived2(b2)!=206+205, "InputRefDerived2() failed");
|
||||
check(multiple_inheritance_abstract.InputRefDerived3(b3)!=307+308+309, "InputRefDerived3() failed");
|
||||
|
||||
check(multiple_inheritance_abstract.InputPtrDerived1(b1)!=103+104, "InputPtrDerived1() failed");
|
||||
check(multiple_inheritance_abstract.InputPtrDerived2(b2)!=206+205, "InputPtrDerived2() failed");
|
||||
check(multiple_inheritance_abstract.InputPtrDerived3(b3)!=307+308+309, "InputPtrDerived3() failed");
|
||||
|
||||
check(multiple_inheritance_abstract.InputCPtrRefDerived1(b1)!=103+104, "InputCPtrRefDerived1() failed");
|
||||
check(multiple_inheritance_abstract.InputCPtrRefDerived2(b2)!=206+205, "InputCPtrRefDerived2() failed");
|
||||
check(multiple_inheritance_abstract.InputCPtrRefDerived3(b3)!=307+308+309, "InputCPtrRefDerived3() failed");
|
||||
|
||||
//Bottom classes as Bottom parameters
|
||||
check(multiple_inheritance_abstract.InputValBottom1(b1)!=103+104, "InputValBottom1() failed");
|
||||
check(multiple_inheritance_abstract.InputValBottom2(b2)!=206+205, "InputValBottom2() failed");
|
||||
check(multiple_inheritance_abstract.InputValBottom3(b3)!=307+308+309, "InputValBottom3() failed");
|
||||
|
||||
check(multiple_inheritance_abstract.InputRefBottom1(b1)!=103+104, "InputRefBottom1() failed");
|
||||
check(multiple_inheritance_abstract.InputRefBottom2(b2)!=206+205, "InputRefBottom2() failed");
|
||||
check(multiple_inheritance_abstract.InputRefBottom3(b3)!=307+308+309, "InputRefBottom3() failed");
|
||||
|
||||
check(multiple_inheritance_abstract.InputPtrBottom1(b1)!=103+104, "InputPtrBottom1() failed");
|
||||
check(multiple_inheritance_abstract.InputPtrBottom2(b2)!=206+205, "InputPtrBottom2() failed");
|
||||
check(multiple_inheritance_abstract.InputPtrBottom3(b3)!=307+308+309, "InputPtrBottom3() failed");
|
||||
|
||||
check(multiple_inheritance_abstract.InputCPtrRefBottom1(b1)!=103+104, "InputCPtrRefBottom1() failed");
|
||||
check(multiple_inheritance_abstract.InputCPtrRefBottom2(b2)!=206+205, "InputCPtrRefBottom2() failed");
|
||||
check(multiple_inheritance_abstract.InputCPtrRefBottom3(b3)!=307+308+309, "InputCPtrRefBottom3() failed");
|
||||
// Return pointers
|
||||
check(multiple_inheritance_abstract.MakePtrDerived1_CBase1().cbase1y()!=3, "MakePtrDerived1_CBase1 failed");
|
||||
check(multiple_inheritance_abstract.MakePtrDerived1_CBase2().cbase2()!=4, "MakePtrDerived1_CBase2 failed");
|
||||
check(multiple_inheritance_abstract.MakePtrDerived2_CBase1().cbase1y()!=6, "MakePtrDerived2_CBase1 failed");
|
||||
check(multiple_inheritance_abstract.MakePtrDerived2_ABase1().abase1()!=5, "MakePtrDerived2_ABase1 failed");
|
||||
check(multiple_inheritance_abstract.MakePtrDerived3_ABase1().abase1()!=9, "MakePtrDerived3_ABase1 failed");
|
||||
check(multiple_inheritance_abstract.MakePtrDerived3_CBase1().cbase1y()!=7, "MakePtrDerived3_CBase1 failed");
|
||||
check(multiple_inheritance_abstract.MakePtrDerived3_CBase2().cbase2()!=8, "MakePtrDerived3_CBase2 failed");
|
||||
|
||||
// Return references
|
||||
check(multiple_inheritance_abstract.MakeRefDerived1_CBase1().cbase1y()!=3, "MakeRefDerived1_CBase1 failed");
|
||||
check(multiple_inheritance_abstract.MakeRefDerived1_CBase2().cbase2()!=4, "MakeRefDerived1_CBase2 failed");
|
||||
check(multiple_inheritance_abstract.MakeRefDerived2_CBase1().cbase1y()!=6, "MakeRefDerived2_CBase1 failed");
|
||||
check(multiple_inheritance_abstract.MakeRefDerived2_ABase1().abase1()!=5, "MakeRefDerived2_ABase1 failed");
|
||||
check(multiple_inheritance_abstract.MakeRefDerived3_ABase1().abase1()!=9, "MakeRefDerived3_ABase1 failed");
|
||||
check(multiple_inheritance_abstract.MakeRefDerived3_CBase1().cbase1y()!=7, "MakeRefDerived3_CBase1 failed");
|
||||
check(multiple_inheritance_abstract.MakeRefDerived3_CBase2().cbase2()!=8, "MakeRefDerived3_CBase2 failed");
|
||||
|
||||
// Return by value (sliced objects)
|
||||
check(multiple_inheritance_abstract.MakeValDerived1_CBase1().cbase1y()!=1, "MakeValDerived1_CBase1 failed");
|
||||
check(multiple_inheritance_abstract.MakeValDerived1_CBase2().cbase2()!=2, "MakeValDerived1_CBase2 failed");
|
||||
check(multiple_inheritance_abstract.MakeValDerived2_CBase1().cbase1y()!=1, "MakeValDerived2_CBase1 failed");
|
||||
check(multiple_inheritance_abstract.MakeValDerived3_CBase1().cbase1y()!=1, "MakeValDerived3_CBase1 failed");
|
||||
check(multiple_inheritance_abstract.MakeValDerived3_CBase2().cbase2()!=2, "MakeValDerived3_CBase2 failed");
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,78 @@
|
|||
import multiple_inheritance_interfaces.*;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class multiple_inheritance_interfaces_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("multiple_inheritance_interfaces");
|
||||
} 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);
|
||||
}
|
||||
}
|
||||
|
||||
private static void checkBaseAndInterfaces(Class cls, boolean interfaceExpected, String base, String[] interfaces) {
|
||||
String[] expectedInterfaces = new String[interfaces.length];
|
||||
for (int i=0; i<interfaces.length; ++i)
|
||||
expectedInterfaces[i] = "interface multiple_inheritance_interfaces." + interfaces[i];
|
||||
Class[] actualInterfaces = cls.getInterfaces();
|
||||
String expectedInterfacesString = Arrays.toString(expectedInterfaces);
|
||||
String actualInterfacesString = Arrays.toString(actualInterfaces);
|
||||
if (!expectedInterfacesString.equals(actualInterfacesString))
|
||||
throw new RuntimeException("Expected interfaces for " + cls.getName() + ": \n" + expectedInterfacesString + "\n" + "Actual interfaces: \n" + actualInterfacesString);
|
||||
|
||||
String expectedBaseString = null;
|
||||
if (interfaceExpected) {
|
||||
// expecting an interface
|
||||
if (!cls.isInterface())
|
||||
throw new RuntimeException(cls.getName() + " should be an interface but is not");
|
||||
expectedBaseString = base.isEmpty() ? "" : "multiple_inheritance_interfaces." + base;
|
||||
} else {
|
||||
// expecting a class
|
||||
if (cls.isInterface())
|
||||
throw new RuntimeException(cls.getName() + " is an interface but it should not be");
|
||||
expectedBaseString = base.isEmpty() ? "java.lang.Object" : "multiple_inheritance_interfaces." + base;
|
||||
}
|
||||
|
||||
String actualBaseString = cls.getSuperclass() == null ? "" : cls.getSuperclass().getName();
|
||||
if (!expectedBaseString.equals(actualBaseString))
|
||||
throw new RuntimeException("Expected base for " + cls.getName() + ": [" + expectedBaseString + "]" + " Actual base: [" + actualBaseString + "]");
|
||||
}
|
||||
|
||||
public static void main(String argv[]) {
|
||||
checkBaseAndInterfaces(IA.class, true, "", new String[] {});
|
||||
checkBaseAndInterfaces(IB.class, true, "", new String[] {});
|
||||
checkBaseAndInterfaces(IC.class, true, "", new String[] {"IA", "IB"});
|
||||
checkBaseAndInterfaces(A.class, false, "", new String[] {"IA"});
|
||||
checkBaseAndInterfaces(B.class, false, "", new String[] {"IB"});
|
||||
checkBaseAndInterfaces(C.class, false, "", new String[] {"IA", "IB", "IC"});
|
||||
checkBaseAndInterfaces(D.class, false, "", new String[] {"IA", "IB", "IC"});
|
||||
checkBaseAndInterfaces(E.class, false, "D", new String[] {});
|
||||
|
||||
checkBaseAndInterfaces(IJ.class, true, "", new String[] {});
|
||||
checkBaseAndInterfaces(IK.class, true, "", new String[] {"IJ"});
|
||||
checkBaseAndInterfaces(IL.class, true, "", new String[] {"IK"});
|
||||
checkBaseAndInterfaces(J.class, false, "", new String[] {"IJ"});
|
||||
checkBaseAndInterfaces(K.class, false, "", new String[] {"IJ", "IK"});
|
||||
checkBaseAndInterfaces(L.class, false, "", new String[] {"IJ", "IK", "IL"});
|
||||
checkBaseAndInterfaces(M.class, false, "", new String[] {"IJ", "IK", "IL"});
|
||||
|
||||
checkBaseAndInterfaces(P.class, false, "", new String[] {});
|
||||
checkBaseAndInterfaces(IQ.class, true, "", new String[] {});
|
||||
checkBaseAndInterfaces(Q.class, false, "", new String[] {"IQ"});
|
||||
checkBaseAndInterfaces(R.class, false, "P", new String[] {"IQ"});
|
||||
checkBaseAndInterfaces(S.class, false, "P", new String[] {"IQ"});
|
||||
checkBaseAndInterfaces(T.class, false, "", new String[] {"IQ"});
|
||||
checkBaseAndInterfaces(U.class, false, "R", new String[] {});
|
||||
checkBaseAndInterfaces(V.class, false, "S", new String[] {});
|
||||
checkBaseAndInterfaces(W.class, false, "T", new String[] {});
|
||||
|
||||
// overloaded methods check
|
||||
D d = new D();
|
||||
d.ia();
|
||||
d.ia(10);
|
||||
d.ia("bye");
|
||||
d.ia("bye", false);
|
||||
}
|
||||
}
|
||||
255
Examples/test-suite/java/multiple_inheritance_nspace_runme.java
Normal file
255
Examples/test-suite/java/multiple_inheritance_nspace_runme.java
Normal file
|
|
@ -0,0 +1,255 @@
|
|||
import multiple_inheritance_nspacePackage.multiple_inheritance_nspace;
|
||||
import multiple_inheritance_nspacePackage.multiple_inheritance_nspaceJNI;
|
||||
import multiple_inheritance_nspacePackage.Space.*;
|
||||
|
||||
public class multiple_inheritance_nspace_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("multiple_inheritance_nspace");
|
||||
} 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);
|
||||
}
|
||||
}
|
||||
|
||||
//Test base class as a parameter in java
|
||||
int jcbase1b(CBase1SwigInterface cb1){
|
||||
return cb1.cbase1y();
|
||||
}
|
||||
int jabase1(ABase1SwigInterface ab1){
|
||||
return ab1.abase1();
|
||||
}
|
||||
int jcbase2(CBase2SwigInterface cb2){
|
||||
return cb2.cbase2();
|
||||
}
|
||||
|
||||
public static void check(boolean fail, String msg) {
|
||||
if (fail)
|
||||
throw new RuntimeException(msg);
|
||||
}
|
||||
|
||||
public static void main(String argv[]) {
|
||||
//Test Derived1
|
||||
Derived1 d1=new Derived1();
|
||||
check(d1.cbase1y()!=3, "Derived1::cbase1y() failed");
|
||||
check(d1.cbase2()!=4, "Derived1::cbase2() failed");
|
||||
|
||||
//Test Derived2
|
||||
Derived2 d2=new Derived2();
|
||||
check(d2.cbase1y()!=6, "Derived2::cbase1y() failed");
|
||||
check(d2.abase1()!=5, "Derived2::abase1() failed");
|
||||
|
||||
//Test Derived3
|
||||
Derived3 d3=new Derived3();
|
||||
check(d3.cbase1y()!=7, "Derived3::cbase1y() failed");
|
||||
check(d3.cbase2()!=8, "Derived3::cbase2() failed");
|
||||
check(d3.abase1()!=9, "Derived3::abase1() failed");
|
||||
|
||||
//Test Bottom1
|
||||
Bottom1 b1=new Bottom1();
|
||||
check(b1.cbase1y()!=103, "Bottom1::cbase1y() failed");
|
||||
check(b1.cbase2()!=104, "Bottom1::cbase2() failed");
|
||||
|
||||
//Test Bottom2
|
||||
Bottom2 b2=new Bottom2();
|
||||
check(b2.cbase1y()!=206, "Bottom2::cbase1y() failed");
|
||||
check(b2.abase1()!=205, "Bottom2::abase1() failed");
|
||||
|
||||
//Test Bottom3
|
||||
Bottom3 b3=new Bottom3();
|
||||
check(b3.cbase1y()!=307, "Bottom3::cbase1y() failed");
|
||||
check(b3.cbase2()!=308, "Bottom3::cbase2() failed");
|
||||
check(b3.abase1()!=309, "Bottom3::abase1() failed");
|
||||
|
||||
//Test interfaces from c++ classes
|
||||
CBase1SwigInterface cb1=new CBase1();
|
||||
CBase2SwigInterface cb2=new CBase2();
|
||||
check(cb1.cbase1y()!=1, "CBase1::cbase1y() failed");
|
||||
check(cb2.cbase2()!=2, "CBase2::cbase2() failed");
|
||||
|
||||
//Test nspace class as return value
|
||||
ABase1SwigInterface ab1=d3.cloneit();
|
||||
check(ab1.abase1()!=9, "Derived3::abase1() through ABase1 failed");
|
||||
|
||||
//Test concrete base class as return value
|
||||
CBase1SwigInterface cb6=d2.cloneit();
|
||||
CBase2SwigInterface cb7=d1.cloneit();
|
||||
check(cb6.cbase1y()!=6, "Derived2::cbase1y() through CBase1 failed");
|
||||
check(cb7.cbase2()!=4, "Derived1:cbase2() through ABase1 failed");
|
||||
|
||||
//Test multi inheritance
|
||||
CBase1SwigInterface cb3=new Derived1();
|
||||
CBase1SwigInterface cb4=new Derived3();
|
||||
CBase2SwigInterface cb5=new Derived3();
|
||||
ABase1SwigInterface ab6=new Derived2();
|
||||
check(cb3.cbase1y()!=3, "Derived1::cbase1y() through CBase1 failed");
|
||||
check(cb4.cbase1y()!=7, "Derived3::cbase1y() through CBase1 failed");
|
||||
check(cb5.cbase2()!=8, "Derived3::cbase2() through CBase2 failed");
|
||||
check(ab6.abase1()!=5, "Derived2::abase1() through ABase1 failed");
|
||||
|
||||
//Test base classes as parameter in java
|
||||
multiple_inheritance_nspace_runme mhar=new multiple_inheritance_nspace_runme();
|
||||
check(mhar.jcbase1b(d1)!=3, "jcbase1b() through Derived1 as parameter failed");
|
||||
check(mhar.jcbase1b(d2)!=6, "jcbase1b() through Derived2 as parameter failed");
|
||||
check(mhar.jcbase1b(d3)!=7, "jcbase1b() through Derived3 as parameter failed");
|
||||
check(mhar.jcbase2(d1)!=4, "jcbase2() through Derived1 as parameter failed");
|
||||
check(mhar.jcbase2(d3)!=8, "jcbase2() through Derived3 as parameter failed");
|
||||
check(mhar.jabase1(d2)!=5, "jabase1() through Derived2 as parameter failed");
|
||||
check(mhar.jabase1(d3)!=9, "jabase1() through Derived3 as parameter failed");
|
||||
|
||||
//Value parameters
|
||||
//Test CBase1 CBase2 as parameters (note slicing for Derived and Bottom classes)
|
||||
check(multiple_inheritance_nspace.InputValCBase1(d1)!=1, "InputValCBase1(), Derived1 as a parameter failed");
|
||||
check(multiple_inheritance_nspace.InputValCBase1(d2)!=1, "InputValCBase1(), Derived2 as a parameter failed");
|
||||
check(multiple_inheritance_nspace.InputValCBase1(d3)!=1, "InputValCBase1(), Derived3 as a parameter failed");
|
||||
check(multiple_inheritance_nspace.InputValCBase2(d3)!=2, "InputValCBase2(), Derived3 as a parameter failed");
|
||||
check(multiple_inheritance_nspace.InputValCBase2(d1)!=2, "InputValCBase2(), Derived1 as a parameter failed");
|
||||
check(multiple_inheritance_nspace.InputValCBase1(cb1)!=1, "InputValCBase1(), CBase1 as a parameter failed");
|
||||
check(multiple_inheritance_nspace.InputValCBase2(cb2)!=2, "InputValCBase2(), CBase2 as a parameter failed");
|
||||
check(multiple_inheritance_nspace.InputValCBase1(b1)!=1, "InputValCBase1(), Bottom1 as a parameter failed");
|
||||
check(multiple_inheritance_nspace.InputValCBase1(b2)!=1, "InputValCBase1(), Bottom2 as a parameter failed");
|
||||
check(multiple_inheritance_nspace.InputValCBase1(b3)!=1, "InputValCBase1(), Bottom3 as a parameter failed");
|
||||
check(multiple_inheritance_nspace.InputValCBase2(b3)!=2, "InputValCBase2(), Bottom3 as a parameter failed");
|
||||
check(multiple_inheritance_nspace.InputValCBase2(b1)!=2, "InputValCBase2(), Bottom1 as a parameter failed");
|
||||
|
||||
//Pointer parameters
|
||||
//Test ABase1 as a parameter
|
||||
check(multiple_inheritance_nspace.InputPtrABase1(d2)!=5, "InputPtrABase1() through Derived2 as a parameter failed");
|
||||
check(multiple_inheritance_nspace.InputPtrABase1(d3)!=9, "InputPtrABase1() through Derived3 as a parameter failed");
|
||||
check(multiple_inheritance_nspace.InputPtrABase1(b2)!=205, "InputPtrABase1() through Bottom2 as a parameter failed");
|
||||
check(multiple_inheritance_nspace.InputPtrABase1(b3)!=309, "InputPtrABase1() through Bottom3 as a parameter failed");
|
||||
|
||||
//Test CBase1 CBase2 as parameters
|
||||
check(multiple_inheritance_nspace.InputPtrCBase1(d1)!=3, "InputPtrCBase1(), Derived1 as a parameter failed");
|
||||
check(multiple_inheritance_nspace.InputPtrCBase1(d2)!=6, "InputPtrCBase1(), Derived2 as a parameter failed");
|
||||
check(multiple_inheritance_nspace.InputPtrCBase1(d3)!=7, "InputPtrCBase1(), Derived3 as a parameter failed");
|
||||
check(multiple_inheritance_nspace.InputPtrCBase2(d3)!=8, "InputPtrCBase2(), Derived3 as a parameter failed");
|
||||
check(multiple_inheritance_nspace.InputPtrCBase2(d1)!=4, "InputPtrCBase2(), Derived1 as a parameter failed");
|
||||
check(multiple_inheritance_nspace.InputPtrCBase1(cb1)!=1, "InputPtrCBase1(), CBase1 as a parameter failed");
|
||||
check(multiple_inheritance_nspace.InputPtrCBase2(cb2)!=2, "InputPtrCBase2(), CBase2 as a parameter failed");
|
||||
check(multiple_inheritance_nspace.InputPtrCBase1(b1)!=103, "InputPtrCBase1(), Bottom1 as a parameter failed");
|
||||
check(multiple_inheritance_nspace.InputPtrCBase1(b2)!=206, "InputPtrCBase1(), Bottom2 as a parameter failed");
|
||||
check(multiple_inheritance_nspace.InputPtrCBase1(b3)!=307, "InputPtrCBase1(), Bottom3 as a parameter failed");
|
||||
check(multiple_inheritance_nspace.InputPtrCBase2(b3)!=308, "InputPtrCBase2(), Bottom3 as a parameter failed");
|
||||
check(multiple_inheritance_nspace.InputPtrCBase2(b1)!=104, "InputPtrCBase2(), Bottom1 as a parameter failed");
|
||||
|
||||
//Reference parameters
|
||||
//Test ABase1 as a parameter
|
||||
check(multiple_inheritance_nspace.InputRefABase1(d2)!=5, "InputRefABase1() through Derived2 as a parameter failed");
|
||||
check(multiple_inheritance_nspace.InputRefABase1(d3)!=9, "InputRefABase1() through Derived3 as a parameter failed");
|
||||
check(multiple_inheritance_nspace.InputRefABase1(b2)!=205, "InputRefABase1() through Bottom2 as a parameter failed");
|
||||
check(multiple_inheritance_nspace.InputRefABase1(b3)!=309, "InputRefABase1() through Bottom3 as a parameter failed");
|
||||
|
||||
//Test CBase1 CBase2 as parameters
|
||||
check(multiple_inheritance_nspace.InputRefCBase1(d1)!=3, "InputRefCBase1(), Derived1 as a parameter failed");
|
||||
check(multiple_inheritance_nspace.InputRefCBase1(d2)!=6, "InputRefCBase1(), Derived2 as a parameter failed");
|
||||
check(multiple_inheritance_nspace.InputRefCBase1(d3)!=7, "InputRefCBase1(), Derived3 as a parameter failed");
|
||||
check(multiple_inheritance_nspace.InputRefCBase2(d3)!=8, "InputRefCBase2(), Derived3 as a parameter failed");
|
||||
check(multiple_inheritance_nspace.InputRefCBase2(d1)!=4, "InputRefCBase2(), Derived1 as a parameter failed");
|
||||
check(multiple_inheritance_nspace.InputRefCBase1(cb1)!=1, "InputRefCBase1(), CBase1 as a parameter failed");
|
||||
check(multiple_inheritance_nspace.InputRefCBase2(cb2)!=2, "InputRefCBase2(), CBase2 as a parameter failed");
|
||||
check(multiple_inheritance_nspace.InputRefCBase1(b1)!=103, "InputRefCBase1(), Bottom1 as a parameter failed");
|
||||
check(multiple_inheritance_nspace.InputRefCBase1(b2)!=206, "InputRefCBase1(), Bottom2 as a parameter failed");
|
||||
check(multiple_inheritance_nspace.InputRefCBase1(b3)!=307, "InputRefCBase1(), Bottom3 as a parameter failed");
|
||||
check(multiple_inheritance_nspace.InputRefCBase2(b3)!=308, "InputRefCBase2(), Bottom3 as a parameter failed");
|
||||
check(multiple_inheritance_nspace.InputRefCBase2(b1)!=104, "InputRefCBase2(), Bottom1 as a parameter failed");
|
||||
|
||||
//Const reference pointer parameters
|
||||
//Test ABase1 as a parameter
|
||||
check(multiple_inheritance_nspace.InputCPtrRefABase1(d2)!=5, "InputCPtrRefABase1() through Derived2 as a parameter failed");
|
||||
check(multiple_inheritance_nspace.InputCPtrRefABase1(d3)!=9, "InputCPtrRefABase1() through Derived3 as a parameter failed");
|
||||
check(multiple_inheritance_nspace.InputCPtrRefABase1(b2)!=205, "InputCPtrRefABase1() through Bottom2 as a parameter failed");
|
||||
check(multiple_inheritance_nspace.InputCPtrRefABase1(b3)!=309, "InputCPtrRefABase1() through Bottom3 as a parameter failed");
|
||||
|
||||
//Test CBase1 CBase2 as parameters
|
||||
check(multiple_inheritance_nspace.InputCPtrRefCBase1(d1)!=3, "InputCPtrRefCBase1(), Derived1 as a parameter failed");
|
||||
check(multiple_inheritance_nspace.InputCPtrRefCBase1(d2)!=6, "InputCPtrRefCBase1(), Derived2 as a parameter failed");
|
||||
check(multiple_inheritance_nspace.InputCPtrRefCBase1(d3)!=7, "InputCPtrRefCBase1(), Derived3 as a parameter failed");
|
||||
check(multiple_inheritance_nspace.InputCPtrRefCBase2(d3)!=8, "InputCPtrRefCBase2(), Derived3 as a parameter failed");
|
||||
check(multiple_inheritance_nspace.InputCPtrRefCBase2(d1)!=4, "InputCPtrRefCBase2(), Derived1 as a parameter failed");
|
||||
check(multiple_inheritance_nspace.InputCPtrRefCBase1(cb1)!=1, "InputCPtrRefCBase1(), CBase1 as a parameter failed");
|
||||
check(multiple_inheritance_nspace.InputCPtrRefCBase2(cb2)!=2, "InputCPtrRefCBase2(), CBase2 as a parameter failed");
|
||||
check(multiple_inheritance_nspace.InputCPtrRefCBase1(b1)!=103, "InputCPtrRefCBase1(), Bottom1 as a parameter failed");
|
||||
check(multiple_inheritance_nspace.InputCPtrRefCBase1(b2)!=206, "InputCPtrRefCBase1(), Bottom2 as a parameter failed");
|
||||
check(multiple_inheritance_nspace.InputCPtrRefCBase1(b3)!=307, "InputCPtrRefCBase1(), Bottom3 as a parameter failed");
|
||||
check(multiple_inheritance_nspace.InputCPtrRefCBase2(b3)!=308, "InputCPtrRefCBase2(), Bottom3 as a parameter failed");
|
||||
check(multiple_inheritance_nspace.InputCPtrRefCBase2(b1)!=104, "InputCPtrRefCBase2(), Bottom1 as a parameter failed");
|
||||
|
||||
//Derived classes as parameters
|
||||
check(multiple_inheritance_nspace.InputValDerived1(d1)!=3+4, "InputValDerived1() failed");
|
||||
check(multiple_inheritance_nspace.InputValDerived2(d2)!=6+5, "InputValDerived2() failed");
|
||||
check(multiple_inheritance_nspace.InputValDerived3(d3)!=7+8+9, "InputValDerived3() failed");
|
||||
|
||||
check(multiple_inheritance_nspace.InputRefDerived1(d1)!=3+4, "InputRefDerived1() failed");
|
||||
check(multiple_inheritance_nspace.InputRefDerived2(d2)!=6+5, "InputRefDerived2() failed");
|
||||
check(multiple_inheritance_nspace.InputRefDerived3(d3)!=7+8+9, "InputRefDerived3() failed");
|
||||
|
||||
check(multiple_inheritance_nspace.InputPtrDerived1(d1)!=3+4, "InputPtrDerived1() failed");
|
||||
check(multiple_inheritance_nspace.InputPtrDerived2(d2)!=6+5, "InputPtrDerived2() failed");
|
||||
check(multiple_inheritance_nspace.InputPtrDerived3(d3)!=7+8+9, "InputPtrDerived3() failed");
|
||||
|
||||
check(multiple_inheritance_nspace.InputCPtrRefDerived1(d1)!=3+4, "InputCPtrRefDerived1() failed");
|
||||
check(multiple_inheritance_nspace.InputCPtrRefDerived2(d2)!=6+5, "InputCPtrRefDerived2() failed");
|
||||
check(multiple_inheritance_nspace.InputCPtrRefDerived3(d3)!=7+8+9, "InputCPtrRefDerived3() failed");
|
||||
|
||||
//Bottom classes as Derived parameters
|
||||
check(multiple_inheritance_nspace.InputValDerived1(b1)!=3+4, "InputValDerived1() failed");
|
||||
check(multiple_inheritance_nspace.InputValDerived2(b2)!=6+5, "InputValDerived2() failed");
|
||||
check(multiple_inheritance_nspace.InputValDerived3(b3)!=7+8+9, "InputValDerived3() failed");
|
||||
|
||||
check(multiple_inheritance_nspace.InputRefDerived1(b1)!=103+104, "InputRefDerived1() failed");
|
||||
check(multiple_inheritance_nspace.InputRefDerived2(b2)!=206+205, "InputRefDerived2() failed");
|
||||
check(multiple_inheritance_nspace.InputRefDerived3(b3)!=307+308+309, "InputRefDerived3() failed");
|
||||
|
||||
check(multiple_inheritance_nspace.InputPtrDerived1(b1)!=103+104, "InputPtrDerived1() failed");
|
||||
check(multiple_inheritance_nspace.InputPtrDerived2(b2)!=206+205, "InputPtrDerived2() failed");
|
||||
check(multiple_inheritance_nspace.InputPtrDerived3(b3)!=307+308+309, "InputPtrDerived3() failed");
|
||||
|
||||
check(multiple_inheritance_nspace.InputCPtrRefDerived1(b1)!=103+104, "InputCPtrRefDerived1() failed");
|
||||
check(multiple_inheritance_nspace.InputCPtrRefDerived2(b2)!=206+205, "InputCPtrRefDerived2() failed");
|
||||
check(multiple_inheritance_nspace.InputCPtrRefDerived3(b3)!=307+308+309, "InputCPtrRefDerived3() failed");
|
||||
|
||||
//Bottom classes as Bottom parameters
|
||||
check(multiple_inheritance_nspace.InputValBottom1(b1)!=103+104, "InputValBottom1() failed");
|
||||
check(multiple_inheritance_nspace.InputValBottom2(b2)!=206+205, "InputValBottom2() failed");
|
||||
check(multiple_inheritance_nspace.InputValBottom3(b3)!=307+308+309, "InputValBottom3() failed");
|
||||
|
||||
check(multiple_inheritance_nspace.InputRefBottom1(b1)!=103+104, "InputRefBottom1() failed");
|
||||
check(multiple_inheritance_nspace.InputRefBottom2(b2)!=206+205, "InputRefBottom2() failed");
|
||||
check(multiple_inheritance_nspace.InputRefBottom3(b3)!=307+308+309, "InputRefBottom3() failed");
|
||||
|
||||
check(multiple_inheritance_nspace.InputPtrBottom1(b1)!=103+104, "InputPtrBottom1() failed");
|
||||
check(multiple_inheritance_nspace.InputPtrBottom2(b2)!=206+205, "InputPtrBottom2() failed");
|
||||
check(multiple_inheritance_nspace.InputPtrBottom3(b3)!=307+308+309, "InputPtrBottom3() failed");
|
||||
|
||||
check(multiple_inheritance_nspace.InputCPtrRefBottom1(b1)!=103+104, "InputCPtrRefBottom1() failed");
|
||||
check(multiple_inheritance_nspace.InputCPtrRefBottom2(b2)!=206+205, "InputCPtrRefBottom2() failed");
|
||||
check(multiple_inheritance_nspace.InputCPtrRefBottom3(b3)!=307+308+309, "InputCPtrRefBottom3() failed");
|
||||
// Return pointers
|
||||
check(multiple_inheritance_nspace.MakePtrDerived1_CBase1().cbase1y()!=3, "MakePtrDerived1_CBase1 failed");
|
||||
check(multiple_inheritance_nspace.MakePtrDerived1_CBase2().cbase2()!=4, "MakePtrDerived1_CBase2 failed");
|
||||
check(multiple_inheritance_nspace.MakePtrDerived2_CBase1().cbase1y()!=6, "MakePtrDerived2_CBase1 failed");
|
||||
check(multiple_inheritance_nspace.MakePtrDerived2_ABase1().abase1()!=5, "MakePtrDerived2_ABase1 failed");
|
||||
check(multiple_inheritance_nspace.MakePtrDerived3_ABase1().abase1()!=9, "MakePtrDerived3_ABase1 failed");
|
||||
check(multiple_inheritance_nspace.MakePtrDerived3_CBase1().cbase1y()!=7, "MakePtrDerived3_CBase1 failed");
|
||||
check(multiple_inheritance_nspace.MakePtrDerived3_CBase2().cbase2()!=8, "MakePtrDerived3_CBase2 failed");
|
||||
|
||||
// Return references
|
||||
check(multiple_inheritance_nspace.MakeRefDerived1_CBase1().cbase1y()!=3, "MakeRefDerived1_CBase1 failed");
|
||||
check(multiple_inheritance_nspace.MakeRefDerived1_CBase2().cbase2()!=4, "MakeRefDerived1_CBase2 failed");
|
||||
check(multiple_inheritance_nspace.MakeRefDerived2_CBase1().cbase1y()!=6, "MakeRefDerived2_CBase1 failed");
|
||||
check(multiple_inheritance_nspace.MakeRefDerived2_ABase1().abase1()!=5, "MakeRefDerived2_ABase1 failed");
|
||||
check(multiple_inheritance_nspace.MakeRefDerived3_ABase1().abase1()!=9, "MakeRefDerived3_ABase1 failed");
|
||||
check(multiple_inheritance_nspace.MakeRefDerived3_CBase1().cbase1y()!=7, "MakeRefDerived3_CBase1 failed");
|
||||
check(multiple_inheritance_nspace.MakeRefDerived3_CBase2().cbase2()!=8, "MakeRefDerived3_CBase2 failed");
|
||||
|
||||
// Return by value (sliced objects)
|
||||
check(multiple_inheritance_nspace.MakeValDerived1_CBase1().cbase1y()!=1, "MakeValDerived1_CBase1 failed");
|
||||
check(multiple_inheritance_nspace.MakeValDerived1_CBase2().cbase2()!=2, "MakeValDerived1_CBase2 failed");
|
||||
check(multiple_inheritance_nspace.MakeValDerived2_CBase1().cbase1y()!=1, "MakeValDerived2_CBase1 failed");
|
||||
check(multiple_inheritance_nspace.MakeValDerived3_CBase1().cbase1y()!=1, "MakeValDerived3_CBase1 failed");
|
||||
check(multiple_inheritance_nspace.MakeValDerived3_CBase2().cbase2()!=2, "MakeValDerived3_CBase2 failed");
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,337 @@
|
|||
import multiple_inheritance_shared_ptr.*;
|
||||
|
||||
public class multiple_inheritance_shared_ptr_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("multiple_inheritance_shared_ptr");
|
||||
} 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);
|
||||
}
|
||||
}
|
||||
|
||||
//Test base class as a parameter in java
|
||||
int jcbase1b(CBase1 cb1){
|
||||
return cb1.cbase1y();
|
||||
}
|
||||
int jabase1(ABase1 ab1){
|
||||
return ab1.abase1();
|
||||
}
|
||||
int jcbase2(CBase2 cb2){
|
||||
return cb2.cbase2();
|
||||
}
|
||||
|
||||
public static void check(boolean fail, String msg) {
|
||||
if (fail)
|
||||
throw new RuntimeException(msg);
|
||||
}
|
||||
|
||||
public static void main(String argv[]) {
|
||||
//Test Derived1
|
||||
Derived1 d1=new Derived1();
|
||||
check(d1.cbase1y()!=3, "Derived1::cbase1y() failed");
|
||||
check(d1.cbase2()!=4, "Derived1::cbase2() failed");
|
||||
|
||||
//Test Derived2
|
||||
Derived2 d2=new Derived2();
|
||||
check(d2.cbase1y()!=6, "Derived2::cbase1y() failed");
|
||||
check(d2.abase1()!=5, "Derived2::abase1() failed");
|
||||
|
||||
//Test Derived3
|
||||
Derived3 d3=new Derived3();
|
||||
check(d3.cbase1y()!=7, "Derived3::cbase1y() failed");
|
||||
check(d3.cbase2()!=8, "Derived3::cbase2() failed");
|
||||
check(d3.abase1()!=9, "Derived3::abase1() failed");
|
||||
|
||||
//Test Bottom1
|
||||
Bottom1 b1=new Bottom1();
|
||||
check(b1.cbase1y()!=103, "Bottom1::cbase1y() failed");
|
||||
check(b1.cbase2()!=104, "Bottom1::cbase2() failed");
|
||||
|
||||
//Test Bottom2
|
||||
Bottom2 b2=new Bottom2();
|
||||
check(b2.cbase1y()!=206, "Bottom2::cbase1y() failed");
|
||||
check(b2.abase1()!=205, "Bottom2::abase1() failed");
|
||||
|
||||
//Test Bottom3
|
||||
Bottom3 b3=new Bottom3();
|
||||
check(b3.cbase1y()!=307, "Bottom3::cbase1y() failed");
|
||||
check(b3.cbase2()!=308, "Bottom3::cbase2() failed");
|
||||
check(b3.abase1()!=309, "Bottom3::abase1() failed");
|
||||
|
||||
//Test interfaces from c++ classes
|
||||
CBase1 cb1=new CBase1SwigImpl();
|
||||
CBase2 cb2=new CBase2SwigImpl();
|
||||
check(cb1.cbase1y()!=1, "CBase1::cbase1y() failed");
|
||||
check(cb2.cbase2()!=2, "CBase2::cbase2() failed");
|
||||
|
||||
//Test abstract class as return value
|
||||
ABase1 ab1=d3.cloneit();
|
||||
check(ab1.abase1()!=9, "Derived3::abase1() through ABase1 failed");
|
||||
|
||||
//Test concrete base class as return value
|
||||
CBase1 cb6=d2.cloneit();
|
||||
CBase2 cb7=d1.cloneit();
|
||||
check(cb6.cbase1y()!=6, "Derived2::cbase1y() through CBase1 failed");
|
||||
check(cb7.cbase2()!=4, "Derived1:cbase2() through ABase1 failed");
|
||||
|
||||
//Test multi inheritance
|
||||
CBase1 cb3=new Derived1();
|
||||
CBase1 cb4=new Derived3();
|
||||
CBase2 cb5=new Derived3();
|
||||
ABase1 ab6=new Derived2();
|
||||
check(cb3.cbase1y()!=3, "Derived1::cbase1y() through CBase1 failed");
|
||||
check(cb4.cbase1y()!=7, "Derived3::cbase1y() through CBase1 failed");
|
||||
check(cb5.cbase2()!=8, "Derived3::cbase2() through CBase2 failed");
|
||||
check(ab6.abase1()!=5, "Derived2::abase1() through ABase1 failed");
|
||||
|
||||
//Test base classes as parameter in java
|
||||
multiple_inheritance_shared_ptr_runme mhar=new multiple_inheritance_shared_ptr_runme();
|
||||
check(mhar.jcbase1b(d1)!=3, "jcbase1b() through Derived1 as parameter failed");
|
||||
check(mhar.jcbase1b(d2)!=6, "jcbase1b() through Derived2 as parameter failed");
|
||||
check(mhar.jcbase1b(d3)!=7, "jcbase1b() through Derived3 as parameter failed");
|
||||
check(mhar.jcbase2(d1)!=4, "jcbase2() through Derived1 as parameter failed");
|
||||
check(mhar.jcbase2(d3)!=8, "jcbase2() through Derived3 as parameter failed");
|
||||
check(mhar.jabase1(d2)!=5, "jabase1() through Derived2 as parameter failed");
|
||||
check(mhar.jabase1(d3)!=9, "jabase1() through Derived3 as parameter failed");
|
||||
|
||||
//Value parameters
|
||||
//Test CBase1 CBase2 as parameters (note slicing for Derived and Bottom classes)
|
||||
check(multiple_inheritance_shared_ptr.InputValCBase1(d1)!=1, "InputValCBase1(), Derived1 as a parameter failed");
|
||||
check(multiple_inheritance_shared_ptr.InputValCBase1(d2)!=1, "InputValCBase1(), Derived2 as a parameter failed");
|
||||
check(multiple_inheritance_shared_ptr.InputValCBase1(d3)!=1, "InputValCBase1(), Derived3 as a parameter failed");
|
||||
check(multiple_inheritance_shared_ptr.InputValCBase2(d3)!=2, "InputValCBase2(), Derived3 as a parameter failed");
|
||||
check(multiple_inheritance_shared_ptr.InputValCBase2(d1)!=2, "InputValCBase2(), Derived1 as a parameter failed");
|
||||
check(multiple_inheritance_shared_ptr.InputValCBase1(cb1)!=1, "InputValCBase1(), CBase1 as a parameter failed");
|
||||
check(multiple_inheritance_shared_ptr.InputValCBase2(cb2)!=2, "InputValCBase2(), CBase2 as a parameter failed");
|
||||
check(multiple_inheritance_shared_ptr.InputValCBase1(b1)!=1, "InputValCBase1(), Bottom1 as a parameter failed");
|
||||
check(multiple_inheritance_shared_ptr.InputValCBase1(b2)!=1, "InputValCBase1(), Bottom2 as a parameter failed");
|
||||
check(multiple_inheritance_shared_ptr.InputValCBase1(b3)!=1, "InputValCBase1(), Bottom3 as a parameter failed");
|
||||
check(multiple_inheritance_shared_ptr.InputValCBase2(b3)!=2, "InputValCBase2(), Bottom3 as a parameter failed");
|
||||
check(multiple_inheritance_shared_ptr.InputValCBase2(b1)!=2, "InputValCBase2(), Bottom1 as a parameter failed");
|
||||
|
||||
//Pointer parameters
|
||||
//Test ABase1 as a parameter
|
||||
check(multiple_inheritance_shared_ptr.InputPtrABase1(d2)!=5, "InputPtrABase1() through Derived2 as a parameter failed");
|
||||
check(multiple_inheritance_shared_ptr.InputPtrABase1(d3)!=9, "InputPtrABase1() through Derived3 as a parameter failed");
|
||||
check(multiple_inheritance_shared_ptr.InputPtrABase1(b2)!=205, "InputPtrABase1() through Bottom2 as a parameter failed");
|
||||
check(multiple_inheritance_shared_ptr.InputPtrABase1(b3)!=309, "InputPtrABase1() through Bottom3 as a parameter failed");
|
||||
|
||||
//Test CBase1 CBase2 as parameters
|
||||
check(multiple_inheritance_shared_ptr.InputPtrCBase1(d1)!=3, "InputPtrCBase1(), Derived1 as a parameter failed");
|
||||
check(multiple_inheritance_shared_ptr.InputPtrCBase1(d2)!=6, "InputPtrCBase1(), Derived2 as a parameter failed");
|
||||
check(multiple_inheritance_shared_ptr.InputPtrCBase1(d3)!=7, "InputPtrCBase1(), Derived3 as a parameter failed");
|
||||
check(multiple_inheritance_shared_ptr.InputPtrCBase2(d3)!=8, "InputPtrCBase2(), Derived3 as a parameter failed");
|
||||
check(multiple_inheritance_shared_ptr.InputPtrCBase2(d1)!=4, "InputPtrCBase2(), Derived1 as a parameter failed");
|
||||
check(multiple_inheritance_shared_ptr.InputPtrCBase1(cb1)!=1, "InputPtrCBase1(), CBase1 as a parameter failed");
|
||||
check(multiple_inheritance_shared_ptr.InputPtrCBase2(cb2)!=2, "InputPtrCBase2(), CBase2 as a parameter failed");
|
||||
check(multiple_inheritance_shared_ptr.InputPtrCBase1(b1)!=103, "InputPtrCBase1(), Bottom1 as a parameter failed");
|
||||
check(multiple_inheritance_shared_ptr.InputPtrCBase1(b2)!=206, "InputPtrCBase1(), Bottom2 as a parameter failed");
|
||||
check(multiple_inheritance_shared_ptr.InputPtrCBase1(b3)!=307, "InputPtrCBase1(), Bottom3 as a parameter failed");
|
||||
check(multiple_inheritance_shared_ptr.InputPtrCBase2(b3)!=308, "InputPtrCBase2(), Bottom3 as a parameter failed");
|
||||
check(multiple_inheritance_shared_ptr.InputPtrCBase2(b1)!=104, "InputPtrCBase2(), Bottom1 as a parameter failed");
|
||||
|
||||
//Reference parameters
|
||||
//Test ABase1 as a parameter
|
||||
check(multiple_inheritance_shared_ptr.InputRefABase1(d2)!=5, "InputRefABase1() through Derived2 as a parameter failed");
|
||||
check(multiple_inheritance_shared_ptr.InputRefABase1(d3)!=9, "InputRefABase1() through Derived3 as a parameter failed");
|
||||
check(multiple_inheritance_shared_ptr.InputRefABase1(b2)!=205, "InputRefABase1() through Bottom2 as a parameter failed");
|
||||
check(multiple_inheritance_shared_ptr.InputRefABase1(b3)!=309, "InputRefABase1() through Bottom3 as a parameter failed");
|
||||
|
||||
//Test CBase1 CBase2 as parameters
|
||||
check(multiple_inheritance_shared_ptr.InputRefCBase1(d1)!=3, "InputRefCBase1(), Derived1 as a parameter failed");
|
||||
check(multiple_inheritance_shared_ptr.InputRefCBase1(d2)!=6, "InputRefCBase1(), Derived2 as a parameter failed");
|
||||
check(multiple_inheritance_shared_ptr.InputRefCBase1(d3)!=7, "InputRefCBase1(), Derived3 as a parameter failed");
|
||||
check(multiple_inheritance_shared_ptr.InputRefCBase2(d3)!=8, "InputRefCBase2(), Derived3 as a parameter failed");
|
||||
check(multiple_inheritance_shared_ptr.InputRefCBase2(d1)!=4, "InputRefCBase2(), Derived1 as a parameter failed");
|
||||
check(multiple_inheritance_shared_ptr.InputRefCBase1(cb1)!=1, "InputRefCBase1(), CBase1 as a parameter failed");
|
||||
check(multiple_inheritance_shared_ptr.InputRefCBase2(cb2)!=2, "InputRefCBase2(), CBase2 as a parameter failed");
|
||||
check(multiple_inheritance_shared_ptr.InputRefCBase1(b1)!=103, "InputRefCBase1(), Bottom1 as a parameter failed");
|
||||
check(multiple_inheritance_shared_ptr.InputRefCBase1(b2)!=206, "InputRefCBase1(), Bottom2 as a parameter failed");
|
||||
check(multiple_inheritance_shared_ptr.InputRefCBase1(b3)!=307, "InputRefCBase1(), Bottom3 as a parameter failed");
|
||||
check(multiple_inheritance_shared_ptr.InputRefCBase2(b3)!=308, "InputRefCBase2(), Bottom3 as a parameter failed");
|
||||
check(multiple_inheritance_shared_ptr.InputRefCBase2(b1)!=104, "InputRefCBase2(), Bottom1 as a parameter failed");
|
||||
|
||||
//Const reference pointer parameters
|
||||
//Test ABase1 as a parameter
|
||||
check(multiple_inheritance_shared_ptr.InputCPtrRefABase1(d2)!=5, "InputCPtrRefABase1() through Derived2 as a parameter failed");
|
||||
check(multiple_inheritance_shared_ptr.InputCPtrRefABase1(d3)!=9, "InputCPtrRefABase1() through Derived3 as a parameter failed");
|
||||
check(multiple_inheritance_shared_ptr.InputCPtrRefABase1(b2)!=205, "InputCPtrRefABase1() through Bottom2 as a parameter failed");
|
||||
check(multiple_inheritance_shared_ptr.InputCPtrRefABase1(b3)!=309, "InputCPtrRefABase1() through Bottom3 as a parameter failed");
|
||||
|
||||
//Test CBase1 CBase2 as parameters
|
||||
check(multiple_inheritance_shared_ptr.InputCPtrRefCBase1(d1)!=3, "InputCPtrRefCBase1(), Derived1 as a parameter failed");
|
||||
check(multiple_inheritance_shared_ptr.InputCPtrRefCBase1(d2)!=6, "InputCPtrRefCBase1(), Derived2 as a parameter failed");
|
||||
check(multiple_inheritance_shared_ptr.InputCPtrRefCBase1(d3)!=7, "InputCPtrRefCBase1(), Derived3 as a parameter failed");
|
||||
check(multiple_inheritance_shared_ptr.InputCPtrRefCBase2(d3)!=8, "InputCPtrRefCBase2(), Derived3 as a parameter failed");
|
||||
check(multiple_inheritance_shared_ptr.InputCPtrRefCBase2(d1)!=4, "InputCPtrRefCBase2(), Derived1 as a parameter failed");
|
||||
check(multiple_inheritance_shared_ptr.InputCPtrRefCBase1(cb1)!=1, "InputCPtrRefCBase1(), CBase1 as a parameter failed");
|
||||
check(multiple_inheritance_shared_ptr.InputCPtrRefCBase2(cb2)!=2, "InputCPtrRefCBase2(), CBase2 as a parameter failed");
|
||||
check(multiple_inheritance_shared_ptr.InputCPtrRefCBase1(b1)!=103, "InputCPtrRefCBase1(), Bottom1 as a parameter failed");
|
||||
check(multiple_inheritance_shared_ptr.InputCPtrRefCBase1(b2)!=206, "InputCPtrRefCBase1(), Bottom2 as a parameter failed");
|
||||
check(multiple_inheritance_shared_ptr.InputCPtrRefCBase1(b3)!=307, "InputCPtrRefCBase1(), Bottom3 as a parameter failed");
|
||||
check(multiple_inheritance_shared_ptr.InputCPtrRefCBase2(b3)!=308, "InputCPtrRefCBase2(), Bottom3 as a parameter failed");
|
||||
check(multiple_inheritance_shared_ptr.InputCPtrRefCBase2(b1)!=104, "InputCPtrRefCBase2(), Bottom1 as a parameter failed");
|
||||
|
||||
//Shared pointer parameters
|
||||
//Test ABase1 as a parameter
|
||||
check(multiple_inheritance_shared_ptr.InputSharedPtrABase1(d2)!=5, "InputSharedPtrABase1() through Derived2 as a parameter failed");
|
||||
check(multiple_inheritance_shared_ptr.InputSharedPtrABase1(d3)!=9, "InputSharedPtrABase1() through Derived3 as a parameter failed");
|
||||
check(multiple_inheritance_shared_ptr.InputSharedPtrABase1(b2)!=205, "InputSharedPtrABase1() through Bottom2 as a parameter failed");
|
||||
check(multiple_inheritance_shared_ptr.InputSharedPtrABase1(b3)!=309, "InputSharedPtrABase1() through Bottom3 as a parameter failed");
|
||||
|
||||
//Test CBase1 CBase2 as parameters
|
||||
check(multiple_inheritance_shared_ptr.InputSharedPtrCBase1(d1)!=3, "InputSharedPtrCBase1(), Derived1 as a parameter failed");
|
||||
check(multiple_inheritance_shared_ptr.InputSharedPtrCBase1(d2)!=6, "InputSharedPtrCBase1(), Derived2 as a parameter failed");
|
||||
check(multiple_inheritance_shared_ptr.InputSharedPtrCBase1(d3)!=7, "InputSharedPtrCBase1(), Derived3 as a parameter failed");
|
||||
check(multiple_inheritance_shared_ptr.InputSharedPtrCBase2(d3)!=8, "InputSharedPtrCBase2(), Derived3 as a parameter failed");
|
||||
check(multiple_inheritance_shared_ptr.InputSharedPtrCBase2(d1)!=4, "InputSharedPtrCBase2(), Derived1 as a parameter failed");
|
||||
check(multiple_inheritance_shared_ptr.InputSharedPtrCBase1(cb1)!=1, "InputSharedPtrCBase1(), CBase1 as a parameter failed");
|
||||
check(multiple_inheritance_shared_ptr.InputSharedPtrCBase2(cb2)!=2, "InputSharedPtrCBase2(), CBase2 as a parameter failed");
|
||||
check(multiple_inheritance_shared_ptr.InputSharedPtrCBase1(b1)!=103, "InputSharedPtrCBase1(), Bottom1 as a parameter failed");
|
||||
check(multiple_inheritance_shared_ptr.InputSharedPtrCBase1(b2)!=206, "InputSharedPtrCBase1(), Bottom2 as a parameter failed");
|
||||
check(multiple_inheritance_shared_ptr.InputSharedPtrCBase1(b3)!=307, "InputSharedPtrCBase1(), Bottom3 as a parameter failed");
|
||||
check(multiple_inheritance_shared_ptr.InputSharedPtrCBase2(b3)!=308, "InputSharedPtrCBase2(), Bottom3 as a parameter failed");
|
||||
check(multiple_inheritance_shared_ptr.InputSharedPtrCBase2(b1)!=104, "InputSharedPtrCBase2(), Bottom1 as a parameter failed");
|
||||
|
||||
//Shared pointer reference parameters
|
||||
//Test ABase1 as a parameter
|
||||
check(multiple_inheritance_shared_ptr.InputSharedPtrRefABase1(d2)!=5, "InputSharedPtrRefABase1() through Derived2 as a parameter failed");
|
||||
check(multiple_inheritance_shared_ptr.InputSharedPtrRefABase1(d3)!=9, "InputSharedPtrRefABase1() through Derived3 as a parameter failed");
|
||||
check(multiple_inheritance_shared_ptr.InputSharedPtrRefABase1(b2)!=205, "InputSharedPtrRefABase1() through Bottom2 as a parameter failed");
|
||||
check(multiple_inheritance_shared_ptr.InputSharedPtrRefABase1(b3)!=309, "InputSharedPtrRefABase1() through Bottom3 as a parameter failed");
|
||||
|
||||
//Test CBase1 CBase2 as parameters
|
||||
check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase1(d1)!=3, "InputSharedPtrRefCBase1(), Derived1 as a parameter failed");
|
||||
check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase1(d2)!=6, "InputSharedPtrRefCBase1(), Derived2 as a parameter failed");
|
||||
check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase1(d3)!=7, "InputSharedPtrRefCBase1(), Derived3 as a parameter failed");
|
||||
check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase2(d3)!=8, "InputSharedPtrRefCBase2(), Derived3 as a parameter failed");
|
||||
check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase2(d1)!=4, "InputSharedPtrRefCBase2(), Derived1 as a parameter failed");
|
||||
check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase1(cb1)!=1, "InputSharedPtrRefCBase1(), CBase1 as a parameter failed");
|
||||
check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase2(cb2)!=2, "InputSharedPtrRefCBase2(), CBase2 as a parameter failed");
|
||||
check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase1(b1)!=103, "InputSharedPtrRefCBase1(), Bottom1 as a parameter failed");
|
||||
check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase1(b2)!=206, "InputSharedPtrRefCBase1(), Bottom2 as a parameter failed");
|
||||
check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase1(b3)!=307, "InputSharedPtrRefCBase1(), Bottom3 as a parameter failed");
|
||||
check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase2(b3)!=308, "InputSharedPtrRefCBase2(), Bottom3 as a parameter failed");
|
||||
check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase2(b1)!=104, "InputSharedPtrRefCBase2(), Bottom1 as a parameter failed");
|
||||
|
||||
//Derived classes as parameters
|
||||
check(multiple_inheritance_shared_ptr.InputValDerived1(d1)!=3+4, "InputValDerived1() failed");
|
||||
check(multiple_inheritance_shared_ptr.InputValDerived2(d2)!=6+5, "InputValDerived2() failed");
|
||||
check(multiple_inheritance_shared_ptr.InputValDerived3(d3)!=7+8+9, "InputValDerived3() failed");
|
||||
|
||||
check(multiple_inheritance_shared_ptr.InputRefDerived1(d1)!=3+4, "InputRefDerived1() failed");
|
||||
check(multiple_inheritance_shared_ptr.InputRefDerived2(d2)!=6+5, "InputRefDerived2() failed");
|
||||
check(multiple_inheritance_shared_ptr.InputRefDerived3(d3)!=7+8+9, "InputRefDerived3() failed");
|
||||
|
||||
check(multiple_inheritance_shared_ptr.InputPtrDerived1(d1)!=3+4, "InputPtrDerived1() failed");
|
||||
check(multiple_inheritance_shared_ptr.InputPtrDerived2(d2)!=6+5, "InputPtrDerived2() failed");
|
||||
check(multiple_inheritance_shared_ptr.InputPtrDerived3(d3)!=7+8+9, "InputPtrDerived3() failed");
|
||||
|
||||
check(multiple_inheritance_shared_ptr.InputCPtrRefDerived1(d1)!=3+4, "InputCPtrRefDerived1() failed");
|
||||
check(multiple_inheritance_shared_ptr.InputCPtrRefDerived2(d2)!=6+5, "InputCPtrRefDerived2() failed");
|
||||
check(multiple_inheritance_shared_ptr.InputCPtrRefDerived3(d3)!=7+8+9, "InputCPtrRefDerived3() failed");
|
||||
|
||||
check(multiple_inheritance_shared_ptr.InputSharedPtrDerived1(d1)!=3+4, "InputSharedPtrDerived1() failed");
|
||||
check(multiple_inheritance_shared_ptr.InputSharedPtrDerived2(d2)!=6+5, "InputSharedPtrDerived2() failed");
|
||||
check(multiple_inheritance_shared_ptr.InputSharedPtrDerived3(d3)!=7+8+9, "InputSharedPtrDerived3() failed");
|
||||
|
||||
check(multiple_inheritance_shared_ptr.InputSharedPtrRefDerived1(d1)!=3+4, "InputSharedPtrRefDerived1() failed");
|
||||
check(multiple_inheritance_shared_ptr.InputSharedPtrRefDerived2(d2)!=6+5, "InputSharedPtrRefDerived2() failed");
|
||||
check(multiple_inheritance_shared_ptr.InputSharedPtrRefDerived3(d3)!=7+8+9, "InputSharedPtrRefDerived3() failed");
|
||||
|
||||
//Bottom classes as Derived parameters
|
||||
check(multiple_inheritance_shared_ptr.InputValDerived1(b1)!=3+4, "InputValDerived1() failed");
|
||||
check(multiple_inheritance_shared_ptr.InputValDerived2(b2)!=6+5, "InputValDerived2() failed");
|
||||
check(multiple_inheritance_shared_ptr.InputValDerived3(b3)!=7+8+9, "InputValDerived3() failed");
|
||||
|
||||
check(multiple_inheritance_shared_ptr.InputRefDerived1(b1)!=103+104, "InputRefDerived1() failed");
|
||||
check(multiple_inheritance_shared_ptr.InputRefDerived2(b2)!=206+205, "InputRefDerived2() failed");
|
||||
check(multiple_inheritance_shared_ptr.InputRefDerived3(b3)!=307+308+309, "InputRefDerived3() failed");
|
||||
|
||||
check(multiple_inheritance_shared_ptr.InputPtrDerived1(b1)!=103+104, "InputPtrDerived1() failed");
|
||||
check(multiple_inheritance_shared_ptr.InputPtrDerived2(b2)!=206+205, "InputPtrDerived2() failed");
|
||||
check(multiple_inheritance_shared_ptr.InputPtrDerived3(b3)!=307+308+309, "InputPtrDerived3() failed");
|
||||
|
||||
check(multiple_inheritance_shared_ptr.InputCPtrRefDerived1(b1)!=103+104, "InputCPtrRefDerived1() failed");
|
||||
check(multiple_inheritance_shared_ptr.InputCPtrRefDerived2(b2)!=206+205, "InputCPtrRefDerived2() failed");
|
||||
check(multiple_inheritance_shared_ptr.InputCPtrRefDerived3(b3)!=307+308+309, "InputCPtrRefDerived3() failed");
|
||||
|
||||
check(multiple_inheritance_shared_ptr.InputSharedPtrDerived1(b1)!=103+104, "InputSharedPtrDerived1() failed");
|
||||
check(multiple_inheritance_shared_ptr.InputSharedPtrDerived2(b2)!=206+205, "InputSharedPtrDerived2() failed");
|
||||
check(multiple_inheritance_shared_ptr.InputSharedPtrDerived3(b3)!=307+308+309, "InputSharedPtrDerived3() failed");
|
||||
|
||||
check(multiple_inheritance_shared_ptr.InputSharedPtrRefDerived1(b1)!=103+104, "InputSharedPtrRefDerived1() failed");
|
||||
check(multiple_inheritance_shared_ptr.InputSharedPtrRefDerived2(b2)!=206+205, "InputSharedPtrRefDerived2() failed");
|
||||
check(multiple_inheritance_shared_ptr.InputSharedPtrRefDerived3(b3)!=307+308+309, "InputSharedPtrRefDerived3() failed");
|
||||
|
||||
//Bottom classes as Bottom parameters
|
||||
check(multiple_inheritance_shared_ptr.InputValBottom1(b1)!=103+104, "InputValBottom1() failed");
|
||||
check(multiple_inheritance_shared_ptr.InputValBottom2(b2)!=206+205, "InputValBottom2() failed");
|
||||
check(multiple_inheritance_shared_ptr.InputValBottom3(b3)!=307+308+309, "InputValBottom3() failed");
|
||||
|
||||
check(multiple_inheritance_shared_ptr.InputRefBottom1(b1)!=103+104, "InputRefBottom1() failed");
|
||||
check(multiple_inheritance_shared_ptr.InputRefBottom2(b2)!=206+205, "InputRefBottom2() failed");
|
||||
check(multiple_inheritance_shared_ptr.InputRefBottom3(b3)!=307+308+309, "InputRefBottom3() failed");
|
||||
|
||||
check(multiple_inheritance_shared_ptr.InputPtrBottom1(b1)!=103+104, "InputPtrBottom1() failed");
|
||||
check(multiple_inheritance_shared_ptr.InputPtrBottom2(b2)!=206+205, "InputPtrBottom2() failed");
|
||||
check(multiple_inheritance_shared_ptr.InputPtrBottom3(b3)!=307+308+309, "InputPtrBottom3() failed");
|
||||
|
||||
check(multiple_inheritance_shared_ptr.InputCPtrRefBottom1(b1)!=103+104, "InputCPtrRefBottom1() failed");
|
||||
check(multiple_inheritance_shared_ptr.InputCPtrRefBottom2(b2)!=206+205, "InputCPtrRefBottom2() failed");
|
||||
check(multiple_inheritance_shared_ptr.InputCPtrRefBottom3(b3)!=307+308+309, "InputCPtrRefBottom3() failed");
|
||||
|
||||
check(multiple_inheritance_shared_ptr.InputSharedPtrBottom1(b1)!=103+104, "InputSharedPtrBottom1() failed");
|
||||
check(multiple_inheritance_shared_ptr.InputSharedPtrBottom2(b2)!=206+205, "InputSharedPtrBottom2() failed");
|
||||
check(multiple_inheritance_shared_ptr.InputSharedPtrBottom3(b3)!=307+308+309, "InputSharedPtrBottom3() failed");
|
||||
|
||||
check(multiple_inheritance_shared_ptr.InputSharedPtrRefBottom1(b1)!=103+104, "InputSharedPtrRefBottom1() failed");
|
||||
check(multiple_inheritance_shared_ptr.InputSharedPtrRefBottom2(b2)!=206+205, "InputSharedPtrRefBottom2() failed");
|
||||
check(multiple_inheritance_shared_ptr.InputSharedPtrRefBottom3(b3)!=307+308+309, "InputSharedPtrRefBottom3() failed");
|
||||
|
||||
// Return pointers
|
||||
check(multiple_inheritance_shared_ptr.MakePtrDerived1_CBase1().cbase1y()!=3, "MakePtrDerived1_CBase1 failed");
|
||||
check(multiple_inheritance_shared_ptr.MakePtrDerived1_CBase2().cbase2()!=4, "MakePtrDerived1_CBase2 failed");
|
||||
check(multiple_inheritance_shared_ptr.MakePtrDerived2_CBase1().cbase1y()!=6, "MakePtrDerived2_CBase1 failed");
|
||||
check(multiple_inheritance_shared_ptr.MakePtrDerived2_ABase1().abase1()!=5, "MakePtrDerived2_ABase1 failed");
|
||||
check(multiple_inheritance_shared_ptr.MakePtrDerived3_ABase1().abase1()!=9, "MakePtrDerived3_ABase1 failed");
|
||||
check(multiple_inheritance_shared_ptr.MakePtrDerived3_CBase1().cbase1y()!=7, "MakePtrDerived3_CBase1 failed");
|
||||
check(multiple_inheritance_shared_ptr.MakePtrDerived3_CBase2().cbase2()!=8, "MakePtrDerived3_CBase2 failed");
|
||||
|
||||
// Return references
|
||||
check(multiple_inheritance_shared_ptr.MakeRefDerived1_CBase1().cbase1y()!=3, "MakeRefDerived1_CBase1 failed");
|
||||
check(multiple_inheritance_shared_ptr.MakeRefDerived1_CBase2().cbase2()!=4, "MakeRefDerived1_CBase2 failed");
|
||||
check(multiple_inheritance_shared_ptr.MakeRefDerived2_CBase1().cbase1y()!=6, "MakeRefDerived2_CBase1 failed");
|
||||
check(multiple_inheritance_shared_ptr.MakeRefDerived2_ABase1().abase1()!=5, "MakeRefDerived2_ABase1 failed");
|
||||
check(multiple_inheritance_shared_ptr.MakeRefDerived3_ABase1().abase1()!=9, "MakeRefDerived3_ABase1 failed");
|
||||
check(multiple_inheritance_shared_ptr.MakeRefDerived3_CBase1().cbase1y()!=7, "MakeRefDerived3_CBase1 failed");
|
||||
check(multiple_inheritance_shared_ptr.MakeRefDerived3_CBase2().cbase2()!=8, "MakeRefDerived3_CBase2 failed");
|
||||
|
||||
// Return by value (sliced objects)
|
||||
check(multiple_inheritance_shared_ptr.MakeValDerived1_CBase1().cbase1y()!=1, "MakeValDerived1_CBase1 failed");
|
||||
check(multiple_inheritance_shared_ptr.MakeValDerived1_CBase2().cbase2()!=2, "MakeValDerived1_CBase2 failed");
|
||||
check(multiple_inheritance_shared_ptr.MakeValDerived2_CBase1().cbase1y()!=1, "MakeValDerived2_CBase1 failed");
|
||||
check(multiple_inheritance_shared_ptr.MakeValDerived3_CBase1().cbase1y()!=1, "MakeValDerived3_CBase1 failed");
|
||||
check(multiple_inheritance_shared_ptr.MakeValDerived3_CBase2().cbase2()!=2, "MakeValDerived3_CBase2 failed");
|
||||
|
||||
// Return smart pointers
|
||||
check(multiple_inheritance_shared_ptr.MakeSharedPtrDerived1_CBase1().cbase1y()!=3, "MakeSharedPtrDerived1_CBase1 failed");
|
||||
check(multiple_inheritance_shared_ptr.MakeSharedPtrDerived1_CBase2().cbase2()!=4, "MakeSharedPtrDerived1_CBase2 failed");
|
||||
check(multiple_inheritance_shared_ptr.MakeSharedPtrDerived2_CBase1().cbase1y()!=6, "MakeSharedPtrDerived2_CBase1 failed");
|
||||
check(multiple_inheritance_shared_ptr.MakeSharedPtrDerived2_ABase1().abase1()!=5, "MakeSharedPtrDerived2_ABase1 failed");
|
||||
check(multiple_inheritance_shared_ptr.MakeSharedPtrDerived3_ABase1().abase1()!=9, "MakeSharedPtrDerived3_ABase1 failed");
|
||||
check(multiple_inheritance_shared_ptr.MakeSharedPtrDerived3_CBase1().cbase1y()!=7, "MakeSharedPtrDerived3_CBase1 failed");
|
||||
check(multiple_inheritance_shared_ptr.MakeSharedPtrDerived3_CBase2().cbase2()!=8, "MakeSharedPtrDerived3_CBase2 failed");
|
||||
|
||||
// Return smart pointers references
|
||||
check(multiple_inheritance_shared_ptr.MakeSharedPtrRefDerived1_CBase1().cbase1y()!=3, "MakeSharedPtrRefDerived1_CBase1 failed");
|
||||
check(multiple_inheritance_shared_ptr.MakeSharedPtrRefDerived1_CBase2().cbase2()!=4, "MakeSharedPtrRefDerived1_CBase2 failed");
|
||||
check(multiple_inheritance_shared_ptr.MakeSharedPtrRefDerived2_CBase1().cbase1y()!=6, "MakeSharedPtrRefDerived2_CBase1 failed");
|
||||
check(multiple_inheritance_shared_ptr.MakeSharedPtrRefDerived2_ABase1().abase1()!=5, "MakeSharedPtrRefDerived2_ABase1 failed");
|
||||
check(multiple_inheritance_shared_ptr.MakeSharedPtrRefDerived3_ABase1().abase1()!=9, "MakeSharedPtrRefDerived3_ABase1 failed");
|
||||
check(multiple_inheritance_shared_ptr.MakeSharedPtrRefDerived3_CBase1().cbase1y()!=7, "MakeSharedPtrRefDerived3_CBase1 failed");
|
||||
check(multiple_inheritance_shared_ptr.MakeSharedPtrRefDerived3_CBase2().cbase2()!=8, "MakeSharedPtrRefDerived3_CBase2 failed");
|
||||
}
|
||||
}
|
||||
90
Examples/test-suite/java/rename_wildcard_runme.java
Normal file
90
Examples/test-suite/java/rename_wildcard_runme.java
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
|
||||
import rename_wildcard.*;
|
||||
|
||||
public class rename_wildcard_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("rename_wildcard");
|
||||
} 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[]) {
|
||||
// Wildcard check
|
||||
{
|
||||
new GlobalWildStruct().mm1();
|
||||
new GlobalWildTemplateStructInt().mm1();
|
||||
new SpaceWildStruct().mm1();
|
||||
new SpaceWildTemplateStructInt().mm1();
|
||||
}
|
||||
// No declaration
|
||||
{
|
||||
new GlobalWildStruct().mm2a();
|
||||
new GlobalWildTemplateStructInt().mm2b();
|
||||
new SpaceWildStruct().mm2c();
|
||||
new SpaceWildTemplateStructInt().mm2d();
|
||||
|
||||
new GlobalWildTemplateStructInt().tt2b();
|
||||
new SpaceWildTemplateStructInt().tt2d();
|
||||
}
|
||||
// With declaration
|
||||
{
|
||||
new GlobalWildStruct().mm3a();
|
||||
new GlobalWildTemplateStructInt().mm3b();
|
||||
new SpaceWildStruct().mm3c();
|
||||
new SpaceWildTemplateStructInt().mm3d();
|
||||
|
||||
new GlobalWildTemplateStructInt().tt3b();
|
||||
new SpaceWildTemplateStructInt().tt3d();
|
||||
}
|
||||
// Global override too
|
||||
{
|
||||
new GlobalWildStruct().mm4a();
|
||||
new GlobalWildTemplateStructInt().mm4b();
|
||||
new SpaceWildStruct().mm4c();
|
||||
new SpaceWildTemplateStructInt().mm4d();
|
||||
|
||||
new GlobalWildTemplateStructInt().tt4b();
|
||||
new SpaceWildTemplateStructInt().tt4d();
|
||||
}
|
||||
// %extend renames
|
||||
{
|
||||
new GlobalWildStruct().mm5a();
|
||||
new GlobalWildTemplateStructInt().mm5b();
|
||||
new SpaceWildStruct().mm5c();
|
||||
new SpaceWildTemplateStructInt().mm5d();
|
||||
|
||||
new GlobalWildTemplateStructInt().tt5b();
|
||||
new SpaceWildTemplateStructInt().tt5d();
|
||||
}
|
||||
// operators
|
||||
{
|
||||
new GlobalWildStruct().opinta();
|
||||
new GlobalWildTemplateStructInt().opintb();
|
||||
new SpaceWildStruct().opintc();
|
||||
new SpaceWildTemplateStructInt().opintd();
|
||||
|
||||
new GlobalWildTemplateStructInt().opdoubleb();
|
||||
new SpaceWildTemplateStructInt().opdoubled();
|
||||
}
|
||||
// Wildcard renames expected for these
|
||||
{
|
||||
new NoChangeStruct().mm1();
|
||||
new NoChangeStruct().mm2();
|
||||
new NoChangeStruct().mm3();
|
||||
new NoChangeStruct().mm4();
|
||||
new NoChangeStruct().mm5();
|
||||
new NoChangeStruct().opint();
|
||||
new SpaceNoChangeStruct().mm1();
|
||||
new SpaceNoChangeStruct().mm2();
|
||||
new SpaceNoChangeStruct().mm3();
|
||||
new SpaceNoChangeStruct().mm4();
|
||||
new SpaceNoChangeStruct().mm5();
|
||||
new SpaceNoChangeStruct().opint();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
19
Examples/test-suite/java/smart_pointer_ignore_runme.java
Normal file
19
Examples/test-suite/java/smart_pointer_ignore_runme.java
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
import smart_pointer_ignore.*;
|
||||
|
||||
public class smart_pointer_ignore_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("smart_pointer_ignore");
|
||||
} 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[]) {
|
||||
DerivedPtr d = smart_pointer_ignore.makeDerived();
|
||||
d.baseMethod();
|
||||
d.derivedMethod();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue