summaryrefslogtreecommitdiffstats
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
parent8766fcfdce4dd864fe6764b063a0f9a4b17327c1 (diff)
GlueGen JavaCallback: Use `SetCallback-KeyClass` if manually specified, even if no keys are defined!
-rw-r--r--doc/GlueGen_Mapping.html12
-rw-r--r--doc/GlueGen_Mapping.md6
-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
5 files changed, 41 insertions, 12 deletions
diff --git a/doc/GlueGen_Mapping.html b/doc/GlueGen_Mapping.html
index 9520f34..aaa305b 100644
--- a/doc/GlueGen_Mapping.html
+++ b/doc/GlueGen_Mapping.html
@@ -1991,9 +1991,9 @@ specify the same key arguments when setting and removing the
``CallbackFunction`.</p>
<h4 id="javacallback-key-definition"><em>JavaCallback</em> Key
Definition</h4>
-<p>If no keys are defined via <code>JavaCallbackKey</code>, or manually
-injected using a custom <code>SetCallback-KeyClass</code>, see below,
-the <code>CallbackFunction</code> has global scope.</p>
+<p>If no keys are defined via <code>JavaCallbackKey</code> or not
+manually injected using a custom <code>SetCallback-KeyClass</code>, see
+below, the <code>CallbackFunction</code> has global scope.</p>
<p>In case keys are defined via <code>JavaCallbackKey</code> and no
manually injected custom <code>SetCallback-KeyClass</code> used, a
public <code>SetCallback-KeyClass</code> is being generated covering the
@@ -2023,8 +2023,8 @@ being generated.</p>
<p>Additional public <em>maintenance</em> methods are generated. In case
keys are being used, they expect <code>SetCallback-KeyClass</code> as an
argument, otherwise they expect no argument for global scope.</p>
-<p>In case keys are defined and hence <code>SetCallback-KeyClass</code>
-used, the additional <em>maintenance</em> methods are:</p>
+<p>In case a <code>SetCallback-KeyClass</code> is used, the additional
+<em>maintenance</em> methods are:</p>
<ul>
<li><em>Set&lt;<code>SetCallback-KeyClass</code>&gt;
get<code>SetCallbackFunctionName</code>Keys()</em></li>
@@ -2048,7 +2048,7 @@ via <code>SetCallbackFunctionName</code>.</li>
releases complete mapped <code>CallbackFunction</code> data set
associated via <code>SetCallbackFunctionName</code>.</li>
</ul>
-<p>In no keys are defined and hence global scope used, the additional
+<p>If no <code>SetCallback-KeyClass</code> is used, the additional
<em>maintenance</em> methods are:</p>
<ul>
<li><em>boolean is<code>SetCallbackFunctionName</code>Mapped()</em>
diff --git a/doc/GlueGen_Mapping.md b/doc/GlueGen_Mapping.md
index f43f7a6..b1cbee5 100644
--- a/doc/GlueGen_Mapping.md
+++ b/doc/GlueGen_Mapping.md
@@ -797,7 +797,7 @@ If mapping the `CallbackFunction` to keys, the user must specify the same key ar
#### *JavaCallback* Key Definition
-If no keys are defined via `JavaCallbackKey`, or manually injected using a custom `SetCallback-KeyClass`, see below,
+If no keys are defined via `JavaCallbackKey` or not manually injected using a custom `SetCallback-KeyClass`, see below,
the `CallbackFunction` has global scope.
In case keys are defined via `JavaCallbackKey` and no manually injected custom `SetCallback-KeyClass` used,
@@ -821,7 +821,7 @@ The public toolkit API `SetCallbackFunction` method is being generated.
Additional public *maintenance* methods are generated. In case keys are being used, they expect `SetCallback-KeyClass` as an argument, otherwise they expect no argument for global scope.
-In case keys are defined and hence `SetCallback-KeyClass` used, the additional *maintenance* methods are:
+In case a `SetCallback-KeyClass` is used, the additional *maintenance* methods are:
- *Set<`SetCallback-KeyClass`> get`SetCallbackFunctionName`Keys()*
- *boolean is`SetCallbackFunctionName`Mapped(`SetCallback-KeyClass`)* queries whether `SetCallbackFunctionName` is mapped to key.
- *`CallbackFunction` get`SetCallbackFunctionName`(`SetCallback-KeyClass`)* returns the mapped `CallbackFunction`, null if not mapped
@@ -829,7 +829,7 @@ In case keys are defined and hence `SetCallback-KeyClass` used, the additional *
- *void release`SetCallbackFunctionName`(`SetCallback-KeyClass`)* releases the mapped `CallbackFunction` data set associated via `SetCallbackFunctionName`.
- *int releaseAll`SetCallbackFunctionName`()* releases complete mapped `CallbackFunction` data set associated via `SetCallbackFunctionName`.
-In no keys are defined and hence global scope used, the additional *maintenance* methods are:
+If no `SetCallback-KeyClass` is used, the additional *maintenance* methods are:
- *boolean is`SetCallbackFunctionName`Mapped()* queries whether `SetCallbackFunctionName` is mapped.
- *`CallbackFunction` get`SetCallbackFunctionName`()* returns the mapped `CallbackFunction`, null if not mapped
- *Object get`SetCallbackFunctionName`UserParam()* returns the mapped `userParam` object, null if not mapped
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