summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2023-07-01 19:23:14 +0200
committerSven Gothel <[email protected]>2023-07-01 19:23:14 +0200
commitdf0895828e957d97f38510da36eade7a60691d96 (patch)
tree061d73226f0e4bfc204ab200001931a544696fed /src
parent8766fcfdce4dd864fe6764b063a0f9a4b17327c1 (diff)
GlueGen JavaCallback: Use `SetCallback-KeyClass` if manually specified, even if no keys are defined!
Diffstat (limited to 'src')
-rw-r--r--src/java/com/jogamp/gluegen/JavaMethodBindingEmitter.java8
-rw-r--r--src/junit/com/jogamp/gluegen/test/junit/generation/Test4JavaCallback.java25
-rw-r--r--src/junit/com/jogamp/gluegen/test/junit/generation/test2.cfg2
3 files changed, 32 insertions, 3 deletions
diff --git a/src/java/com/jogamp/gluegen/JavaMethodBindingEmitter.java b/src/java/com/jogamp/gluegen/JavaMethodBindingEmitter.java
index 985056d..1737ba1 100644
--- a/src/java/com/jogamp/gluegen/JavaMethodBindingEmitter.java
+++ b/src/java/com/jogamp/gluegen/JavaMethodBindingEmitter.java
@@ -600,15 +600,17 @@ public class JavaMethodBindingEmitter extends FunctionEmitter {
final String lockInstanceName = lowIfaceName+"Lock";
final String dataMapInstanceName = lowIfaceName+"DataMap";
final String dataInstanceName = lowIfaceName+"Data";
- final boolean useDataMap = javaCallback.setFuncKeyIndices.size() > 0;
final boolean customKeyClass;
final String KeyClassName;
+ final boolean useDataMap;
if( null != javaCallback.setFuncKeyClassName ) {
customKeyClass = true;;
KeyClassName = javaCallback.setFuncKeyClassName;
+ useDataMap = true;
} else {
customKeyClass = false;
KeyClassName = CodeGenUtils.capitalizeString(capIfaceName+"Key");
+ useDataMap = javaCallback.setFuncKeyIndices.size() > 0;
}
final String DataClassName = CodeGenUtils.capitalizeString( javaCallback.cbFuncTypeName+"Data" );
final String fqUsrParamClassName = cfg.packageName()+"."+cfg.className()+"."+DataClassName;
@@ -943,12 +945,14 @@ public class JavaMethodBindingEmitter extends FunctionEmitter {
final String funcArgName = binding.getArgumentName(javaCallback.setFuncCBParamIdx);
final String userParamArgName = binding.getArgumentName(javaCallback.setFuncUserParamIdx);
final String DataClassName = CodeGenUtils.capitalizeString( javaCallback.cbFuncTypeName+"Data" );
- final boolean useDataMap = javaCallback.setFuncKeyIndices.size() > 0;
final String KeyClassName;
+ final boolean useDataMap;
if( null != javaCallback.setFuncKeyClassName ) {
KeyClassName = javaCallback.setFuncKeyClassName;
+ useDataMap = true;
} else {
KeyClassName = CodeGenUtils.capitalizeString(capIfaceName+"Key");
+ useDataMap = javaCallback.setFuncKeyIndices.size() > 0;
}
if( DEBUG_JAVACALLBACK ) {
unit.emitln(" System.err.println(\"ZZZ returned nativeUserParam 0x\"+Long.toHexString(nativeUserParam[0]));");
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 badd299..54a8c59 100644
--- a/src/junit/com/jogamp/gluegen/test/junit/generation/Test4JavaCallback.java
+++ b/src/junit/com/jogamp/gluegen/test/junit/generation/Test4JavaCallback.java
@@ -772,6 +772,31 @@ public class Test4JavaCallback extends BaseClass {
return "CustomALKey[this "+toHexString(System.identityHashCode(this))+", buffer "+buffer+"]";
}
}
+
+ public static class CustomMessageCallback11Key {
+ public CustomMessageCallback11Key() {
+ }
+ @Override
+ public boolean equals(final Object o) {
+ if( this == o ) {
+ return true;
+ }
+ if( !(o instanceof CustomAlBufferCallback1Key) ) {
+ return false;
+ }
+ final CustomAlBufferCallback1Key o2 = (CustomAlBufferCallback1Key)o;
+ return true;
+ }
+ @Override
+ public int hashCode() {
+ return 0;
+ }
+ @Override
+ public String toString() {
+ return "CustomMessageCallback11Key[this "+toHexString(System.identityHashCode(this))+"]";
+ }
+ }
+
static private String toHexString(final int v) { return "0x"+Integer.toHexString(v); }
public static void main(final String args[]) throws IOException {
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 812676e..472471c 100644
--- a/src/junit/com/jogamp/gluegen/test/junit/generation/test2.cfg
+++ b/src/junit/com/jogamp/gluegen/test/junit/generation/test2.cfg
@@ -162,7 +162,7 @@ JavaCallbackKey alBufferCallback1 0
# void MessageCallback11(T2_CallbackFunc11 cbFunc, const T2_Callback11UserType* usrParam);
# void InjectMessageCallback11(size_t id, const char* msg);
ArgumentIsString InjectMessageCallback11 1
-JavaCallbackDef MessageCallback11 T2_CallbackFunc11 0
+JavaCallbackDef MessageCallback11 T2_CallbackFunc11 0 com.jogamp.gluegen.test.junit.generation.Test4JavaCallback.CustomMessageCallback11Key
#
# End JavaCallback