Merge from trunk
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2009-sploving@12270 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
commit
1842244c93
530 changed files with 22854 additions and 11740 deletions
|
|
@ -7,8 +7,8 @@ JAVA = java
|
|||
JAVAC = javac
|
||||
SCRIPTSUFFIX = _runme.java
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@/..
|
||||
top_builddir = @top_builddir@/..
|
||||
top_srcdir = ../@top_srcdir@
|
||||
top_builddir = ../@top_builddir@
|
||||
|
||||
C_TEST_CASES = \
|
||||
java_lib_arrays \
|
||||
|
|
@ -39,7 +39,6 @@ include $(srcdir)/../common.mk
|
|||
# Overridden variables here
|
||||
JAVA_PACKAGE = $*
|
||||
SWIGOPT += -package $(JAVA_PACKAGE)
|
||||
INTERFACEDIR = ../../
|
||||
|
||||
# Custom tests - tests with additional commandline options
|
||||
nspace.%: JAVA_PACKAGE = $*Package
|
||||
|
|
|
|||
|
|
@ -13,8 +13,38 @@ public class global_namespace_runme {
|
|||
|
||||
public static void main(String argv[]) {
|
||||
|
||||
KlassMethods.methodA(new Klass1(), new Klass2(), new Klass3(), new Klass4(), new Klass5(), new Klass6(), new Klass7());
|
||||
KlassMethods.methodB(new Klass1(), new Klass2(), new Klass3(), new Klass4(), new Klass5(), new Klass6(), new Klass7());
|
||||
Klass1 k1 = new Klass1();
|
||||
Klass2 k2 = new Klass2();
|
||||
Klass3 k3 = new Klass3();
|
||||
Klass4 k4 = new Klass4();
|
||||
Klass5 k5 = new Klass5();
|
||||
Klass6 k6 = new Klass6();
|
||||
Klass7 k7 = new Klass7();
|
||||
|
||||
KlassMethods.methodA(k1, k2, k3, k4, k5, k6, k7);
|
||||
KlassMethods.methodB(k1, k2, k3, k4, k5, k6, k7);
|
||||
|
||||
k1 = global_namespace.getKlass1A();
|
||||
k2 = global_namespace.getKlass2A();
|
||||
k3 = global_namespace.getKlass3A();
|
||||
k4 = global_namespace.getKlass4A();
|
||||
k5 = global_namespace.getKlass5A();
|
||||
k6 = global_namespace.getKlass6A();
|
||||
k7 = global_namespace.getKlass7A();
|
||||
|
||||
KlassMethods.methodA(k1, k2, k3, k4, k5, k6, k7);
|
||||
KlassMethods.methodB(k1, k2, k3, k4, k5, k6, k7);
|
||||
|
||||
k1 = global_namespace.getKlass1B();
|
||||
k2 = global_namespace.getKlass2B();
|
||||
k3 = global_namespace.getKlass3B();
|
||||
k4 = global_namespace.getKlass4B();
|
||||
k5 = global_namespace.getKlass5B();
|
||||
k6 = global_namespace.getKlass6B();
|
||||
k7 = global_namespace.getKlass7B();
|
||||
|
||||
KlassMethods.methodA(k1, k2, k3, k4, k5, k6, k7);
|
||||
KlassMethods.methodB(k1, k2, k3, k4, k5, k6, k7);
|
||||
|
||||
XYZMethods.methodA(new XYZ1(), new XYZ2(), new XYZ3(), new XYZ4(), new XYZ5(), new XYZ6(), new XYZ7());
|
||||
XYZMethods.methodB(new XYZ1(), new XYZ2(), new XYZ3(), new XYZ4(), new XYZ5(), new XYZ6(), new XYZ7());
|
||||
|
|
|
|||
27
Examples/test-suite/java/li_boost_shared_ptr_bits_runme.java
Normal file
27
Examples/test-suite/java/li_boost_shared_ptr_bits_runme.java
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
import li_boost_shared_ptr_bits.*;
|
||||
|
||||
public class li_boost_shared_ptr_bits_runme {
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("li_boost_shared_ptr_bits");
|
||||
} 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[])
|
||||
{
|
||||
VectorIntHolder v = new VectorIntHolder();
|
||||
v.add(new IntHolder(11));
|
||||
v.add(new IntHolder(22));
|
||||
v.add(new IntHolder(33));
|
||||
|
||||
int sum = li_boost_shared_ptr_bits.sum(v);
|
||||
if (sum != 66)
|
||||
throw new RuntimeException("sum is wrong");
|
||||
|
||||
HiddenDestructor hidden = HiddenDestructor.create();
|
||||
hidden.delete();
|
||||
}
|
||||
}
|
||||
68
Examples/test-suite/java/preproc_line_file_runme.java
Normal file
68
Examples/test-suite/java/preproc_line_file_runme.java
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
import preproc_line_file.*;
|
||||
|
||||
public class preproc_line_file_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("preproc_line_file");
|
||||
} 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 String FILENAME_WINDOWS = "..\\..\\..\\..\\Examples\\test-suite\\preproc_line_file.i";
|
||||
public static String FILENAME_UNIX = "../../../../Examples/test-suite/preproc_line_file.i";
|
||||
public static void main(String argv[]) throws Throwable
|
||||
{
|
||||
int myline = preproc_line_file.MYLINE;
|
||||
int myline_adjusted = preproc_line_file.MYLINE_ADJUSTED;
|
||||
if (myline != 4)
|
||||
throw new RuntimeException("preproc failure");
|
||||
if (myline + 100 + 1 != myline_adjusted)
|
||||
throw new RuntimeException("preproc failure");
|
||||
|
||||
String myfile = preproc_line_file.MYFILE;
|
||||
String myfile_adjusted = preproc_line_file.MYFILE_ADJUSTED;
|
||||
if (!(myfile.equals(FILENAME_UNIX) || myfile.equals(FILENAME_WINDOWS)))
|
||||
throw new RuntimeException("preproc failure");
|
||||
|
||||
if (!(myfile_adjusted.equals(FILENAME_UNIX + ".bak") || myfile_adjusted.equals(FILENAME_WINDOWS + ".bak")))
|
||||
throw new RuntimeException("preproc failure");
|
||||
|
||||
if (!preproc_line_file.MY_STRINGNUM_A.equals("my15"))
|
||||
throw new RuntimeException("preproc failed MY_STRINGNUM_A");
|
||||
|
||||
if (!preproc_line_file.MY_STRINGNUM_B.equals("my16"))
|
||||
throw new RuntimeException("preproc failed MY_STRINGNUM_B");
|
||||
|
||||
if (preproc_line_file.getThing27() != -1)
|
||||
throw new RuntimeException("preproc failure");
|
||||
|
||||
if (preproc_line_file.getThing28() != -2)
|
||||
throw new RuntimeException("preproc failure");
|
||||
|
||||
if (preproc_line_file.MYLINE2 != 30)
|
||||
throw new RuntimeException("preproc failure");
|
||||
|
||||
if (SillyStruct.LINE_NUMBER != 52)
|
||||
throw new RuntimeException("preproc failure");
|
||||
|
||||
if (SillyMacroClass.LINE_NUM != 56)
|
||||
throw new RuntimeException("preproc failure");
|
||||
|
||||
if (SillyMultipleMacroStruct.LINE_NUM != 81)
|
||||
throw new RuntimeException("preproc failure");
|
||||
|
||||
if (preproc_line_file.INLINE_LINE != 87)
|
||||
throw new RuntimeException("preproc failure");
|
||||
|
||||
String inlineFile = preproc_line_file.INLINE_FILE;
|
||||
if (!(inlineFile.equals(FILENAME_UNIX) || inlineFile.equals(FILENAME_WINDOWS)))
|
||||
throw new RuntimeException("preproc failure");
|
||||
|
||||
if (Slash.LINE_NUM != 93)
|
||||
throw new RuntimeException("preproc failure");
|
||||
|
||||
}
|
||||
}
|
||||
26
Examples/test-suite/java/rename_pcre_enum_runme.java
Normal file
26
Examples/test-suite/java/rename_pcre_enum_runme.java
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
import rename_pcre_enum.*;
|
||||
|
||||
public class rename_pcre_enum_runme {
|
||||
static { System.loadLibrary("rename_pcre_enum"); }
|
||||
|
||||
public static void main(String argv[])
|
||||
{
|
||||
Foo foo = Foo.First;
|
||||
if ( foo == Foo.Second )
|
||||
throw new RuntimeException("Enum values should be different");
|
||||
|
||||
// Check that Foo_Max enum element was ignored.
|
||||
int numFooEnumElements = Foo.values().length;
|
||||
if ( numFooEnumElements != 2 )
|
||||
throw new RuntimeException(String.format("Enum should have 2 elements, not %d",
|
||||
numFooEnumElements));
|
||||
|
||||
BoundaryCondition bc = BoundaryCondition.MaxMax;
|
||||
if ( bc.ordinal() != 2 )
|
||||
throw new RuntimeException("Wrong enum value");
|
||||
|
||||
Colour c = Colour.red;
|
||||
if ( c == Colour.blue )
|
||||
throw new RuntimeException("Enum values should be different");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,99 @@
|
|||
import smart_pointer_const_overload.*;
|
||||
|
||||
public class smart_pointer_const_overload_runme {
|
||||
static int CONST_ACCESS = 1;
|
||||
static int MUTABLE_ACCESS = 2;
|
||||
|
||||
static {
|
||||
System.loadLibrary("smart_pointer_const_overload");
|
||||
}
|
||||
|
||||
public static void test(Bar b, Foo f) {
|
||||
Assert(f.getX() == 0);
|
||||
|
||||
// Test member variable get
|
||||
Assert(b.getX() == 0);
|
||||
Assert(f.getAccess() == CONST_ACCESS);
|
||||
|
||||
// Test member variable set
|
||||
b.setX(1);
|
||||
Assert(f.getX() == 1);
|
||||
Assert(f.getAccess() == MUTABLE_ACCESS);
|
||||
|
||||
// Test const method
|
||||
Assert(b.getx() == 1);
|
||||
Assert(f.getAccess() == CONST_ACCESS);
|
||||
|
||||
// Test mutable method
|
||||
b.setx(2);
|
||||
|
||||
Assert(f.getX() == 2);
|
||||
Assert(f.getAccess() == MUTABLE_ACCESS);
|
||||
|
||||
// Test extended const method
|
||||
Assert(b.getx2() == 2);
|
||||
Assert(f.getAccess() == CONST_ACCESS);
|
||||
|
||||
// Test extended mutable method
|
||||
b.setx2(3);
|
||||
|
||||
Assert(f.getX() == 3);
|
||||
Assert(f.getAccess() == MUTABLE_ACCESS);
|
||||
|
||||
// Test static method
|
||||
b.stat();
|
||||
|
||||
Assert(f.getAccess() == CONST_ACCESS);
|
||||
|
||||
// Test const member
|
||||
f.setAccess(MUTABLE_ACCESS);
|
||||
|
||||
Assert(b.getY() == 0);
|
||||
Assert(f.getAccess() == CONST_ACCESS);
|
||||
|
||||
// Test get through mutable pointer to const member
|
||||
f.setAccess(MUTABLE_ACCESS);
|
||||
|
||||
Assert(smart_pointer_const_overload.get_int(b.getYp()) == 0);
|
||||
Assert(f.getAccess() == CONST_ACCESS);
|
||||
|
||||
// Test get through const pointer to mutable member
|
||||
f.setX(4);
|
||||
f.setAccess(MUTABLE_ACCESS);
|
||||
|
||||
Assert(smart_pointer_const_overload.get_int(b.getXp()) == 4);
|
||||
Assert(f.getAccess() == CONST_ACCESS);
|
||||
|
||||
// Test set through const pointer to mutable member
|
||||
f.setAccess(MUTABLE_ACCESS);
|
||||
smart_pointer_const_overload.set_int(b.getXp(), 5);
|
||||
|
||||
Assert(f.getX() == 5);
|
||||
Assert(f.getAccess() == CONST_ACCESS);
|
||||
|
||||
// Test set pointer to const member
|
||||
b.setYp(smart_pointer_const_overload.new_int(6));
|
||||
|
||||
Assert(f.getY() == 0);
|
||||
Assert(smart_pointer_const_overload.get_int(f.getYp()) == 6);
|
||||
Assert(f.getAccess() == MUTABLE_ACCESS);
|
||||
|
||||
smart_pointer_const_overload.delete_int(f.getYp());
|
||||
}
|
||||
|
||||
public static void main(String argv[]) {
|
||||
Foo f = new Foo();
|
||||
Bar b = new Bar(f);
|
||||
|
||||
//Foo f2 = new Foo();
|
||||
//Bar b2 = new Bar2(f2);
|
||||
|
||||
test(b, f);
|
||||
//test(b2, f2);
|
||||
}
|
||||
|
||||
public static void Assert(boolean b) {
|
||||
if (!b)
|
||||
throw new RuntimeException("Assertion failed");
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue