aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/com/jogamp/gluegen/JavaEmitter.java
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2023-06-23 06:31:56 +0200
committerSven Gothel <[email protected]>2023-06-23 06:31:56 +0200
commit9e61409658358834c2ba26c69c3efcbb5755c128 (patch)
tree4fec6e32d6f7b5a11a7a46e2dde0a3de6495f56c /src/java/com/jogamp/gluegen/JavaEmitter.java
parentf90a42bd693ab9d451902e69ad86359fae2510dc (diff)
GlueGen: Type: Have get{Base,Target}Type() stop at isFunctionPointer(), enhance API doc; Add getArrayBaseOrPointerTargetType() and getTargetFunction()
Added getArrayBaseOrPointerTargetType() returns getBaseType() for arrays or getTargetType() for pointer, i.e. stops traversing if an elementType is a pointer and returns the elementType as target-type. This resolves 'int* intPtrArray[10]', but also simplifies all cases of 'int** intPtrPtr' and 'int intPtr[10]' etc. Since get{Base,Target}Type() returns the functionPointer, getTargetFunction() allows to retrieve the actual target function type.
Diffstat (limited to 'src/java/com/jogamp/gluegen/JavaEmitter.java')
-rw-r--r--src/java/com/jogamp/gluegen/JavaEmitter.java28
1 files changed, 8 insertions, 20 deletions
diff --git a/src/java/com/jogamp/gluegen/JavaEmitter.java b/src/java/com/jogamp/gluegen/JavaEmitter.java
index 0bf5725..110bf50 100644
--- a/src/java/com/jogamp/gluegen/JavaEmitter.java
+++ b/src/java/com/jogamp/gluegen/JavaEmitter.java
@@ -983,7 +983,7 @@ public class JavaEmitter implements GlueEmitter {
}
generateOffsetAndSizeArrays(javaUnit, " ", fieldName, fieldType, field, null);
} else if (fieldType.isArray()) {
- final Type baseElementType = field.getType().asArray().getBaseType();
+ final Type baseElementType = fieldType.getBaseType();
if( GlueGen.debug() ) {
System.err.printf("SE.os.%02d: %s / %s, %s (%s)%n", (i+1), field, cfgFieldName1, fieldType.getDebugString(), "array");
System.err.printf("SE.os.%02d: baseType %s%n", (i+1), baseElementType.getDebugString());
@@ -1249,11 +1249,11 @@ public class JavaEmitter implements GlueEmitter {
isArray = false;
referencedType = null;
relationship = "being";
- } else if( fieldType.pointerDepth() > 0 ) {
+ } else if( fieldType.isPointer() ) {
isArray = true;
referencedType = fieldType.getBaseType();
relationship = "referencing";
- } else if( fieldType.arrayDimension() > 0 ) {
+ } else if( fieldType.isArray() ) {
isArray = true;
referencedType = null;
relationship = "being";
@@ -2390,14 +2390,8 @@ public class JavaEmitter implements GlueEmitter {
if (info != null) {
boolean isPointerPointer = false;
if (cType.pointerDepth() > 0 || cType.arrayDimension() > 0) {
- Type targetType; // target type
- if (cType.isPointer()) {
- // t is <type>*, we need to get <type>
- targetType = cType.asPointer().getTargetType();
- } else {
- // t is <type>[], we need to get <type>
- targetType = cType.asArray().getBaseType();
- }
+ // t is `<type>*`, `<type>[]` or `<type>[][]`, we need to get <type>
+ final Type targetType = cType.getArrayBaseOrPointerTargetType();
if (cType.pointerDepth() == 2 || cType.arrayDimension() == 2) {
// Get the target type of the target type (targetType was computer earlier
// as to be a pointer to the target type, so now we need to get its
@@ -2435,14 +2429,8 @@ public class JavaEmitter implements GlueEmitter {
} else if (cType.isVoid()) {
return javaType(Void.TYPE);
} else if (cType.pointerDepth() > 0 || cType.arrayDimension() > 0) {
- Type targetType; // target type
- if (cType.isPointer()) {
- // t is <type>*, we need to get <type>
- targetType = cType.asPointer().getTargetType();
- } else {
- // t is <type>[], we need to get <type>
- targetType = cType.asArray().getBaseType();
- }
+ // <type>[][]
+ final Type targetType = cType.getArrayBaseOrPointerTargetType();
// Handle Types of form pointer-to-type or array-of-type, like
// char* or int[]; these are expanded out into Java primitive
@@ -2521,7 +2509,7 @@ public class JavaEmitter implements GlueEmitter {
return JavaType.forNIOPointerBufferClass();
} else if(targetType.isArray()) {
// t is<type>[][], targetType is <type>[], we need to get <type>
- bottomType = targetType.asArray().getBaseType();
+ bottomType = targetType.getBaseType();
if( GlueGen.debug() ) {
LOG.log(INFO, cType.getASTLocusTag(), "typeToJavaType(ptr-ptr.array): {0}, targetType: {1}, bottomType: {2}",
cType.getDebugString(), targetType.getDebugString(), bottomType.getDebugString());