aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2023-06-29 02:06:00 +0200
committerSven Gothel <[email protected]>2023-06-29 02:06:00 +0200
commit9be1305636daa633a7219e102b22a4ffcf277690 (patch)
tree3e44a8f880162c3e9de745c7b069f830513e9d23 /src
parent58712fb3a386ca6327b71218bab6e4b218da36a8 (diff)
GlueGen Struct [17]: Handle void pointers, i.e. `void*`, within a struct as `Opaque` configured pointer-types
.. includes cross-ref'ed doc and unit test
Diffstat (limited to 'src')
-rw-r--r--src/java/com/jogamp/gluegen/JavaEmitter.java15
-rw-r--r--src/junit/com/jogamp/gluegen/test/junit/generation/Test2FuncPtr.java6
2 files changed, 11 insertions, 10 deletions
diff --git a/src/java/com/jogamp/gluegen/JavaEmitter.java b/src/java/com/jogamp/gluegen/JavaEmitter.java
index f0bc8c7..3a86239 100644
--- a/src/java/com/jogamp/gluegen/JavaEmitter.java
+++ b/src/java/com/jogamp/gluegen/JavaEmitter.java
@@ -1741,8 +1741,11 @@ public class JavaEmitter implements GlueEmitter {
final String baseElemSizeDenominator;
final boolean useGetCStringLength;
final boolean maxOneElement; // zero or one element
- if( isOpaque && opaqueTypeInfo.pointerDepth() <= 1 || ( fieldType.isPrimitive() && !baseElemType.isFunctionPointer() ) ) {
- // Overridden by JavaConfiguration.typeInfo(..), i.e. Opaque!
+ if( isOpaque && opaqueTypeInfo.pointerDepth() <= 1 || // explicit 'Opaque' (config)
+ ( fieldType.isPrimitive() && !baseElemType.isFunctionPointer() ) || // a primitive and non-function-ptr
+ ( fieldType.isPointer() && baseElemType.isVoid() ) // like 'void*' -> 'void'
+ )
+ {
// Emulating array w/ 1 element
isPrimitive = true;
isPointer = false;
@@ -1837,14 +1840,6 @@ public class JavaEmitter implements GlueEmitter {
if( GlueGen.debug() ) {
System.err.printf("SE.ac.%02d: ownership %s%n", (i+1), ownership);
}
-
- if( !baseElemType.hasSize() ) { // like 'void*' -> 'void'
- final String msg = "SKIP unsized field in struct: "+fqStructFieldName+": fieldType "+fieldType.getSignature(null).toString()+", baseType "+baseElemType.getSignature(null).toString();
- unit.emitln(" // "+msg);
- unit.emitln();
- LOG.log(WARNING, structCType.getASTLocusTag(), msg);
- return;
- }
baseIsPointer = baseElemType.isPointer();
isConstValue = baseElemType.isConst();
if( baseIsPointer ) {
diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/Test2FuncPtr.java b/src/junit/com/jogamp/gluegen/test/junit/generation/Test2FuncPtr.java
index 3503fa3..cf32eb7 100644
--- a/src/junit/com/jogamp/gluegen/test/junit/generation/Test2FuncPtr.java
+++ b/src/junit/com/jogamp/gluegen/test/junit/generation/Test2FuncPtr.java
@@ -96,6 +96,12 @@ public class Test2FuncPtr extends BaseClass {
Assert.assertNotEquals(0, options.getCustomFuncB1());
Assert.assertNotEquals(0, options.getCustomFuncB2());
Assert.assertEquals(1, options.getApiVersion());
+ Assert.assertEquals(1, T2_InitializeOptions.getReserved1ElemCount());
+ BaseClass.assertAPTR(0x0000CAFFEEBEEFL, options.getReserved1());
+ {
+ options.setReserved1(0xBEEFCAFFEE0DADL);
+ BaseClass.assertAPTR(0xBEEFCAFFEE0DADL, options.getReserved1());
+ }
Assert.assertEquals("Product Name", options.getProductName());
Assert.assertEquals("Product Version", options.getProductVersion());
Assert.assertEquals(0xa001, options.CustomFuncA1(0));