aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/com/jogamp
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2023-08-04 20:46:50 +0200
committerSven Gothel <[email protected]>2023-08-04 20:46:50 +0200
commit8fcea7ef29de9036871efabcd2288b0059af5007 (patch)
tree2492a10405fedeee49ff08b5a5f88b85a7ee3921 /src/java/com/jogamp
parent6dce08b3410cf7f6a1848f814496c5e8c2e1ff73 (diff)
parentb08c61935daa0191f4ec59c6998bc56dae18e54d (diff)
Merge remote-tracking branch 'Mathieu_Fery/feature/prevent_callback_generation_if_setter_is_absent'
Diffstat (limited to 'src/java/com/jogamp')
-rw-r--r--src/java/com/jogamp/gluegen/DebugEmitter.java3
-rw-r--r--src/java/com/jogamp/gluegen/GlueEmitter.java3
-rw-r--r--src/java/com/jogamp/gluegen/GlueGen.java2
-rw-r--r--src/java/com/jogamp/gluegen/JavaEmitter.java13
-rw-r--r--src/java/com/jogamp/gluegen/procaddress/ProcAddressEmitter.java5
5 files changed, 19 insertions, 7 deletions
diff --git a/src/java/com/jogamp/gluegen/DebugEmitter.java b/src/java/com/jogamp/gluegen/DebugEmitter.java
index 9824462..8b53827 100644
--- a/src/java/com/jogamp/gluegen/DebugEmitter.java
+++ b/src/java/com/jogamp/gluegen/DebugEmitter.java
@@ -84,7 +84,8 @@ public class DebugEmitter implements GlueEmitter {
@Override
public void beginFunctions(final TypeDictionary typedefDictionary,
final TypeDictionary structDictionary,
- final Map<Type, Type> canonMap) {
+ final Map<Type, Type> canonMap,
+ List<FunctionSymbol> cFunctions) {
final Set<String> keys = typedefDictionary.keySet();
for (final String key: keys) {
final Type value = typedefDictionary.get(key);
diff --git a/src/java/com/jogamp/gluegen/GlueEmitter.java b/src/java/com/jogamp/gluegen/GlueEmitter.java
index 8844a33..6b654f1 100644
--- a/src/java/com/jogamp/gluegen/GlueEmitter.java
+++ b/src/java/com/jogamp/gluegen/GlueEmitter.java
@@ -75,7 +75,8 @@ public interface GlueEmitter {
public void beginFunctions(TypeDictionary typedefDictionary,
TypeDictionary structDictionary,
- Map<Type, Type> canonMap) throws Exception;
+ Map<Type, Type> canonMap,
+ List<FunctionSymbol> cFunctions) throws Exception;
/** Emit glue code for the list of FunctionSymbols. */
public Iterator<FunctionSymbol> emitFunctions(List<FunctionSymbol> cFunctions) throws Exception;
diff --git a/src/java/com/jogamp/gluegen/GlueGen.java b/src/java/com/jogamp/gluegen/GlueGen.java
index 872214d..5aa76f8 100644
--- a/src/java/com/jogamp/gluegen/GlueGen.java
+++ b/src/java/com/jogamp/gluegen/GlueGen.java
@@ -362,7 +362,7 @@ public class GlueGen implements GlueEmitterControls {
if ( !cfg.structsOnly() ) {
// emit java and C code to interface with the native functions
- emit.beginFunctions(td, sd, headerParser.getCanonMap());
+ emit.beginFunctions(td, sd, headerParser.getCanonMap(), allFunctions);
emit.emitFunctions(allFunctions);
emit.endFunctions();
}
diff --git a/src/java/com/jogamp/gluegen/JavaEmitter.java b/src/java/com/jogamp/gluegen/JavaEmitter.java
index fb310a9..d126215 100644
--- a/src/java/com/jogamp/gluegen/JavaEmitter.java
+++ b/src/java/com/jogamp/gluegen/JavaEmitter.java
@@ -66,6 +66,7 @@ import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Optional;
import java.util.Set;
import jogamp.common.os.MachineDataInfoRuntime;
@@ -359,7 +360,8 @@ public class JavaEmitter implements GlueEmitter {
@Override
public void beginFunctions(final TypeDictionary typedefDictionary,
final TypeDictionary structDictionary,
- final Map<Type, Type> canonMap) throws Exception {
+ final Map<Type, Type> canonMap,
+ final List<FunctionSymbol> cFunctions) throws Exception {
// this.typedefDictionary = typedefDictionary;
this.canonMap = canonMap;
@@ -371,7 +373,14 @@ public class JavaEmitter implements GlueEmitter {
for(final JavaCallbackDef jcbd : javaCallbacks) {
final Type funcPtr = typedefDictionary.get(jcbd.cbFuncTypeName);
if( null != funcPtr && funcPtr.isFunctionPointer() ) {
- generateJavaCallbackCode(jcbd, funcPtr.getTargetFunction());
+ final Optional<FunctionSymbol> setter = cFunctions.stream()
+ .filter(cFunction -> jcbd.setFuncName.equals(cFunction.getName()))
+ .findFirst();
+ if( setter.isPresent() ) {
+ generateJavaCallbackCode(jcbd, funcPtr.getTargetFunction());
+ } else {
+ LOG.log(WARNING, "JavaCallback '{0}' setter not available", jcbd);
+ }
} else {
LOG.log(WARNING, "JavaCallback '{0}' function-pointer type not available", jcbd);
}
diff --git a/src/java/com/jogamp/gluegen/procaddress/ProcAddressEmitter.java b/src/java/com/jogamp/gluegen/procaddress/ProcAddressEmitter.java
index b812416..6fb8a10 100644
--- a/src/java/com/jogamp/gluegen/procaddress/ProcAddressEmitter.java
+++ b/src/java/com/jogamp/gluegen/procaddress/ProcAddressEmitter.java
@@ -78,13 +78,14 @@ public class ProcAddressEmitter extends JavaEmitter {
protected String tableClassName;
@Override
- public void beginFunctions(final TypeDictionary typedefDictionary, final TypeDictionary structDictionary, final Map<Type, Type> canonMap) throws Exception {
+ public void beginFunctions(final TypeDictionary typedefDictionary, final TypeDictionary structDictionary,
+ final Map<Type, Type> canonMap, final List<FunctionSymbol> cFunctions) throws Exception {
this.typedefDictionary = typedefDictionary;
if (getProcAddressConfig().emitProcAddressTable()) {
beginProcAddressTable();
}
- super.beginFunctions(typedefDictionary, structDictionary, canonMap);
+ super.beginFunctions(typedefDictionary, structDictionary, canonMap, cFunctions);
}
@Override