From 2abb40b0ca9a6a06bdbe3e66b4235301ed15c693 Mon Sep 17 00:00:00 2001 From: Mathieu Féry Date: Fri, 4 Aug 2023 19:37:14 +0200 Subject: wip(test_case): Example of test case for issue related of 927bbc7160a812bb29c0e7120d4a3009bfb13bbf Almost done --- .../com/jogamp/gluegen/JavaCallbackEmitter.java | 2 + src/java/com/jogamp/gluegen/JavaConfiguration.java | 10 ++++ src/java/com/jogamp/gluegen/JavaEmitter.java | 70 ++++++++++++---------- 3 files changed, 51 insertions(+), 31 deletions(-) (limited to 'src/java/com/jogamp') diff --git a/src/java/com/jogamp/gluegen/JavaCallbackEmitter.java b/src/java/com/jogamp/gluegen/JavaCallbackEmitter.java index 01ffe8f..3359c1c 100644 --- a/src/java/com/jogamp/gluegen/JavaCallbackEmitter.java +++ b/src/java/com/jogamp/gluegen/JavaCallbackEmitter.java @@ -348,6 +348,8 @@ public final class JavaCallbackEmitter { } private final void emitJavaKeyClass(final CodeUnit unit) { + if( cfg.shouldIgnoreInInterface(KeyClassName) ) return; + emitJavaBriefAPIDoc(unit, "", "", "", "for "); unit.emitln(" public static class "+KeyClassName+" {"); binding.forEachParameter( ( final int idx, final int consumedCount, final Type cType, final JavaType jType, final String name ) -> { diff --git a/src/java/com/jogamp/gluegen/JavaConfiguration.java b/src/java/com/jogamp/gluegen/JavaConfiguration.java index 107b8c3..870b708 100644 --- a/src/java/com/jogamp/gluegen/JavaConfiguration.java +++ b/src/java/com/jogamp/gluegen/JavaConfiguration.java @@ -1808,23 +1808,33 @@ public class JavaConfiguration { final Set parsedEnumNames = parser.getParsedEnumNames(); final Set parsedFuncNames = parser.getParsedFunctionNames(); + final Set parsedInnerInterfaces = parser.getParsedInnerInterfacesNames(); + final Set parsedInnerClasses = parser.getParsedInnerClassesNames(); if(forInterface) { if(onlyList) { extendedIntfSymbolsOnly.addAll(parsedEnumNames); extendedIntfSymbolsOnly.addAll(parsedFuncNames); + extendedIntfSymbolsOnly.addAll(parsedInnerInterfaces); + extendedIntfSymbolsOnly.addAll(parsedInnerClasses); } else { extendedIntfSymbolsIgnore.addAll(parsedEnumNames); extendedIntfSymbolsIgnore.addAll(parsedFuncNames); + extendedIntfSymbolsIgnore.addAll(parsedInnerInterfaces); + extendedIntfSymbolsIgnore.addAll(parsedInnerClasses); } } if(forImplementation) { if(onlyList) { extendedImplSymbolsOnly.addAll(parsedEnumNames); extendedImplSymbolsOnly.addAll(parsedFuncNames); + extendedImplSymbolsOnly.addAll(parsedInnerInterfaces); + extendedImplSymbolsOnly.addAll(parsedInnerClasses); } else { extendedImplSymbolsIgnore.addAll(parsedEnumNames); extendedImplSymbolsIgnore.addAll(parsedFuncNames); + extendedImplSymbolsIgnore.addAll(parsedInnerInterfaces); + extendedImplSymbolsIgnore.addAll(parsedInnerClasses); } } } diff --git a/src/java/com/jogamp/gluegen/JavaEmitter.java b/src/java/com/jogamp/gluegen/JavaEmitter.java index 0936536..6e79b6c 100644 --- a/src/java/com/jogamp/gluegen/JavaEmitter.java +++ b/src/java/com/jogamp/gluegen/JavaEmitter.java @@ -1494,11 +1494,17 @@ public class JavaEmitter implements GlueEmitter { LOG.log(INFO, "JavaCallbackInfo: Reusing {0} -> {1}", jcbd.setFuncName, jcbi0); } else { final StringBuilder cbMethodSignature = new StringBuilder(); - javaUnit.emitln(" /** JavaCallback interface: "+jcbd.cbFuncTypeName+" -> "+funcType.toString(jcbd.cbFuncTypeName, false, true)+" */"); - javaUnit.emitln(" public static interface "+cbSimpleClazzName+" {"); - final List mbs = generateFunctionInterfaceCode(javaUnit, funcSym, jcbd, cbMethodSignature); - javaUnit.emitln(" }"); - javaUnit.emitln(); + final List mbs; + if( !cfg.shouldIgnoreInInterface(jcbd.cbFuncTypeName) ) { + javaUnit.emitln(" /** JavaCallback interface: "+jcbd.cbFuncTypeName+" -> "+funcType.toString(jcbd.cbFuncTypeName, false, true)+" */"); + javaUnit.emitln(" public static interface "+cbSimpleClazzName+" {"); + mbs = generateFunctionInterfaceCode(javaUnit, funcSym, jcbd, cbMethodSignature); + javaUnit.emitln(" }"); + javaUnit.emitln(); + } else { + LOG.log(WARNING, "JavaCallbackInfo: Java Configuration indicate current JavaCallback must be ignored so assume JavaCallback meet presents requirements of {0}", jcbd.setFuncName); + mbs = generateFunctionInterfaceCode(null, funcSym, jcbd, cbMethodSignature); + } if( 1 != mbs.size() ) { throw new UnsupportedOperationException("Multiple bindings generated where only 1 is allowed for func "+funcType.toString(jcbd.cbFuncTypeName, false, true)); } @@ -1508,9 +1514,9 @@ public class JavaEmitter implements GlueEmitter { cbFuncBinding.getJavaReturnType()+", func "+funcType.toString(jcbd.cbFuncTypeName, false, true)); } final JavaCallbackInfo jcbi1 = new JavaCallbackInfo(jcbd.cbFuncTypeName, cbSimpleClazzName, cbFQClazzName, cbMethodSignature.toString(), - funcType, cbFuncBinding, jcbd.cbFuncUserParamIdx, jcbd.cbFuncKeyIndices, - jcbd.setFuncName, jcbd.setFuncUserParamIdx, jcbd.setFuncKeyIndices, - jcbd.userParamClassName, jcbd.customKeyClassName); + funcType, cbFuncBinding, jcbd.cbFuncUserParamIdx, jcbd.cbFuncKeyIndices, + jcbd.setFuncName, jcbd.setFuncUserParamIdx, jcbd.setFuncKeyIndices, + jcbd.userParamClassName, jcbd.customKeyClassName); cfg.setFuncToJavaCallbackMap.put(jcbd.setFuncName, jcbi1); javaCallbackInterfaceMap.put(cbFQClazzName, jcbi1); LOG.log(INFO, "JavaCallbackInfo: Added {0} -> {1}", jcbd.setFuncName, jcbi1); @@ -1556,29 +1562,31 @@ public class JavaEmitter implements GlueEmitter { final boolean useNIOOnly = true; final boolean useNIODirectOnly = true; - for (final MethodBinding binding : bindings) { - // Emit public Java entry point for calling this function pointer - final JavaMethodBindingEmitter emitter = new JavaMethodBindingEmitter(binding, - javaUnit, - cfg.runtimeExceptionType(), - cfg.unsupportedExceptionType(), - false, // emitBody - cfg.tagNativeBinding(), - false, // eraseBufferAndArrayTypes - useNIOOnly, - useNIODirectOnly, - false, // forDirectBufferImplementation - false, // forIndirectBufferAndArrayImplementation - true, // isUnimplemented - true, // isInterface - false, // isNativeMethod - false, // isPrivateNativeMethod - cfg) { - @Override - protected String getBaseIndentString() { return " "; } - }; - emitter.addModifier(JavaMethodBindingEmitter.PUBLIC); - emitter.emit(); + if( null != javaUnit) { + for (final MethodBinding binding : bindings) { + // Emit public Java entry point for calling this function pointer + final JavaMethodBindingEmitter emitter = new JavaMethodBindingEmitter(binding, + javaUnit, + cfg.runtimeExceptionType(), + cfg.unsupportedExceptionType(), + false, // emitBody + cfg.tagNativeBinding(), + false, // eraseBufferAndArrayTypes + useNIOOnly, + useNIODirectOnly, + false, // forDirectBufferImplementation + false, // forIndirectBufferAndArrayImplementation + true, // isUnimplemented + true, // isInterface + false, // isNativeMethod + false, // isPrivateNativeMethod + cfg) { + @Override + protected String getBaseIndentString() { return " "; } + }; + emitter.addModifier(JavaMethodBindingEmitter.PUBLIC); + emitter.emit(); + } } return bindings; } -- cgit v1.2.3