Merge branch 'master' into gsoc2009-matevz

parser.y still to be fixed up

Conflicts:
	Doc/Devel/engineering.html
	Examples/Makefile.in
	Lib/allegrocl/allegrocl.swg
	Lib/csharp/csharp.swg
	Lib/csharp/enums.swg
	Lib/csharp/enumsimple.swg
	Lib/csharp/enumtypesafe.swg
	Lib/java/java.swg
	Lib/python/pydocs.swg
	Lib/r/rtype.swg
	Source/Include/swigwarn.h
	Source/Modules/octave.cxx
	Source/Modules/python.cxx
	Source/Modules/ruby.cxx
	Source/Swig/scanner.c
	Source/Swig/stype.c
	Source/Swig/swig.h
	configure.ac
This commit is contained in:
William S Fulton 2013-01-28 07:01:37 +00:00
commit e805d5f925
42 changed files with 54298 additions and 20093 deletions

View file

@ -3,12 +3,13 @@
#######################################################################
LANGUAGE = java
JAVA = java
JAVAC = javac
JAVA = @JAVA@
JAVAC = @JAVAC@
JAVAFLAGS = -Xcheck:jni
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 \
@ -22,10 +23,12 @@ CPP_TEST_CASES = \
intermediary_classname \
java_constants \
java_director \
java_director_assumeoverride \
java_enums \
java_jnitypes \
java_lib_arrays_dimensionless \
java_lib_various \
java_jnitypes \
java_nspacewithoutpackage \
java_pgcpp \
java_pragmas \
java_prepost \
@ -38,11 +41,15 @@ include $(srcdir)/../common.mk
# Overridden variables here
JAVA_PACKAGE = $*
SWIGOPT += -package $(JAVA_PACKAGE)
JAVA_PACKAGEOPT = -package $(JAVA_PACKAGE)
SWIGOPT += $(JAVA_PACKAGEOPT)
# Custom tests - tests with additional commandline options
java_nspacewithoutpackage.%: JAVA_PACKAGEOPT =
nspace.%: JAVA_PACKAGE = $*Package
nspace_extend.%: JAVA_PACKAGE = $*Package
director_nspace.%: JAVA_PACKAGE = $*Package
director_nspace_director_name_collision.%: JAVA_PACKAGE = $*Package
# Rules for the different types of tests
%.cpptest:
@ -78,7 +85,7 @@ run_testcase = \
cd $(JAVA_PACKAGE) && $(COMPILETOOL) $(JAVAC) -classpath . `find . -name "*.java"` && cd .. && \
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
$(COMPILETOOL) $(JAVAC) -classpath . -d . $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \
env LD_LIBRARY_PATH="$(JAVA_PACKAGE):$$LD_LIBRARY_PATH" PATH="$(JAVA_PACKAGE):$$PATH" SHLIB_PATH="$(JAVA_PACKAGE):$$SHLIB_PATH" DYLD_LIBRARY_PATH="$(JAVA_PACKAGE):$$DYLD_LIBRARY_PATH" $(RUNTOOL) $(JAVA) -classpath . $*_runme; \
env LD_LIBRARY_PATH="$(JAVA_PACKAGE):$$LD_LIBRARY_PATH" PATH="$(JAVA_PACKAGE):$$PATH" SHLIB_PATH="$(JAVA_PACKAGE):$$SHLIB_PATH" DYLD_LIBRARY_PATH="$(JAVA_PACKAGE):$$DYLD_LIBRARY_PATH" $(RUNTOOL) $(JAVA) $(JAVAFLAGS) -classpath . $*_runme; \
fi
# Clean: remove testcase directories

View file

@ -0,0 +1,24 @@
import char_binary.*;
public class char_binary_runme {
static {
try {
System.loadLibrary("char_binary");
} 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[]) {
Test t = new Test();
byte[] hile = "hile".getBytes();
byte[] hil0 = "hil\0".getBytes();
if (t.strlen(hile) != 4)
throw new RuntimeException("bad multi-arg typemap");
if (t.strlen(hil0) != 4)
throw new RuntimeException("bad multi-arg typemap");
}
}

View file

@ -0,0 +1,29 @@
import curiously_recurring_template_pattern.*;
public class curiously_recurring_template_pattern_runme {
static {
try {
System.loadLibrary("curiously_recurring_template_pattern");
} 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[]) {
Derived d = new Derived();
d.setBase1Param(1).setDerived1Param(10).setDerived2Param(20).setBase2Param(2);
if (d.getBase1Param() != 1)
throw new RuntimeException("fail");
if (d.getDerived1Param() != 10)
throw new RuntimeException("fail");
if (d.getBase2Param() != 2)
throw new RuntimeException("fail");
if (d.getDerived2Param() != 20)
throw new RuntimeException("fail");
}
}

