From 405512e1c8a2e24834b0d057f0b020b4a0f4c25b Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 11 Mar 2015 08:48:36 +0100 Subject: Bug 1144 - Add 'DelegateImplementation', manually impl. may delegate to renamed original 'DelegateImplementation' is a variation of 'ManuallyImplement'. 'ManuallyImplement' emits the interface method, but suppresses the Java and native-code implementation. The latter shall be implemented manually by the user. 'DelegateImplementation' emits the interface method, and the _private_ renamed Java and native-code implementation. Both can be called from the manual user implementation, hence delegation. Configuration: DelegateImplementation I.e. delegation model shall apply to and the Java and native-code implementation renamed to . The user manual implementation of may delegate to . --- .../com/jogamp/gluegen/test/junit/generation/BaseClass.java | 9 ++++++++- .../com/jogamp/gluegen/test/junit/generation/test1-common.cfg | 4 ++++ src/junit/com/jogamp/gluegen/test/junit/generation/test1.c | 4 ++++ src/junit/com/jogamp/gluegen/test/junit/generation/test1.h | 2 ++ 4 files changed, 18 insertions(+), 1 deletion(-) (limited to 'src/junit/com/jogamp/gluegen') 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 92015dd..75ef808 100644 --- a/src/junit/com/jogamp/gluegen/test/junit/generation/BaseClass.java +++ b/src/junit/com/jogamp/gluegen/test/junit/generation/BaseClass.java @@ -77,7 +77,7 @@ public class BaseClass extends SingletonJunitCase { * ie a compilation only coverage test without functional tests. */ public void chapter__TestCoverageSignature(final Bindingtest1 binding) throws Exception { - int i; + int i = 0; final long context = 0; LongBuffer lb=null; ByteBuffer bb=null; @@ -119,6 +119,8 @@ public class BaseClass extends SingletonJunitCase { lb = binding.testFooPtr(larray, 0); lb = binding.testFooPtr(lb); + + i = binding.testDelegate(i); } { @@ -712,6 +714,11 @@ public class BaseClass extends SingletonJunitCase { Assert.assertEquals(fooLB, foo2Out); } + { + i=41; + final int iRes = binding.testDelegate(i); + Assert.assertEquals(i+1, iRes); + } } public void chapter04TestPointerBuffer(final Bindingtest1 binding) throws Exception { 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 29c13fa..6c516c2 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 @@ -46,6 +46,10 @@ Opaque long TK_Context RenameJavaSymbol DEFINE_01_EXT DEFINE_01 RenameJavaSymbol testXID_EXT testXID +DelegateImplementation testDelegate testDelegateOrigImpl +IncludeAs CustomJavaCode Bindingtest1p1Impl test1-CustomJavaCode.cfg +IncludeAs CustomJavaCode Bindingtest1p2Impl test1-CustomJavaCode.cfg + StructPackage TK_Dimension com.jogamp.gluegen.test.junit.generation EmitStruct TK_Dimension StructPackage TK_DimensionPair com.jogamp.gluegen.test.junit.generation diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/test1.c b/src/junit/com/jogamp/gluegen/test/junit/generation/test1.c index 316603b..0683600 100644 --- a/src/junit/com/jogamp/gluegen/test/junit/generation/test1.c +++ b/src/junit/com/jogamp/gluegen/test/junit/generation/test1.c @@ -65,6 +65,10 @@ MYAPI foo MYAPIENTRY nopTest() { return 42; } +MYAPI int32_t MYAPIENTRY testDelegate(int32_t v) { + return v; +} + /** * new blob sizeof(void*) filled w/ 0xDEADBEEF */ 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 b176f3a..6e826c5 100644 --- a/src/junit/com/jogamp/gluegen/test/junit/generation/test1.h +++ b/src/junit/com/jogamp/gluegen/test/junit/generation/test1.h @@ -111,6 +111,8 @@ MYAPI foo_ptr MYAPIENTRY testFooPtr(foo_ptr v); /** Returns 42 */ MYAPI foo MYAPIENTRY nopTest(); +MYAPI int32_t MYAPIENTRY testDelegate(int32_t v); + // // Different pointer type tests .. // -- cgit v1.2.3