summaryrefslogtreecommitdiffstats
path: root/src/java/com/jogamp/gluegen/cgram
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2014-06-17 08:26:36 +0200
committerSven Gothel <[email protected]>2014-06-17 08:26:36 +0200
commitf4e753ff1f39be381307ffdb0fb6bb7a2d323eff (patch)
tree156e7c1bdad95420754098fb3fe9522b4cf38edd /src/java/com/jogamp/gluegen/cgram
parenta75276408c9bcff77f568cf72b6c71e421a07552 (diff)
GlueGen: Add support for 'compound array call-by-value'
Completing commit c3054a01990e55ab35756ea23ab7d7c05f24dd37 by allowing passing compound arrays via 'call-by-value. - Creating linear temp heap, copying NIO values into it and passing to C function. Copy-back if not 'const', see below. - Respect 'const' qualifier to skip write-back of temp heap passed to C function - See tag: // FIXME: Compound and Compound-Arrays for code changes and validation of completeness - triggers for compound arrays are: - javaType.isArrayOfCompoundTypeWrappers() - type.isArray() - simplified const query by c-type: FunctionEmitter.isBaseTypeConst(ctype) +++ Tests: Added call-by-value to test1.[ch] binding test!
Diffstat (limited to 'src/java/com/jogamp/gluegen/cgram')
-rw-r--r--src/java/com/jogamp/gluegen/cgram/types/ArrayType.java9
-rw-r--r--src/java/com/jogamp/gluegen/cgram/types/FunctionType.java14
2 files changed, 18 insertions, 5 deletions
diff --git a/src/java/com/jogamp/gluegen/cgram/types/ArrayType.java b/src/java/com/jogamp/gluegen/cgram/types/ArrayType.java
index 6cedc9c..678fa10 100644
--- a/src/java/com/jogamp/gluegen/cgram/types/ArrayType.java
+++ b/src/java/com/jogamp/gluegen/cgram/types/ArrayType.java
@@ -46,8 +46,8 @@ package com.jogamp.gluegen.cgram.types;
should be passed in to the constructor. */
public class ArrayType extends MemoryLayoutType implements Cloneable {
- private Type elementType;
- private int length;
+ private final Type elementType;
+ private final int length;
private String computedName;
public ArrayType(Type elementType, SizeThunk sizeInBytes, int length, int cvAttributes) {
@@ -87,7 +87,7 @@ public class ArrayType extends MemoryLayoutType implements Cloneable {
/** Return the bottommost element type if this is a multidimensional
array. */
- public Type getBaseElementType() {
+ public Type getBaseElementType() {
ArrayType t = this;
while (t.getElementType().isArray()) {
t = t.getElementType().asArray();
@@ -112,6 +112,9 @@ public class ArrayType extends MemoryLayoutType implements Cloneable {
public String toString(String variableName) {
StringBuilder buf = new StringBuilder();
+ if(elementType.isConst()) {
+ buf.append("const ");
+ }
buf.append(elementType.getName());
if (variableName != null) {
buf.append(" ");
diff --git a/src/java/com/jogamp/gluegen/cgram/types/FunctionType.java b/src/java/com/jogamp/gluegen/cgram/types/FunctionType.java
index bb62eba..70fbc64 100644
--- a/src/java/com/jogamp/gluegen/cgram/types/FunctionType.java
+++ b/src/java/com/jogamp/gluegen/cgram/types/FunctionType.java
@@ -45,7 +45,7 @@ import java.util.*;
declarations and (via PointerType) function pointers. */
public class FunctionType extends Type implements Cloneable {
- private Type returnType;
+ private final Type returnType;
private ArrayList<Type> argumentTypes;
private ArrayList<String> argumentNames;
@@ -136,6 +136,9 @@ public class FunctionType extends Type implements Cloneable {
String toString(String functionName, String callingConvention, boolean emitNativeTag, boolean isPointer) {
StringBuilder res = new StringBuilder();
+ if(isConst()) {
+ res.append("const ");
+ }
res.append(getReturnType());
res.append(" ");
if (isPointer) {
@@ -163,11 +166,18 @@ public class FunctionType extends Type implements Cloneable {
for (int i = 0; i < n; i++) {
Type t = getArgumentType(i);
if (t.isFunctionPointer()) {
- FunctionType ft = t.asPointer().getTargetType().asFunction();
+ Type targetType = t.asPointer().getTargetType();
+ if(targetType.isConst()) {
+ res.append("const ");
+ }
+ FunctionType ft = targetType.asFunction();
res.append(ft.toString(getArgumentName(i), callingConvention, false, true));
} else if (t.isArray()) {
res.append(t.asArray().toString(getArgumentName(i)));
} else {
+ if(t.isConst()) {
+ res.append("const ");
+ }
res.append(t);
String argumentName = getArgumentName(i);
if (argumentName != null) {