diff options
author | Sven Gothel <[email protected]> | 2014-06-17 08:26:36 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2014-06-17 08:26:36 +0200 |
commit | f4e753ff1f39be381307ffdb0fb6bb7a2d323eff (patch) | |
tree | 156e7c1bdad95420754098fb3fe9522b4cf38edd /src/java/com/jogamp/gluegen/FunctionEmitter.java | |
parent | a75276408c9bcff77f568cf72b6c71e421a07552 (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/FunctionEmitter.java')
-rw-r--r-- | src/java/com/jogamp/gluegen/FunctionEmitter.java | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/src/java/com/jogamp/gluegen/FunctionEmitter.java b/src/java/com/jogamp/gluegen/FunctionEmitter.java index 01a0e12..d193ec2 100644 --- a/src/java/com/jogamp/gluegen/FunctionEmitter.java +++ b/src/java/com/jogamp/gluegen/FunctionEmitter.java @@ -42,14 +42,16 @@ package com.jogamp.gluegen; import java.util.*; import java.io.*; +import com.jogamp.gluegen.cgram.types.Type; + public abstract class FunctionEmitter { public static final EmissionModifier STATIC = new EmissionModifier("static"); - private boolean isInterfaceVal; + private final boolean isInterfaceVal; private final ArrayList<EmissionModifier> modifiers; private CommentEmitter commentEmitter = null; - private PrintWriter defaultOutput; + private final PrintWriter defaultOutput; /** * Constructs the FunctionEmitter with a CommentEmitter that emits nothing. @@ -73,6 +75,25 @@ public abstract class FunctionEmitter { public boolean isInterface() { return isInterfaceVal; } + /** + * Checks the base type of pointer-to-pointer, pointer, array or plain for const-ness. + * <p> + * Note: Implementation walks down to the base type and returns it's const-ness. + * Intermediate 'const' qualifier are not considered, e.g. const pointer. + * </p> + */ + protected final boolean isBaseTypeConst(Type type) { + if ( 2 == type.pointerDepth() ) { + return type.asPointer().getTargetType().asPointer().getTargetType().isConst(); + } else if ( 1 == type.pointerDepth() ) { + return type.asPointer().getTargetType().isConst(); + } else if( type.isArray() ) { + return type.asArray().getBaseElementType().isConst(); + } else { + return type.isConst(); + } + } + public PrintWriter getDefaultOutput() { return defaultOutput; } public void addModifiers(Iterator<EmissionModifier> mi) { @@ -196,7 +217,7 @@ public abstract class FunctionEmitter { @Override public final String toString() { return emittedForm; } - private String emittedForm; + private final String emittedForm; @Override public int hashCode() { |