Merge from trunk

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2009-sploving@12905 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Vincent Couvert 2012-02-03 14:37:31 +00:00
commit dd3db36b1a
321 changed files with 12114 additions and 8559 deletions

View file

@ -43,6 +43,7 @@ SWIGOPT += -package $(JAVA_PACKAGE)
# Custom tests - tests with additional commandline options
nspace.%: JAVA_PACKAGE = $*Package
nspace_extend.%: JAVA_PACKAGE = $*Package
director_nspace.%: JAVA_PACKAGE = $*Package
# Rules for the different types of tests
%.cpptest:

View file

@ -0,0 +1,42 @@
import director_binary_string.*;
public class director_binary_string_runme {
static {
try {
System.loadLibrary("director_binary_string");
} 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[]) {
Caller caller = new Caller();
Callback callback = new DirectorBinaryStringCallback();
caller.setCallback(callback);
int sum = caller.call();
caller.delCallback();
if (sum != 9*2*8 + 13*3*5)
throw new RuntimeException("Unexpected sum: " + sum);
}
}
class DirectorBinaryStringCallback extends Callback {
public DirectorBinaryStringCallback() {
super();
}
@Override
public void run(byte[] dataBufferAA, byte[] dataBufferBB)
{
for (int i = 0; i < dataBufferAA.length; i++)
dataBufferAA[i] = (byte)(dataBufferAA[i] * 2);
for (int i = 0; i < dataBufferBB.length; i++)
dataBufferBB[i] = (byte)(dataBufferBB[i] * 3);
}
}

View file

