aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/com/jogamp/gluegen/JavaConfiguration.java
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2023-06-26 11:17:22 +0200
committerSven Gothel <[email protected]>2023-06-26 11:17:22 +0200
commit4d884db4e08ce9911871d3bdcf378041cde584fd (patch)
tree2a59a33814476a7d1bf3524df572e95c06cb0777 /src/java/com/jogamp/gluegen/JavaConfiguration.java
parent68911f778039bbf08b5afbffd536b4cdacd33032 (diff)
GlueGen JavaCallback: Move JavaCallback into JavaConfiguration, accessible across *Emitter (needed for CMethodEmitter as well); Add JavaCallback.methodSignature to be passed to native function later on to find the callback jmethodID
Diffstat (limited to 'src/java/com/jogamp/gluegen/JavaConfiguration.java')
-rw-r--r--src/java/com/jogamp/gluegen/JavaConfiguration.java51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/java/com/jogamp/gluegen/JavaConfiguration.java b/src/java/com/jogamp/gluegen/JavaConfiguration.java
index c111e0c..30ccbb2 100644
--- a/src/java/com/jogamp/gluegen/JavaConfiguration.java
+++ b/src/java/com/jogamp/gluegen/JavaConfiguration.java
@@ -2223,4 +2223,55 @@ public class JavaConfiguration {
}
return true;
}
+
+ /**
+ * JavaCallback information, produced by {@link JavaEmitter#beginFunctions(TypeDictionary, TypeDictionary, Map)}
+ * from {@link Type#isFunctionPointer() function-pointer} {@link Type}s mapped to {@link JavaConfiguration#getJavaCallbackList()} names via {@link TypeDictionary} (typedef).
+ * @see JavaConfiguration#funcPtrTypeToJavaCallbackMap
+ * @see JavaConfiguration#bindingToJavaCallbackMap
+ */
+ public static class JavaCallback {
+ final String funcName;
+ final String simpleClazzName;
+ final String fqClazzName;
+ final String methodSignature;
+ final FunctionType func;
+ final int userParamIdx;
+ final Type userParamType;
+ final String userParamName;
+
+ public JavaCallback(final String funcName, final String simpleClazzName, final String fqClazzName, final String methodSignature,
+ final FunctionType func, final int userParamIdx) {
+ this.funcName = funcName;
+ this.simpleClazzName = simpleClazzName;
+ this.fqClazzName = fqClazzName;
+ this.methodSignature = methodSignature;
+ this.func = func;
+ int paramIdx = -2;
+ Type paramType = null;
+ String paramName = null;
+ if( 0 <= userParamIdx && userParamIdx < func.getNumArguments() ) {
+ final Type t = func.getArgumentType(userParamIdx);
+ if( null != t && t.isPointer() && t.getTargetType().isVoid() ) {
+ // OK 'void*'
+ paramIdx = userParamIdx;
+ paramName = func.getArgumentName(userParamIdx);
+ paramType = t;
+ }
+ }
+ this.userParamIdx = paramIdx;
+ this.userParamType = paramType;
+ this.userParamName = paramName;
+ }
+
+ @Override
+ public String toString() {
+ return String.format("JavaCallback[%s, %s%s, userParam[idx %d, '%s', %s], %s]", funcName, fqClazzName, methodSignature,
+ userParamIdx, userParamName, userParamType.getSignature(null).toString(), func.toString(funcName, false, true));
+ }
+ }
+ /** Mapped function-pointer type name to {@link JavaCallback} */
+ /* pp */ final Map<String, JavaCallback> funcPtrTypeToJavaCallbackMap = new HashMap<String, JavaCallback>();
+ /** Mapped binding name to {@link JavaCallback} */
+ /* pp */ final Map<String, JavaCallback> bindingToJavaCallbackMap = new HashMap<String, JavaCallback>();
}