diff options
author | Sven Gothel <[email protected]> | 2023-07-06 10:35:30 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2023-07-06 10:35:30 +0200 |
commit | 3ed3e9887c459169b807165c9df2ae2bc2990a31 (patch) | |
tree | 895211a59571e09e4128223dca2cda1bcf9a9d5c /src/junit | |
parent | 5b867d0f90a43a02e1fbd03fb1ed588a391806eb (diff) |
GlueGen JavaCallback: Remove ambiguity: Config JavaCallbackDef/JavaCallbackKey: Always define both parameter indices; emitJavaStaticCallback(): Use cbFuncBinding and cbFuncKeyIndices from callback parameter to build key
Diffstat (limited to 'src/junit')
4 files changed, 25 insertions, 22 deletions
diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/Test4JavaCallback.java b/src/junit/com/jogamp/gluegen/test/junit/generation/Test4JavaCallback.java index 8c1d726..bc04977 100644 --- a/src/junit/com/jogamp/gluegen/test/junit/generation/Test4JavaCallback.java +++ b/src/junit/com/jogamp/gluegen/test/junit/generation/Test4JavaCallback.java @@ -446,7 +446,7 @@ public class Test4JavaCallback extends BaseClass { Assert.assertEquals(0, bt2.getAlBufferCallback1Keys().size()); // 1st mapping: buffer1 -> myCallback01, myUserParam01 - bt2.alBufferCallback1(buffer1, 0, 0, myCallback01, myUserParam01); + bt2.alBufferCallback1(myUserParam01, buffer1, 0, 0, myCallback01); Assert.assertEquals(true, bt2.isAlBufferCallback1Mapped(buffer1Key)); Assert.assertEquals(false, bt2.isAlBufferCallback1Mapped(buffer2Key)); Assert.assertEquals(false, bt2.isAlBufferCallback1Mapped(buffer3Key)); @@ -465,7 +465,7 @@ public class Test4JavaCallback extends BaseClass { } // 2nd mapping: buffer2 -> myCallback02, myUserParam02 - bt2.alBufferCallback1(buffer2, 0, 0, myCallback02, myUserParam02); + bt2.alBufferCallback1(myUserParam02, buffer2, 0, 0, myCallback02); Assert.assertEquals(true, bt2.isAlBufferCallback1Mapped(buffer1Key)); Assert.assertEquals(true, bt2.isAlBufferCallback1Mapped(buffer2Key)); Assert.assertEquals(false, bt2.isAlBufferCallback1Mapped(buffer3Key)); @@ -512,7 +512,7 @@ public class Test4JavaCallback extends BaseClass { } // Switch the callback function for buffer2 -> myCallback01, myUserParam02 - bt2.alBufferCallback1(buffer2, 0, 0, myCallback01, myUserParam02); + bt2.alBufferCallback1(myUserParam02, buffer2, 0, 0, myCallback01); Assert.assertEquals(true, bt2.isAlBufferCallback1Mapped(buffer1Key)); Assert.assertEquals(true, bt2.isAlBufferCallback1Mapped(buffer2Key)); Assert.assertEquals(false, bt2.isAlBufferCallback1Mapped(buffer3Key)); @@ -552,7 +552,7 @@ public class Test4JavaCallback extends BaseClass { } // Just release the buffer2 callback and mapped resources - bt2.alBufferCallback1(buffer2, 0, 0, null, myUserParam02); // usrptr is not key, only buffer is key! + bt2.alBufferCallback1(myUserParam02, buffer2, 0, 0, null); // usrptr is not key, only buffer is key! Assert.assertEquals(true, bt2.isAlBufferCallback1Mapped(buffer1Key)); Assert.assertEquals(false, bt2.isAlBufferCallback1Mapped(buffer2Key)); Assert.assertEquals(false, bt2.isAlBufferCallback1Mapped(buffer3Key)); @@ -571,7 +571,7 @@ public class Test4JavaCallback extends BaseClass { } // Just release the buffer1 callback and mapped resources - bt2.alBufferCallback1(buffer1, 0, 0, null, null); // usrptr is not key, only buffer is key! + bt2.alBufferCallback1(null, buffer1, 0, 0, null); // usrptr is not key, only buffer is key! Assert.assertEquals(false, bt2.isAlBufferCallback1Mapped(buffer1Key)); Assert.assertEquals(false, bt2.isAlBufferCallback1Mapped(buffer2Key)); Assert.assertEquals(false, bt2.isAlBufferCallback1Mapped(buffer3Key)); diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/test2.c b/src/junit/com/jogamp/gluegen/test/junit/generation/test2.c index 28fb3aa..dafad7c 100644 --- a/src/junit/com/jogamp/gluegen/test/junit/generation/test2.c +++ b/src/junit/com/jogamp/gluegen/test/junit/generation/test2.c @@ -165,7 +165,7 @@ void alBufferCallback0Inject(int buffer, int sampledata, int numbytes) { static ALBUFFERCALLBACKTYPESOFT alBufferCallback1_callback[] = { NULL, NULL, NULL, NULL, NULL }; static void* alBufferCallback1_userptr[] = { NULL, NULL, NULL, NULL, NULL }; -void alBufferCallback1(int buffer /* key */, int format, int freq, ALBUFFERCALLBACKTYPESOFT callback, void *userptr) { +void alBufferCallback1(void* userptr, int buffer /* key */, int format, int freq, ALBUFFERCALLBACKTYPESOFT callback) { if( buffer < 0 || MAX_AL_BUFFER <= buffer ) { fprintf(stderr, "Error: alBufferCallback1: buffer not in range [0..%d), is %d\n", MAX_AL_BUFFER, buffer); } else { diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/test2.cfg b/src/junit/com/jogamp/gluegen/test/junit/generation/test2.cfg index 08194e6..d4ea72d 100644 --- a/src/junit/com/jogamp/gluegen/test/junit/generation/test2.cfg +++ b/src/junit/com/jogamp/gluegen/test/junit/generation/test2.cfg @@ -67,14 +67,14 @@ ArgumentIsString InjectMessageCallback01 1 # - `T2_CallbackFunc01 getMessageCallback01()` returns the global T2_CallbackFunc01, null if not mapped # - `Object getMessageCallback01UserParam()` returns the global `usrParam` object, null if not mapped # - `void releaseMessageCallback01()` releases callback data skipping toolkit API. Favor passing `null` callback ref to `MessageCallback01(..)` -JavaCallbackDef MessageCallback01 T2_CallbackFunc01 2 +JavaCallbackDef MessageCallback01 1 T2_CallbackFunc01 2 # # End JavaCallback # Begin JavaCallback. # # typedef void ( * ALEVENTPROCSOFT)(int eventType, int object, int param, int length, const char *message, void *userParam); -# void alEventCallback(ALEVENTPROCSOFT callback, void *userParam /* identity-key */); +# void alEventCallback(ALEVENTPROCSOFT callback, void *userParam); # void alEventCallbackInject(int eventType, int object, int param, const char* msg); ArgumentIsPascalString ALEVENTPROCSOFT 3 4 ArgumentIsString alEventCallbackInject 3 @@ -93,17 +93,17 @@ ArgumentIsString alEventCallbackInject 3 # - `ALEVENTPROCSOFT getAlEventCallback()` returns the global ALEVENTPROCSOFT, null if not mapped # - `Object getAlEventCallbackUserParam()` returns the global `userParam` object, null if not mapped # - `void releaseAlEventCallback()` releases callback data skipping toolkit API. Favor passing `null` callback ref to `alEventCallback(..)` -JavaCallbackDef alEventCallback ALEVENTPROCSOFT 5 -JavaCallbackKey alEventCallback +JavaCallbackDef alEventCallback 1 ALEVENTPROCSOFT 5 +# JavaCallbackKey alEventCallback 1 ALEVENTPROCSOFT 5 # # End JavaCallback # Begin JavaCallback (OpanAL AL_SOFT_callback_buffer) # -# // typedef void ( * ALBUFFERCALLBACKTYPESOFT)(int buffer, void *userptr, void *sampledata, int numbytes); -# typedef void ( * ALBUFFERCALLBACKTYPESOFT)(int buffer, void *userptr, int sampledata, int numbytes); +# // typedef void ( * ALBUFFERCALLBACKTYPESOFT)(int buffer /* key */, void *userptr, void *sampledata, int numbytes); +# typedef void ( * ALBUFFERCALLBACKTYPESOFT)(int buffer /* key */, void *userptr, int sampledata, int numbytes); # -# void alBufferCallback0(int buffer /* key */, int format, int freq, ALBUFFERCALLBACKTYPESOFT callback, void *userptr /* identity-key */); +# void alBufferCallback0(int buffer /* key */, int format, int freq, ALBUFFERCALLBACKTYPESOFT callback, void *userptr); # # // void alBufferCallback0Inject(int buffer, void *sampledata, int numbytes); # void alBufferCallback0Inject(int buffer, int sampledata, int numbytes); @@ -124,8 +124,8 @@ JavaCallbackKey alEventCallback # - `Object getAlBufferCallback0UserParam(AlBufferCallback0Key)` returns the `buffer` mapped `userptr` object, null if not mapped # - `void releaseAllAlBufferCallback0()` releases all callback data mapped via Key { int buffer } skipping toolkit API. Favor passing `null` callback ref to `alBufferCallback0(..)` # - `void releaseAlBufferCallback0(AlBufferCallback0Key)` releases callback data mapped to Key { int buffer } skipping toolkit API. Favor passing `null` callback ref to `alBufferCallback0(..)` -JavaCallbackDef alBufferCallback0 ALBUFFERCALLBACKTYPESOFT 1 -JavaCallbackKey alBufferCallback0 0 +JavaCallbackDef alBufferCallback0 4 ALBUFFERCALLBACKTYPESOFT 1 +JavaCallbackKey alBufferCallback0 0 ALBUFFERCALLBACKTYPESOFT 0 # # End JavaCallback @@ -133,7 +133,10 @@ JavaCallbackKey alBufferCallback0 0 # # Reuses: ALBUFFERCALLBACKTYPESOFT, see above. # -# void alBufferCallback1(int buffer /* key */, int format, int freq, ALBUFFERCALLBACKTYPESOFT callback, void *userptr /* identity-key */); +# // typedef void ( * ALBUFFERCALLBACKTYPESOFT)(int buffer /* key */, void *userptr, void *sampledata, int numbytes); +# typedef void ( * ALBUFFERCALLBACKTYPESOFT)(int buffer /* key */, void *userptr, int sampledata, int numbytes); +# +# void alBufferCallback1(void* user_ptr, int buffer_key /* key */, int format, int freq, ALBUFFERCALLBACKTYPESOFT callback); # # // void alBufferCallback1Inject(int buffer, void *sampledata, int numbytes); # void alBufferCallback1Inject(int buffer, int sampledata, int numbytes); @@ -151,8 +154,8 @@ JavaCallbackKey alBufferCallback0 0 # - `boolean isAlBufferCallback1Mapped(int buffer)` queries whether `alBufferCallback1` is mapped to `buffer`. # - `ALBUFFERCALLBACKTYPESOFT getAlBufferCallback1(int buffer)` returns the `buffer` mapped ALEVENTPROCSOFT, null if not mapped # - `Object getAlBufferCallback1UserParam(int buffer)` returns the `buffer` mapped `userptr` object, null if not mapped -JavaCallbackDef alBufferCallback1 ALBUFFERCALLBACKTYPESOFT 1 com.jogamp.gluegen.test.junit.generation.Test4JavaCallback.CustomAlBufferCallback1Key -JavaCallbackKey alBufferCallback1 0 +JavaCallbackDef alBufferCallback1 0 ALBUFFERCALLBACKTYPESOFT 1 com.jogamp.gluegen.test.junit.generation.Test4JavaCallback.CustomAlBufferCallback1Key +JavaCallbackKey alBufferCallback1 1 ALBUFFERCALLBACKTYPESOFT 0 # # End JavaCallback @@ -162,15 +165,15 @@ JavaCallbackKey alBufferCallback1 0 # void MessageCallback11a(size_t id /* key */, T2_CallbackFunc11 cbFunc, const T2_Callback11UserType* usrParam); # void MessageCallback11aInject(size_t id); #JavaCallbackDef MessageCallback11a T2_CallbackFunc11 1 com.jogamp.gluegen.test.junit.generation.Test4JavaCallback.CustomMessageCallback11Key -JavaCallbackDef MessageCallback11a T2_CallbackFunc11 1 -JavaCallbackKey MessageCallback11a 0 +JavaCallbackDef MessageCallback11a 2 T2_CallbackFunc11 1 +JavaCallbackKey MessageCallback11a 0 T2_CallbackFunc11 0 # # End JavaCallback # void MessageCallback11b(size_t id /* key */, T2_CallbackFunc11 cbFunc, void* Data); # void MessageCallback11bInject(size_t id); JavaCallbackDef MessageCallback11b 2 T2_CallbackFunc11 1 -JavaCallbackKey MessageCallback11b 0 +JavaCallbackKey MessageCallback11b 0 T2_CallbackFunc11 0 CustomCCode #include "test2.h" diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/test2.h b/src/junit/com/jogamp/gluegen/test/junit/generation/test2.h index 183f905..dea6d72 100644 --- a/src/junit/com/jogamp/gluegen/test/junit/generation/test2.h +++ b/src/junit/com/jogamp/gluegen/test/junit/generation/test2.h @@ -84,7 +84,7 @@ void alBufferCallback0(int buffer /* key */, int format, int freq, ALBUFFERCALLB // void alBufferCallback0Inject(int buffer, void *sampledata, int numbytes); void alBufferCallback0Inject(int buffer, int sampledata, int numbytes); -void alBufferCallback1(int buffer /* key */, int format, int freq, ALBUFFERCALLBACKTYPESOFT callback, void *userptr); +void alBufferCallback1(void* user_ptr, int buffer_key /* key */, int format, int freq, ALBUFFERCALLBACKTYPESOFT callback); // void alBufferCallback1Inject(int buffer, void *sampledata, int numbytes); void alBufferCallback1Inject(int buffer, int sampledata, int numbytes); |