View file

@ -0,0 +1,49 @@
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);
new Callback().run(null, null);
callback = new DirectorBinaryStringCallback();
caller.setCallback(callback);
caller.call_null();
}
}
class DirectorBinaryStringCallback extends Callback {
public DirectorBinaryStringCallback() {
super();
}
@Override
public void run(byte[] dataBufferAA, byte[] dataBufferBB)
{
if (dataBufferAA != null)
for (int i = 0; i < dataBufferAA.length; i++)
dataBufferAA[i] = (byte)(dataBufferAA[i] * 2);
if (dataBufferBB != null)
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.TopLevel.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.TopLevel.Bar.FooBar fooBar) {
return fooBar.FooBarDo();
}
@Override
public director_nspacePackage.TopLevel.Bar.Foo makeFoo() {
return new director_nspacePackage.TopLevel.Bar.Foo();
}
@Override
public director_nspacePackage.TopLevel.Bar.FooBar makeFooBar() {
return new director_nspacePackage.TopLevel.Bar.FooBar();
}
}

View file

@ -19,6 +19,7 @@ public class director_protected_runme {
Foo f = b.create();
director_protected_FooBar fb = new director_protected_FooBar();
director_protected_FooBar2 fb2 = new director_protected_FooBar2();
director_protected_FooBar3 fb3 = new director_protected_FooBar3();
{
String s = fb.used();
@ -60,11 +61,34 @@ public class director_protected_runme {
if ( !Modifier.isProtected(method.getModifiers()) )
throw new RuntimeException("Foo::ping should be protected" );
method = b.getClass().getDeclaredMethod("cheer", (java.lang.Class[])null);
if ( !Modifier.isProtected(method.getModifiers()) )
throw new RuntimeException("Bar::cheer should be protected" );
method = f.getClass().getDeclaredMethod("cheer", (java.lang.Class[])null);
if ( !Modifier.isProtected(method.getModifiers()) )
throw new RuntimeException("Foo::cheer should be protected" );
} catch (NoSuchMethodException n) {
throw new RuntimeException("NoSuchmethodException caught. Test failed.");
throw new RuntimeException(n);
} catch (SecurityException s) {
throw new RuntimeException("SecurityException caught. Test failed.");
}
if (!fb3.cheer().equals("director_protected_FooBar3::cheer();"))
throw new RuntimeException("bad fb3::cheer");
if (!fb2.callping().equals("director_protected_FooBar2::ping();"))
throw new RuntimeException("bad fb2.callping");
if (!fb2.callcheer().equals("director_protected_FooBar2::pang();Bar::pong();Foo::pong();director_protected_FooBar2::ping();"))
throw new RuntimeException("bad fb2.callcheer");
if (!fb3.callping().equals("Bar::ping();"))
throw new RuntimeException("bad fb3.callping");
if (!fb3.callcheer().equals("director_protected_FooBar3::cheer();"))
throw new RuntimeException("bad fb3.callcheer");
}
}
@ -83,3 +107,9 @@ class director_protected_FooBar2 extends Bar {
}
}
class director_protected_FooBar3 extends Bar {
public String cheer() {
return "director_protected_FooBar3::cheer();";
}
}

View file

@ -0,0 +1,48 @@
// Make sure that directors are connected and disconnected when used inconjunction with
// being a smart pointer
public class director_smartptr_runme {
static {
try {
System.loadLibrary("director_smartptr");
} 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_smartptr_MyBarFoo myBarFoo =
new director_smartptr_MyBarFoo();
}
}
class director_smartptr_MyBarFoo extends director_smartptr.Foo {
@Override
public String ping() {
return "director_smartptr_MyBarFoo.ping();";
}
@Override
public String pong() {
return "director_smartptr_MyBarFoo.pong();" + ping();
}
@Override
public String fooBar(director_smartptr.FooBar fooBar) {
return fooBar.FooBarDo();
}
@Override
public director_smartptr.Foo makeFoo() {
return new director_smartptr.Foo();
}
@Override
public director_smartptr.FooBar makeFooBar() {
return new director_smartptr.FooBar();
}
}

View file

@ -0,0 +1,33 @@
import enum_forward.*;
public class enum_forward_runme {
static {
try {
System.loadLibrary("enum_forward");
} 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[])
{
try {
ForwardEnum1 f1 = enum_forward.get_enum1();
f1 = enum_forward.test_function1(f1);
} catch (IllegalArgumentException e) {
}
try {
ForwardEnum2 f2 = enum_forward.get_enum2();
f2 = enum_forward.test_function2(f2);
} catch (IllegalArgumentException e) {
}
ForwardEnum3 f3 = enum_forward.get_enum3();
f3 = enum_forward.test_function3(f3);
}
}

