diff options
author | Mathieu Féry <[email protected]> | 2023-06-15 18:03:13 +0200 |
---|---|---|
committer | Mathieu Féry <[email protected]> | 2023-06-16 11:44:42 +0200 |
commit | d7bc10d7ff0e3a30d74c4e4c439230f3983bcfb4 (patch) | |
tree | 4b0d789720c79cfb7604fd5107971c52814470e4 /src/junit/com/jogamp | |
parent | 88309192b450e09ba16e9d72adac178c4ce47dc3 (diff) |
feat(jni): Add directive for dedicated JNI Code with CustomJNICode
Diffstat (limited to 'src/junit/com/jogamp')
8 files changed, 51 insertions, 0 deletions
diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/BaseClass.java b/src/junit/com/jogamp/gluegen/test/junit/generation/BaseClass.java index ed23f54..276b585 100644 --- a/src/junit/com/jogamp/gluegen/test/junit/generation/BaseClass.java +++ b/src/junit/com/jogamp/gluegen/test/junit/generation/BaseClass.java @@ -2256,4 +2256,8 @@ public class BaseClass extends SingletonJunitCase { model.setCtx(surfaceContext); assertAPTR(surfaceContext, model.getCtx()); } + + public void chapter14TestCustomJNICode(final Bindingtest1 binding) throws Exception { + Assert.assertEquals(Bindingtest1.FOO_VALUE, binding.getFoo()); + } } diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p1JavaEmitter.java b/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p1JavaEmitter.java index 3e19232..c7c5644 100644 --- a/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p1JavaEmitter.java +++ b/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p1JavaEmitter.java @@ -165,6 +165,14 @@ public class Test1p1JavaEmitter extends BaseClass { chapter15TestTKMixed(new Bindingtest1p1Impl()); } + /** + * Test Custom JNI Code invocation + */ + @Test + public void chapter14TestCustomJNICode() throws Exception { + chapter14TestCustomJNICode(new Bindingtest1p1Impl()); + } + public static void main(final String args[]) throws IOException { final String tstname = Test1p1JavaEmitter.class.getName(); org.junit.runner.JUnitCore.main(tstname); diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p2DynamicLibraryBundle.java b/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p2DynamicLibraryBundle.java index def7655..e4adce1 100644 --- a/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p2DynamicLibraryBundle.java +++ b/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p2DynamicLibraryBundle.java @@ -174,6 +174,14 @@ public class Test1p2DynamicLibraryBundle extends BaseClass { } /** + * Test Custom JNI Code invocation + */ + @Test + public void chapter14TestCustomJNICode() throws Exception { + chapter14TestCustomJNICode(new Bindingtest1p2Impl()); + } + + /** * Verifies unloading of the new library. */ @AfterClass diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p2ProcAddressEmitter.java b/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p2ProcAddressEmitter.java index 711f218..366d9eb 100644 --- a/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p2ProcAddressEmitter.java +++ b/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p2ProcAddressEmitter.java @@ -175,6 +175,14 @@ public class Test1p2ProcAddressEmitter extends BaseClass { } /** + * Test Custom JNI Code invocation + */ + @Test + public void chapter14TestCustomJNICode() throws Exception { + chapter14TestCustomJNICode(new Bindingtest1p2Impl()); + } + + /** * Verifies unloading of the new library. */ @AfterClass diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/test1-CustomJNICode.cfg b/src/junit/com/jogamp/gluegen/test/junit/generation/test1-CustomJNICode.cfg new file mode 100644 index 0000000..b76997d --- /dev/null +++ b/src/junit/com/jogamp/gluegen/test/junit/generation/test1-CustomJNICode.cfg @@ -0,0 +1,13 @@ +#include "test1.h" + +JNIEXPORT jobject JNICALL +com.jogamp.gluegen.test.junit.generation +Java_com_jogamp_gluegen_test_junit_generation_Bindingtest1p1_I_returnFooImpl(JNIEnv *env, jobject _unused) { + return FOO_VALUE; +} + +JNIEXPORT jobject JNICALL +com.jogamp.gluegen.test.junit.generation +Java_com_jogamp_gluegen_test_junit_generation_Bindingtest1p2_I_returnFooImpl(JNIEnv *env, jobject _unused) { + return FOO_VALUE; +}
\ No newline at end of file diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/test1-CustomJavaCode.cfg b/src/junit/com/jogamp/gluegen/test/junit/generation/test1-CustomJavaCode.cfg index 8d8f650..c210ec9 100644 --- a/src/junit/com/jogamp/gluegen/test/junit/generation/test1-CustomJavaCode.cfg +++ b/src/junit/com/jogamp/gluegen/test/junit/generation/test1-CustomJavaCode.cfg @@ -4,4 +4,9 @@ public int testDelegate(int v) { return testDelegateOrigImpl(v) + 1; } +private native int returnFooImpl(); + +public int getFoo() { + return returnFooImpl(); +}; diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/test1-common.cfg b/src/junit/com/jogamp/gluegen/test/junit/generation/test1-common.cfg index 7e9ba4a..e01f748 100644 --- a/src/junit/com/jogamp/gluegen/test/junit/generation/test1-common.cfg +++ b/src/junit/com/jogamp/gluegen/test/junit/generation/test1-common.cfg @@ -47,8 +47,11 @@ RenameJavaSymbol DEFINE_01_EXT DEFINE_01 RenameJavaSymbol testXID_EXT testXID DelegateImplementation testDelegate testDelegateOrigImpl +CustomJavaCode Bindingtest1 public int getFoo(); IncludeAs CustomJavaCode Bindingtest1p1Impl test1-CustomJavaCode.cfg +IncludeAs CustomJNICode Bindingtest1p1Impl test1-CustomJNICode.cfg IncludeAs CustomJavaCode Bindingtest1p2Impl test1-CustomJavaCode.cfg +IncludeAs CustomJNICode Bindingtest1p2Impl test1-CustomJNICode.cfg StructPackage TK_Dimension com.jogamp.gluegen.test.junit.generation EmitStruct TK_Dimension diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/test1.h b/src/junit/com/jogamp/gluegen/test/junit/generation/test1.h index 89848d7..a296585 100644 --- a/src/junit/com/jogamp/gluegen/test/junit/generation/test1.h +++ b/src/junit/com/jogamp/gluegen/test/junit/generation/test1.h @@ -36,6 +36,8 @@ typedef void * XID; // Opaque typedef XID XID_2; // Opaque, due to XID typedef void * AnonBuffer; // Non Opaque +#define FOO_VALUE 42 + // typedef XID XID_2; // Duplicate w/ compatible type (ignored) - OpenSolaris: Native gcc error // typedef int XID_2; // Duplicate w/ incompatible type ERROR |