From f20389b3f59c5d8c6d9afe0df16282dd09115640 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 18 Dec 2011 04:17:47 +0100 Subject: 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 . --- src/java/com/jogamp/gluegen/JavaEmitter.java | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'src/java/com/jogamp/gluegen') 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(" }"); } -- cgit v1.2.3