View file

@ -416,6 +416,28 @@ public class enum_thorough_proper_runme {
if (enum_thorough_proper.repeatTest(repeat.llast).swigValue() != 3) throw new RuntimeException("repeatTest 5 failed");
if (enum_thorough_proper.repeatTest(repeat.end).swigValue() != 3) throw new RuntimeException("repeatTest 6 failed");
}
// different types
{
if (enum_thorough_proper.differentTypesTest(DifferentTypes.typeint).swigValue() != 10) throw new RuntimeException("differentTypes 1 failed");
if (enum_thorough_proper.differentTypesTest(DifferentTypes.typeboolfalse).swigValue() != 0) throw new RuntimeException("differentTypes 2 failed");
if (enum_thorough_proper.differentTypesTest(DifferentTypes.typebooltrue).swigValue() != 1) throw new RuntimeException("differentTypes 3 failed");
if (enum_thorough_proper.differentTypesTest(DifferentTypes.typebooltwo).swigValue() != 2) throw new RuntimeException("differentTypes 4 failed");
if (enum_thorough_proper.differentTypesTest(DifferentTypes.typechar).swigValue() != 'C') throw new RuntimeException("differentTypes 5 failed");
if (enum_thorough_proper.differentTypesTest(DifferentTypes.typedefaultint).swigValue() != 'D') throw new RuntimeException("differentTypes 6 failed");
int global_enum = enum_thorough_proper.global_typeint;
if (enum_thorough_proper.globalDifferentTypesTest(global_enum) != 10) throw new RuntimeException("global differentTypes 1 failed");
global_enum = enum_thorough_proper.global_typeboolfalse;
if (enum_thorough_proper.globalDifferentTypesTest(global_enum) != 0) throw new RuntimeException("global differentTypes 2 failed");
global_enum = enum_thorough_proper.global_typebooltrue;
if (enum_thorough_proper.globalDifferentTypesTest(global_enum) != 1) throw new RuntimeException("global differentTypes 3 failed");
global_enum = enum_thorough_proper.global_typebooltwo;
if (enum_thorough_proper.globalDifferentTypesTest(global_enum) != 2) throw new RuntimeException("global differentTypes 4 failed");
global_enum = enum_thorough_proper.global_typechar;
if (enum_thorough_proper.globalDifferentTypesTest(global_enum) != 'C') throw new RuntimeException("global differentTypes 5 failed");
global_enum = enum_thorough_proper.global_typedefaultint;
if (enum_thorough_proper.globalDifferentTypesTest(global_enum) != 'D') throw new RuntimeException("global differentTypes 6 failed");
}
}
}

View file

@ -416,6 +416,28 @@ public class enum_thorough_runme {
if (enum_thorough.repeatTest(repeat.llast).swigValue() != 3) throw new RuntimeException("repeatTest 5 failed");
if (enum_thorough.repeatTest(repeat.end).swigValue() != 3) throw new RuntimeException("repeatTest 6 failed");
}
// different types
{
if (enum_thorough.differentTypesTest(DifferentTypes.typeint).swigValue() != 10) throw new RuntimeException("differentTypes 1 failed");
if (enum_thorough.differentTypesTest(DifferentTypes.typeboolfalse).swigValue() != 0) throw new RuntimeException("differentTypes 2 failed");
if (enum_thorough.differentTypesTest(DifferentTypes.typebooltrue).swigValue() != 1) throw new RuntimeException("differentTypes 3 failed");
if (enum_thorough.differentTypesTest(DifferentTypes.typebooltwo).swigValue() != 2) throw new RuntimeException("differentTypes 4 failed");
if (enum_thorough.differentTypesTest(DifferentTypes.typechar).swigValue() != 'C') throw new RuntimeException("differentTypes 5 failed");
if (enum_thorough.differentTypesTest(DifferentTypes.typedefaultint).swigValue() != 'D') throw new RuntimeException("differentTypes 6 failed");
int global_enum = enum_thorough.global_typeint;
if (enum_thorough.globalDifferentTypesTest(global_enum) != 10) throw new RuntimeException("global differentTypes 1 failed");
global_enum = enum_thorough.global_typeboolfalse;
if (enum_thorough.globalDifferentTypesTest(global_enum) != 0) throw new RuntimeException("global differentTypes 2 failed");
global_enum = enum_thorough.global_typebooltrue;
if (enum_thorough.globalDifferentTypesTest(global_enum) != 1) throw new RuntimeException("global differentTypes 3 failed");
global_enum = enum_thorough.global_typebooltwo;
if (enum_thorough.globalDifferentTypesTest(global_enum) != 2) throw new RuntimeException("global differentTypes 4 failed");
global_enum = enum_thorough.global_typechar;
if (enum_thorough.globalDifferentTypesTest(global_enum) != 'C') throw new RuntimeException("global differentTypes 5 failed");
global_enum = enum_thorough.global_typedefaultint;
if (enum_thorough.globalDifferentTypesTest(global_enum) != 'D') throw new RuntimeException("global differentTypes 6 failed");
}
}
}

