Ensure the premature garbage collection prevention parameter (pgcpp) is generated for Java wrappers
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9943 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
7a3c9a08a2
commit
7199cf2ef0
10 changed files with 156 additions and 18 deletions
|
|
@ -24,6 +24,7 @@ CPP_TEST_CASES = \
|
|||
java_lib_arrays_dimensionless \
|
||||
java_lib_various \
|
||||
java_jnitypes \
|
||||
java_pgcpp \
|
||||
java_pragmas \
|
||||
java_prepost \
|
||||
java_throws \
|
||||
|
|
|
|||
30
Examples/test-suite/java/java_pgcpp_runme.java
Normal file
30
Examples/test-suite/java/java_pgcpp_runme.java
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
|
||||
import java_pgcpp.*;
|
||||
|
||||
|
||||
public class java_pgcpp_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("java_pgcpp");
|
||||
} 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[]) {
|
||||
Classic object = new Classic();
|
||||
long ptr = object.getCPtrValue();
|
||||
|
||||
java_pgcppJNI.new_Classic__SWIG_1(ptr, object, ptr, object, ptr, object, ptr, object, ptr, object);
|
||||
java_pgcppJNI.new_Classic__SWIG_2(ptr, object, ptr, object, ptr, object, ptr, object, ptr, object, false);
|
||||
|
||||
java_pgcppJNI.Classic_method(ptr, object, ptr, object, ptr, object, ptr, object, ptr, object, ptr, object);
|
||||
java_pgcppJNI.Classic_methodconst(ptr, object, ptr, object, ptr, object, ptr, object, ptr, object, ptr, object);
|
||||
|
||||
java_pgcppJNI.function(ptr, object, ptr, object, ptr, object, ptr, object, ptr, object);
|
||||
java_pgcppJNI.functionconst(ptr, object, ptr, object, ptr, object, ptr, object, ptr, object);
|
||||
}
|
||||
}
|
||||
|
||||
36
Examples/test-suite/java_pgcpp.i
Normal file
36
Examples/test-suite/java_pgcpp.i
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
// Test the premature garbage collection prevention parameter (pgcpp) for the different ways of passing objects
|
||||
|
||||
%module java_pgcpp
|
||||
|
||||
%pragma(java) jniclassclassmodifiers="public class"
|
||||
|
||||
%typemap(javacode) Space::Classic %{
|
||||
public long getCPtrValue() {
|
||||
return this.swigCPtr;
|
||||
}
|
||||
%}
|
||||
|
||||
// Default pointer to pointer typemaps do not use proxy class, so make sure that the pgcpp is generated for these typemaps
|
||||
%typemap(jni) Space::Classic ** "jlong"
|
||||
%typemap(jtype) Space::Classic ** "long"
|
||||
%typemap(jstype) Space::Classic ** " Classic "
|
||||
%typemap(javain) Space::Classic ** "Classic.getCPtr($javainput)"
|
||||
|
||||
// Default typemaps for pass by value, ref, pointer and pointer reference should use pgcpp
|
||||
|
||||
%inline %{
|
||||
namespace Space {
|
||||
struct Classic {
|
||||
Classic() {}
|
||||
Classic(Classic c1, Classic& c2, Classic* c3, Classic*& c4, Classic** c5) {}
|
||||
Classic(const Classic c1, const Classic& c2, const Classic* c3, const Classic*& c4, const Classic** c5, bool b) {}
|
||||
|
||||
void method(Classic c1, Classic& c2, Classic* c3, Classic*& c4, Classic** c5) {}
|
||||
void methodconst(const Classic c1, const Classic& c2, const Classic* c3, const Classic*& c4, const Classic** c5) {}
|
||||
};
|
||||
|
||||
void function(Classic c1, Classic& c2, Classic* c3, Classic*& c4, Classic** c5) {}
|
||||
void functionconst(const Classic c1, const Classic& c2, const Classic* c3, const Classic*& c4, const Classic** c5) {}
|
||||
}
|
||||
%}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue