summaryrefslogtreecommitdiffstats
path: root/src/java/com/jogamp/gluegen/JavaEmitter.java
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-12-18 04:17:47 +0100
committerSven Gothel <[email protected]>2011-12-18 04:17:47 +0100
commitf20389b3f59c5d8c6d9afe0df16282dd09115640 (patch)
tree142ade0593db5b2a602be5aaff0c9756859f7d14 /src/java/com/jogamp/gluegen/JavaEmitter.java
parent53bcf1366374a2005003088b02d6019ca402843c (diff)
JavaEmitter: Fix primitive StructEmitter for non-fixed-sized (size conversion, ie. 32/64 bits)
An opaque type still needs to be converted to the right size (32/64 bit). In case of a conversion, respect the pointer type. This fixes bug 536 .
Diffstat (limited to 'src/java/com/jogamp/gluegen/JavaEmitter.java')
-rw-r--r--src/java/com/jogamp/gluegen/JavaEmitter.java23
1 files changed, 16 insertions, 7 deletions
diff --git a/src/java/com/jogamp/gluegen/JavaEmitter.java b/src/java/com/jogamp/gluegen/JavaEmitter.java
index d768858..7ab3aca 100644
--- a/src/java/com/jogamp/gluegen/JavaEmitter.java
+++ b/src/java/com/jogamp/gluegen/JavaEmitter.java
@@ -1061,22 +1061,31 @@ public class JavaEmitter implements GlueEmitter {
}
if (javaType.isPrimitive()) {
// Primitive type
- final boolean fieldTypeNativeSizeFixed = fieldType.getSize().hasFixedNativeSize() || isOpaque(fieldType) ;
- String javaTypeName = javaType.getName();
- if (isOpaque(fieldType)) {
+ final boolean fieldTypeNativeSizeFixed = fieldType.getSize().hasFixedNativeSize();
+ final String javaTypeName;
+ if ( isOpaque(fieldType) ) {
javaTypeName = compatiblePrimitiveJavaTypeName(fieldType, javaType, machDescJava);
+ } else {
+ javaTypeName = javaType.getName();
+ }
+ final String capJavaTypeName = capitalizeString(javaTypeName);
+ final String capFieldName = capitalizeString(fieldName);
+ final String sizeDenominator = fieldType.isPointer() ? "pointer" : javaTypeName ;
+
+ if(GlueGen.debug()) {
+ System.err.println("Java.StructEmitter.Primitive: "+field.getName()+", "+fieldType.getName(true)+", "+javaTypeName+", "+
+ ", fixedSize "+fieldTypeNativeSizeFixed+", opaque "+isOpaque(fieldType)+", isPointer "+fieldType.isPointer()+", isCompound "+fieldType.isCompound()+
+ ", sizeDenominator "+sizeDenominator);
}
- String capJavaTypeName = capitalizeString(javaTypeName);
writer.println();
- String capFieldName = capitalizeString(fieldName);
// Setter
generateSetterSignature(writer, false, containingTypeName, capFieldName, javaTypeName);
writer.println(" {");
if( fieldTypeNativeSizeFixed ) {
writer.println(" accessor.set" + capJavaTypeName + "At(" + fieldName+"_offset[mdIdx], val);");
} else {
- writer.println(" accessor.set" + capJavaTypeName + "At(" + fieldName+"_offset[mdIdx], val, MachineDescriptionRuntime.getStatic().md."+javaTypeName+"SizeInBytes());");
+ writer.println(" accessor.set" + capJavaTypeName + "At(" + fieldName+"_offset[mdIdx], val, MachineDescriptionRuntime.getStatic().md."+sizeDenominator+"SizeInBytes());");
}
writer.println(" return this;");
writer.println(" }");
@@ -1089,7 +1098,7 @@ public class JavaEmitter implements GlueEmitter {
if( fieldTypeNativeSizeFixed ) {
writer.println("accessor.get" + capJavaTypeName + "At(" + fieldName+"_offset[mdIdx]);");
} else {
- writer.println("accessor.get" + capJavaTypeName + "At(" + fieldName+"_offset[mdIdx], MachineDescriptionRuntime.getStatic().md."+javaTypeName+"SizeInBytes());");
+ writer.println("accessor.get" + capJavaTypeName + "At(" + fieldName+"_offset[mdIdx], MachineDescriptionRuntime.getStatic().md."+sizeDenominator+"SizeInBytes());");
}
writer.println(" }");
}