View file

@ -416,6 +416,28 @@ public class enum_thorough_simple_runme {
if (enum_thorough_simple.repeatTest(enum_thorough_simpleConstants.llast) != 3) throw new RuntimeException("repeatTest 5 failed");
if (enum_thorough_simple.repeatTest(enum_thorough_simpleConstants.end) != 3) throw new RuntimeException("repeatTest 6 failed");
}
// different types
{
if (enum_thorough_simple.differentTypesTest(enum_thorough_simpleConstants.typeint) != 10) throw new RuntimeException("differentTypes 1 failed");
if (enum_thorough_simple.differentTypesTest(enum_thorough_simpleConstants.typeboolfalse) != 0) throw new RuntimeException("differentTypes 2 failed");
if (enum_thorough_simple.differentTypesTest(enum_thorough_simpleConstants.typebooltrue) != 1) throw new RuntimeException("differentTypes 3 failed");
if (enum_thorough_simple.differentTypesTest(enum_thorough_simpleConstants.typebooltwo) != 2) throw new RuntimeException("differentTypes 4 failed");
if (enum_thorough_simple.differentTypesTest(enum_thorough_simpleConstants.typechar) != 'C') throw new RuntimeException("differentTypes 5 failed");
if (enum_thorough_simple.differentTypesTest(enum_thorough_simpleConstants.typedefaultint) != 'D') throw new RuntimeException("differentTypes 6 failed");
int global_enum = enum_thorough_simple.global_typeint;
if (enum_thorough_simple.globalDifferentTypesTest(global_enum) != 10) throw new RuntimeException("global differentTypes 1 failed");
global_enum = enum_thorough_simple.global_typeboolfalse;
if (enum_thorough_simple.globalDifferentTypesTest(global_enum) != 0) throw new RuntimeException("global differentTypes 2 failed");
global_enum = enum_thorough_simple.global_typebooltrue;
if (enum_thorough_simple.globalDifferentTypesTest(global_enum) != 1) throw new RuntimeException("global differentTypes 3 failed");
global_enum = enum_thorough_simple.global_typebooltwo;
if (enum_thorough_simple.globalDifferentTypesTest(global_enum) != 2) throw new RuntimeException("global differentTypes 4 failed");
global_enum = enum_thorough_simple.global_typechar;
if (enum_thorough_simple.globalDifferentTypesTest(global_enum) != 'C') throw new RuntimeException("global differentTypes 5 failed");
global_enum = enum_thorough_simple.global_typedefaultint;
if (enum_thorough_simple.globalDifferentTypesTest(global_enum) != 'D') throw new RuntimeException("global differentTypes 6 failed");
}
}
}

View file