@ -0,0 +1,48 @@
// Make sure that directors are connected and disconnected when used inconjunction with
// the %nspace feature
public class director_nspace_runme {
static {
try {
System.loadLibrary("director_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);
}
}
public static void main(String argv[]) {
director_nspace_MyBarFoo myBarFoo =
new director_nspace_MyBarFoo();
}
}
class director_nspace_MyBarFoo extends director_nspacePackage.Bar.Foo {
@Override
public String ping() {
return "director_nspace_MyBarFoo.ping();";
}
@Override
public String pong() {
return "director_nspace_MyBarFoo.pong();" + ping();
}
@Override
public String fooBar(director_nspacePackage.Bar.FooBar fooBar) {
return fooBar.FooBarDo();
}
@Override
public director_nspacePackage.Bar.Foo makeFoo() {
return new director_nspacePackage.Bar.Foo();
}
@Override
public director_nspacePackage.Bar.FooBar makeFooBar() {
return new director_nspacePackage.Bar.FooBar();
}
}

View file

@ -0,0 +1,52 @@
import extend_constructor_destructor.*;
public class extend_constructor_destructor_runme {
static {
try {
System.loadLibrary("extend_constructor_destructor");
} 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[]) {
AStruct a = new AStruct(10);
checkGlobal(10);
BStruct b = new BStruct(20);
checkGlobal(20);
CStruct c = new CStruct(30);
checkGlobal(30);
DStruct d = new DStruct(40);
checkGlobal(40);
EStruct e = new EStruct(50);
checkGlobal(50);
FStruct f = new FStruct(60);
checkGlobal(60);
GStruct g = new GStruct(70);
checkGlobal(70);
a.delete();
checkGlobal(-10);
b.delete();
checkGlobal(-20);
c.delete();
checkGlobal(-30);
d.delete();
checkGlobal(-40);
e.delete();
checkGlobal(-50);
f.delete();
checkGlobal(-60);
g.delete();
checkGlobal(-70);
}
public static void checkGlobal(int val) {
int global = extend_constructor_destructor.getGlobalVar();
if (global != val)
throw new RuntimeException("global value incorrect. Expected: " + val + " got: " + global);
}
}

View file

@ -0,0 +1,65 @@
import extend_typedef_class.*;
public class extend_typedef_class_runme {
static {
try {
System.loadLibrary("extend_typedef_class");
} 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[]) {
// No namespace
{
AClass s = new AClass();
s.setMembervar(10);
checkMatch(s.getvar(), 10);
}
{
BClass s = new BClass();
s.setMembervar(20);
checkMatch(s.getvar(), 20);
}
{
CClass s = new CClass();
s.setMembervar(30);
checkMatch(s.getvar(), 30);
}
{
DClass s = new DClass();
s.setMembervar(40);
checkMatch(s.getvar(), 40);
}
// In namespace
{
AStruct s = new AStruct();
s.setMembervar(10);
checkMatch(s.getvar(), 10);
}
{
BStruct s = new BStruct();
s.setMembervar(20);
checkMatch(s.getvar(), 20);
}
{
CStruct s = new CStruct();
s.setMembervar(30);
checkMatch(s.getvar(), 30);
}
{
DStruct s = new DStruct();
s.setMembervar(40);
checkMatch(s.getvar(), 40);
}
}
public static void checkMatch(int expected, int got) {
if (expected != got)
throw new RuntimeException("Value incorrect. Expected: " + expected + " got: " + got);
}
}

View file

@ -23,6 +23,7 @@ public class java_lib_arrays_runme {
// Create arrays for all the array types that ArrayStruct can handle
String array_c = "X";
byte[] array_c_extra = {11, 22};
byte[] array_sc = {10, 20};
short[] array_uc = {101, 201};
short[] array_s = {1002, 2002};
@ -105,6 +106,12 @@ public class java_lib_arrays_runme {
as.setArray_struct(array_struct);
check_struct_array(array_struct, as.getArray_struct());
// Extended element (for char[])
ArrayStructExtra ase = new ArrayStructExtra();
ase.setArray_c2(array_c_extra);
check_byte_array(array_c_extra, ase.getArray_c2());
}
// Functions to check that the array values were set correctly

View file

@ -0,0 +1,49 @@
import li_boost_shared_ptr_template.*;
public class li_boost_shared_ptr_template_runme {
static {
try {
System.loadLibrary("li_boost_shared_ptr_template");
} 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[]) {
{
BaseINTEGER b = new BaseINTEGER();
DerivedINTEGER d = new DerivedINTEGER();
if (b.bar() != 1)
throw new RuntimeException("test 1");
if (d.bar() != 2)
throw new RuntimeException("test 2");
if (li_boost_shared_ptr_template.bar_getter(b) != 1)
throw new RuntimeException("test 3");
if (li_boost_shared_ptr_template.bar_getter(d) != 2)
throw new RuntimeException("test 4");
}
{
BaseDefaultInt b = new BaseDefaultInt();
DerivedDefaultInt d = new DerivedDefaultInt();
DerivedDefaultInt2 d2 = new DerivedDefaultInt2();
if (b.bar2() != 3)
throw new RuntimeException("test 5");
if (d.bar2() != 4)
throw new RuntimeException("test 6");
if (d2.bar2() != 4)
throw new RuntimeException("test 6");
if (li_boost_shared_ptr_template.bar2_getter(b) != 3)
throw new RuntimeException("test 7");
if (li_boost_shared_ptr_template.bar2_getter(d) != 4)
throw new RuntimeException("test 8");
if (li_boost_shared_ptr_template.bar2_getter(d2) != 4)
throw new RuntimeException("test 8");
}
}
}

View file

@ -17,8 +17,11 @@ public class template_default_class_parms_runme {
{
DefaultBar bar = new DefaultBar(20.0, new SomeType(), 10);
double d = bar.getCType();
bar.setCType(d);
SomeType s = bar.getDType();
bar.setDType(s);
int i = bar.getEType();
bar.setEType(i);
d = bar.method(d, s, i);
}
{
@ -29,13 +32,17 @@ public class template_default_class_parms_runme {
{
BarAnotherTypeBool bar = new BarAnotherTypeBool(new AnotherType(), true, 10);
AnotherType a = bar.getCType();
bar.setCType(a);
boolean b = bar.getDType();
bar.setDType(b);
int i = bar.getEType();
bar.setEType(i);
a = bar.method(a, b, i);
}
{
FooAnotherType foo = new FooAnotherType(new AnotherType());
AnotherType a = foo.getTType();
foo.setTType(a);
a = foo.method(a);
}
}

View file

@ -0,0 +1,86 @@
import template_default_class_parms_typedef.*;
public class template_default_class_parms_typedef_runme {
static {
try {
System.loadLibrary("template_default_class_parms_typedef");
} 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[]) {
{
DefaultBar bar = new DefaultBar(20.0, new SomeType(), 10);
double d = bar.getCType();
bar.setCType(d);
SomeType s = bar.getDType();
bar.setDType(s);
int i = bar.getEType();
bar.setEType(i);
d = bar.method(d, s, i);
d = bar.method_1(d, s, i);
d = bar.method_2(d, s, i);
d = bar.method_3(d, s, i);
bar = new DefaultBar(true, 20.0, new SomeType(), 10);
bar = new DefaultBar(true, true, 20.0, new SomeType(), 10);
bar = new DefaultBar(true, true, true, 20.0, new SomeType(), 10);
}
{
DefaultFoo foo = new DefaultFoo(new SomeType());
SomeType s = foo.getTType();
s = foo.method(s);
s = foo.method_A(s);
s = foo.method_B(s);
s = foo.method_C(s);
foo = new DefaultFoo(new SomeType(), new SomeType());
foo = new DefaultFoo(new SomeType(), new SomeType(), new SomeType());
foo = new DefaultFoo(new SomeType(), new SomeType(), new SomeType(), new SomeType());
}
{
BarAnotherTypeBool bar = new BarAnotherTypeBool(new AnotherType(), true, 10);
AnotherType a = bar.getCType();
bar.setCType(a);
boolean b = bar.getDType();
bar.setDType(b);
int i = bar.getEType();
bar.setEType(i);
a = bar.method(a, b, i);
a = bar.method_1(a, b, i);
a = bar.method_2(a, b, i);
a = bar.method_3(a, b, i);
bar = new BarAnotherTypeBool(true, new AnotherType(), true, 10);
bar = new BarAnotherTypeBool(true, true, new AnotherType(), true, 10);
bar = new BarAnotherTypeBool(true, true, true, new AnotherType(), true, 10);
}
{
FooAnotherType foo = new FooAnotherType(new AnotherType());
AnotherType a = foo.getTType();
foo.setTType(a);
a = foo.method(a);
a = foo.method_A(a);
a = foo.method_B(a);
a = foo.method_C(a);
foo = new FooAnotherType(new AnotherType(), new AnotherType());
foo = new FooAnotherType(new AnotherType(), new AnotherType(), new AnotherType());
foo = new FooAnotherType(new AnotherType(), new AnotherType(), new AnotherType(), new AnotherType());
}
{
UsesBarDouble u = new UsesBarDouble();
u.use_A(10.1, new SomeType(), 10);
u.use_B(10.1, new SomeType(), 10);
u.use_C(10.1, new SomeType(), 10);
u.use_D(10.1, new SomeType(), 10);
}
}
}

View file

@ -0,0 +1,24 @@
import template_typedef_inherit.*;
public class template_typedef_inherit_runme {
static {
try {
System.loadLibrary("template_typedef_inherit");
} 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[]) {
DescriptionImplementationTypedCollectionInterfaceObject d = new DescriptionImplementationTypedCollectionInterfaceObject();
d.add("a string");
StringPersistentCollection s = new StringPersistentCollection();
s.add("a string");
}
}