summaryrefslogtreecommitdiffstats
path: root/src/java/com
diff options
context:
space:
mode:
authorMathieu Féry <[email protected]>2023-08-04 10:50:10 +0200
committerMathieu Féry <[email protected]>2023-08-04 10:52:05 +0200
commitb08c61935daa0191f4ec59c6998bc56dae18e54d (patch)
tree61713f0bdad677c61ea22e90583f67c1c2e5fa83 /src/java/com
parentfe21c87b24842d67df686b7c48fa36ed65a9afc9 (diff)
feat(callbackGenerator): Prevent generation of CallBack interface if setter related isn't present
Diffstat (limited to 'src/java/com')
-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 576e9bc..a4260e7 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