@ -416,6 +416,28 @@ public class enum_thorough_typeunsafe_runme {
if (enum_thorough_typeunsafe.repeatTest(repeat.llast) != 3) throw new RuntimeException("repeatTest 5 failed");
if (enum_thorough_typeunsafe.repeatTest(repeat.end) != 3) throw new RuntimeException("repeatTest 6 failed");
}
// different types
{
if (enum_thorough_typeunsafe.differentTypesTest(DifferentTypes.typeint) != 10) throw new RuntimeException("differentTypes 1 failed");
if (enum_thorough_typeunsafe.differentTypesTest(DifferentTypes.typeboolfalse) != 0) throw new RuntimeException("differentTypes 2 failed");
if (enum_thorough_typeunsafe.differentTypesTest(DifferentTypes.typebooltrue) != 1) throw new RuntimeException("differentTypes 3 failed");
if (enum_thorough_typeunsafe.differentTypesTest(DifferentTypes.typebooltwo) != 2) throw new RuntimeException("differentTypes 4 failed");
if (enum_thorough_typeunsafe.differentTypesTest(DifferentTypes.typechar) != 'C') throw new RuntimeException("differentTypes 5 failed");
if (enum_thorough_typeunsafe.differentTypesTest(DifferentTypes.typedefaultint) != 'D') throw new RuntimeException("differentTypes 6 failed");
int global_enum = enum_thorough_typeunsafe.global_typeint;
if (enum_thorough_typeunsafe.globalDifferentTypesTest(global_enum) != 10) throw new RuntimeException("global differentTypes 1 failed");
global_enum = enum_thorough_typeunsafe.global_typeboolfalse;
if (enum_thorough_typeunsafe.globalDifferentTypesTest(global_enum) != 0) throw new RuntimeException("global differentTypes 2 failed");
global_enum = enum_thorough_typeunsafe.global_typebooltrue;
if (enum_thorough_typeunsafe.globalDifferentTypesTest(global_enum) != 1) throw new RuntimeException("global differentTypes 3 failed");
global_enum = enum_thorough_typeunsafe.global_typebooltwo;
if (enum_thorough_typeunsafe.globalDifferentTypesTest(global_enum) != 2) throw new RuntimeException("global differentTypes 4 failed");
global_enum = enum_thorough_typeunsafe.global_typechar;
if (enum_thorough_typeunsafe.globalDifferentTypesTest(global_enum) != 'C') throw new RuntimeException("global differentTypes 5 failed");
global_enum = enum_thorough_typeunsafe.global_typedefaultint;
if (enum_thorough_typeunsafe.globalDifferentTypesTest(global_enum) != 'D') throw new RuntimeException("global differentTypes 6 failed");
}
}
}

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,25 @@
import extend_special_variables.*;
public class extend_special_variables_runme {
static {
try {
System.loadLibrary("extend_special_variables");
} 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[])
{
ForExtensionNewName f = new ForExtensionNewName();
verify(f.extended_renamed(), "name:extended symname:extended_renamed wrapname: overname:__SWIG_0 decl:ForExtension::extended() fulldecl:char const * ForExtension::extended() parentclasssymname:ForExtensionNewName parentclassname:ForExtension");
verify(f.extended_renamed(10), "name:extended symname:extended_renamed wrapname: overname:__SWIG_1 decl:ForExtension::extended(int) fulldecl:char const * ForExtension::extended(int) parentclasssymname:ForExtensionNewName parentclassname:ForExtension");
}
static void verify(String received, String expected) {
if (!received.equals(expected))
throw new RuntimeException("Incorrect, received: " + received);
}
}

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

@ -0,0 +1,53 @@
import friends.*;
public class friends_runme {
static {
try {
System.loadLibrary("friends");
} 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
{
A a = new A(2);
if (friends.get_val1(a) != 2)
throw new RuntimeException("failed");
if (friends.get_val2(a) != 4)
throw new RuntimeException("failed");
if (friends.get_val3(a) != 6)
throw new RuntimeException("failed");
// nice overload working fine
if (friends.get_val1(1,2,3) != 1)
throw new RuntimeException("failed");
B b = new B(3);
// David's case
if (friends.mix(a,b) != 5)
throw new RuntimeException("failed");
D_d di = new D_d(2);
D_d dd = new D_d(3.3);
// incredible template overloading working just fine
if (friends.get_val1(di) != 2)
throw new RuntimeException("failed");
if (friends.get_val1(dd) != 3.3)
throw new RuntimeException("failed");
friends.set(di, 4);
friends.set(dd, 1.3);
if (friends.get_val1(di) != 4)
throw new RuntimeException("failed");
if (friends.get_val1(dd) != 1.3)
throw new RuntimeException("failed");
}
}

View file

@ -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());

View file

@ -0,0 +1,27 @@
import java_director_assumeoverride.*;
public class java_director_assumeoverride_runme {
static {
try {
System.loadLibrary("java_director_assumeoverride");
} 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);
}
}
static class MyOverrideMe extends OverrideMe {
}
public static void main(String argv[]) {
OverrideMe overrideMe = new MyOverrideMe();
// MyOverrideMe doesn't actually override func(), but because assumeoverride
// was set to true, the C++ side will believe it was overridden.
if (!java_director_assumeoverride.isFuncOverridden(overrideMe)) {
throw new RuntimeException ( "isFuncOverridden()" );
}
}
}

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

@ -45,6 +45,11 @@ public class java_lib_various_runme {
if ( !langs[i].equals(newLangs[i]) )
throw new RuntimeException("Languages verify failed " + i + " " + langs[i] + "|" + newLangs[i]);
// STRING_ARRAY null
java_lib_various.setLanguages(null);
if (java_lib_various.getLanguages() != null)
throw new RuntimeException("languages should be null");
// STRING_RET test
{
String stringOutArray[] = { "" };

Some files were not shown because too many files have changed in this diff Show more