summaryrefslogtreecommitdiffstats
path: root/src/java/com
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2023-06-19 15:18:42 +0200
committerSven Gothel <[email protected]>2023-06-19 15:18:42 +0200
commit32db4ef66cacc4a6f01bd6b36f8cda96acb7ed38 (patch)
treedbdee2ed0247d854fab4bf28acd10274726f5f82 /src/java/com
parent49e5000347543559867a45f1d1b330b6086d7a32 (diff)
GlueGen Type: Use virt getTargetType() for ArrayType dropping getElementType(); Rename getBase{Elem ->}Type() to align with getTargetType()
Diffstat (limited to 'src/java/com')
-rw-r--r--src/java/com/jogamp/gluegen/CMethodBindingEmitter.java8
-rw-r--r--src/java/com/jogamp/gluegen/JavaEmitter.java16
-rw-r--r--src/java/com/jogamp/gluegen/MethodBinding.java4
-rw-r--r--src/java/com/jogamp/gluegen/cgram/types/ArrayType.java9
-rw-r--r--src/java/com/jogamp/gluegen/cgram/types/PointerType.java8
-rw-r--r--src/java/com/jogamp/gluegen/cgram/types/StructLayout.java2
-rw-r--r--src/java/com/jogamp/gluegen/cgram/types/Type.java9
7 files changed, 30 insertions, 26 deletions
diff --git a/src/java/com/jogamp/gluegen/CMethodBindingEmitter.java b/src/java/com/jogamp/gluegen/CMethodBindingEmitter.java
index caeede8..a7de97d 100644
--- a/src/java/com/jogamp/gluegen/CMethodBindingEmitter.java
+++ b/src/java/com/jogamp/gluegen/CMethodBindingEmitter.java
@@ -525,7 +525,7 @@ public class CMethodBindingEmitter extends FunctionEmitter {
if (arrt == null) {
throw new IllegalArgumentException("Type " + type + " should have been a pointer or array type");
}
- type = arrt.getElementType();
+ type = arrt.getTargetType();
}
}
if (type.isVoid()) {
@@ -652,7 +652,7 @@ public class CMethodBindingEmitter extends FunctionEmitter {
}
}
} else if( cArgType.isArray() ) {
- cArgElementType = cArgType.asArray().getBaseElementType();
+ cArgElementType = cArgType.asArray().getBaseType();
cArgElementType2 = null;
} else {
cArgElementType = null;
@@ -814,7 +814,7 @@ public class CMethodBindingEmitter extends FunctionEmitter {
unit.emitln(" for (_copyIndex = 0; _copyIndex < _tmpArrayLen; ++_copyIndex) {");
unit.emitln(" _tmpObj = (*env)->GetObjectArrayElement(env, " + javaArgName + ", _copyIndex);");
emitReturnDirectBufferAddress("_tmpObj",
- cArgType.asArray().getBaseElementType().getCName(),
+ cArgType.asArray().getBaseType().getCName(),
"("+convName + "_copy + _copyIndex)",
false /* receivingIsPtrPtr */,
null);
@@ -1116,7 +1116,7 @@ public class CMethodBindingEmitter extends FunctionEmitter {
if (retType.isPointer()) {
pointerType = retType.asPointer().getTargetType();
} else {
- pointerType = retType.asArray().getBaseElementType();
+ pointerType = retType.asArray().getBaseType();
}
unit.emitln(" (*env)->SetObjectArrayElement(env, " + arrayRes + ", " + arrayIdx +
", (*env)->NewDirectByteBuffer(env, (void *)_res[" + arrayIdx + "], sizeof(" + pointerType.getCName() + ")));");
diff --git a/src/java/com/jogamp/gluegen/JavaEmitter.java b/src/java/com/jogamp/gluegen/JavaEmitter.java
index 784976a..c425c05 100644
--- a/src/java/com/jogamp/gluegen/JavaEmitter.java
+++ b/src/java/com/jogamp/gluegen/JavaEmitter.java
@@ -982,7 +982,7 @@ public class JavaEmitter implements GlueEmitter {
}
generateOffsetAndSizeArrays(javaUnit, " ", fieldName, fieldType, field, null);
} else if (fieldType.isArray()) {
- final Type baseElementType = field.getType().asArray().getBaseElementType();
+ final Type baseElementType = field.getType().asArray().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());
@@ -1229,7 +1229,7 @@ public class JavaEmitter implements GlueEmitter {
final PointerType pointerType = fieldType.asPointer();
if( null != pointerType ) {
isPointer = true;
- referencedType = pointerType.getBaseElementType();
+ referencedType = pointerType.getBaseType();
} else {
isPointer = false;
referencedType = null;
@@ -1498,7 +1498,7 @@ public class JavaEmitter implements GlueEmitter {
hasFixedTypeLen[0] = false;
}
if( null != typeIter ) {
- typeIter = typeIter.getElementType().asArray();
+ typeIter = typeIter.getTargetType().asArray();
}
}
final String cfgVal = cfg.returnedArrayLength(returnSizeLookupName);
@@ -1639,13 +1639,13 @@ public class JavaEmitter implements GlueEmitter {
constElemCount = _useFixedArrayLen[0];
ownership = Ownership.Parent; // a fixed linear array
staticElemCount = constElemCount;
- baseCElemType = arrayType.getBaseElementType();
+ baseCElemType = arrayType.getBaseType();
isPointer = false;
useGetCStringLength = false;
} else {
final PointerType pointerType = fieldType.asPointer();
final String _elemCountExpr = cfg.returnedArrayLength(returnSizeLookupName);
- baseCElemType = pointerType.getBaseElementType();
+ baseCElemType = pointerType.getBaseType();
isPointer = true;
if( 1 != pointerType.pointerDepth() ) {
final String msg = "SKIP ptr-ptr (depth "+pointerType.pointerDepth()+"): "+returnSizeLookupName +": "+fieldType;
@@ -2356,7 +2356,7 @@ public class JavaEmitter implements GlueEmitter {
targetType = cType.asPointer().getTargetType();
} else {
// t is <type>[], we need to get <type>
- targetType = cType.asArray().getBaseElementType();
+ targetType = cType.asArray().getBaseType();
}
if (cType.pointerDepth() == 2 || cType.arrayDimension() == 2) {
// Get the target type of the target type (targetType was computer earlier
@@ -2401,7 +2401,7 @@ public class JavaEmitter implements GlueEmitter {
targetType = cType.asPointer().getTargetType();
} else {
// t is <type>[], we need to get <type>
- targetType = cType.asArray().getBaseElementType();
+ targetType = cType.asArray().getBaseType();
}
// Handle Types of form pointer-to-type or array-of-type, like
@@ -2479,7 +2479,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().getBaseElementType();
+ bottomType = targetType.asArray().getBaseType();
if( GlueGen.debug() ) {
LOG.log(INFO, cType.getASTLocusTag(), "typeToJavaType(ptr-ptr.array): {0}, targetType: {1}, bottomType: {2}",
cType.getDebugString(), targetType, bottomType);
diff --git a/src/java/com/jogamp/gluegen/MethodBinding.java b/src/java/com/jogamp/gluegen/MethodBinding.java
index 42bae04..21df415 100644
--- a/src/java/com/jogamp/gluegen/MethodBinding.java
+++ b/src/java/com/jogamp/gluegen/MethodBinding.java
@@ -373,7 +373,7 @@ public class MethodBinding {
if (cRetType.isArray()) {
// Needs checking of array lengths
signatureUsesCArrays = true;
- if (cRetType.asArray().getElementType().isPrimitive()) {
+ if (cRetType.asArray().getTargetType().isPrimitive()) {
signatureUsesCPrimitivePointers = true;
}
}
@@ -415,7 +415,7 @@ public class MethodBinding {
if (cArgType.isArray()) {
// Needs checking of array lengths
signatureUsesCArrays = true;
- if (cArgType.asArray().getElementType().isPrimitive()) {
+ if (cArgType.asArray().getTargetType().isPrimitive()) {
signatureUsesCPrimitivePointers = true;
}
}
diff --git a/src/java/com/jogamp/gluegen/cgram/types/ArrayType.java b/src/java/com/jogamp/gluegen/cgram/types/ArrayType.java
index ada34f7..03cb64d 100644
--- a/src/java/com/jogamp/gluegen/cgram/types/ArrayType.java
+++ b/src/java/com/jogamp/gluegen/cgram/types/ArrayType.java
@@ -111,13 +111,14 @@ public class ArrayType extends MemoryLayoutType implements Cloneable {
@Override
public final ArrayType asArray() { return this; }
- public Type getElementType() { return elementType; }
+ @Override
+ public final Type getTargetType() { return elementType; }
public int getLength() { return length; }
public boolean hasLength() { return length >= 0; }
@Override
- public final Type getBaseElementType() {
- return elementType.getBaseElementType();
+ public final Type getBaseType() {
+ return elementType.getBaseType();
}
@Override
@@ -128,7 +129,7 @@ public class ArrayType extends MemoryLayoutType implements Cloneable {
/** Recompute the size of this array if necessary. This needs to be
done when the base element type is a compound type after layouting. */
void recomputeSize() {
- final ArrayType arrayElementType = getElementType().asArray();
+ final ArrayType arrayElementType = getTargetType().asArray();
if (arrayElementType != null) {
arrayElementType.recomputeSize();
}
diff --git a/src/java/com/jogamp/gluegen/cgram/types/PointerType.java b/src/java/com/jogamp/gluegen/cgram/types/PointerType.java
index 5707b5c..eb89500 100644
--- a/src/java/com/jogamp/gluegen/cgram/types/PointerType.java
+++ b/src/java/com/jogamp/gluegen/cgram/types/PointerType.java
@@ -124,13 +124,11 @@ public class PointerType extends Type implements Cloneable {
}
@Override
- public final Type getTargetType() {
- return targetType;
- }
+ public final Type getTargetType() { return targetType; }
@Override
- public final Type getBaseElementType() {
- return targetType.getBaseElementType();
+ public final Type getBaseType() {
+ return targetType.getBaseType();
}
@Override
diff --git a/src/java/com/jogamp/gluegen/cgram/types/StructLayout.java b/src/java/com/jogamp/gluegen/cgram/types/StructLayout.java
index 86f1ae1..62b0025 100644
--- a/src/java/com/jogamp/gluegen/cgram/types/StructLayout.java
+++ b/src/java/com/jogamp/gluegen/cgram/types/StructLayout.java
@@ -103,7 +103,7 @@ public class StructLayout {
} else if (ft.isArray()) {
final ArrayType arrayType = ft.asArray();
if(!arrayType.isLayouted()) {
- final CompoundType compoundElementType = arrayType.getBaseElementType().asCompound();
+ final CompoundType compoundElementType = arrayType.getBaseType().asCompound();
if (compoundElementType != null) {
if(!compoundElementType.isLayouted()) {
StructLayout.layout(0, compoundElementType);
diff --git a/src/java/com/jogamp/gluegen/cgram/types/Type.java b/src/java/com/jogamp/gluegen/cgram/types/Type.java
index 7ff1fed..9c881c9 100644
--- a/src/java/com/jogamp/gluegen/cgram/types/Type.java
+++ b/src/java/com/jogamp/gluegen/cgram/types/Type.java
@@ -428,7 +428,7 @@ public abstract class Type implements SemanticEqualityOp, ASTLocusTagProvider {
* </p>
*/
public final boolean isBaseTypeConst() {
- return getBaseElementType().isConst();
+ return getBaseType().isConst();
}
/** Hashcode for Types. */
@@ -568,13 +568,18 @@ public abstract class Type implements SemanticEqualityOp, ASTLocusTagProvider {
* If this is a multidimensional array or pointer method returns the bottom-most element type,
* otherwise this.
* </p>
+ * @see #getTargetType()
*/
- public Type getBaseElementType() {
+ public Type getBaseType() {
return this;
}
/**
* Helper method to returns the target type of this type, in case another type is being referenced.
+ * <p>
+ * If this is an array or pointer method returns the next target element type, otherwise this.
+ * </p>
+ * @see #getBaseType()
*/
public Type getTargetType() {
return this;