aboutsummaryrefslogtreecommitdiffstats
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
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 .
-rwxr-xr-xmake/scripts/runtest.sh4
-rw-r--r--src/java/com/jogamp/gluegen/JavaEmitter.java23
-rw-r--r--src/junit/com/jogamp/gluegen/test/junit/generation/BaseClass.java28
-rw-r--r--src/junit/com/jogamp/gluegen/test/junit/generation/test1.c3
-rw-r--r--src/junit/com/jogamp/gluegen/test/junit/generation/test1.h5
5 files changed, 51 insertions, 12 deletions
diff --git a/make/scripts/runtest.sh b/make/scripts/runtest.sh
index 34f3bc6..286921a 100755
--- a/make/scripts/runtest.sh
+++ b/make/scripts/runtest.sh
@@ -55,7 +55,7 @@ function onetest() {
#onetest com.jogamp.common.util.TestVersionInfo 2>&1 | tee -a $LOG
#onetest com.jogamp.common.util.TestIteratorIndexCORE 2>&1 | tee -a $LOG
#onetest com.jogamp.common.util.locks.TestRecursiveLock01 2>&1 | tee -a $LOG
-onetest com.jogamp.common.util.locks.TestRecursiveThreadGroupLock01 2>&1 | tee -a $LOG
+#onetest com.jogamp.common.util.locks.TestRecursiveThreadGroupLock01 2>&1 | tee -a $LOG
#onetest com.jogamp.common.util.TestArrayHashSet01 2>&1 | tee -a $LOG
#onetest com.jogamp.common.util.IntIntHashMapTest 2>&1 | tee -a $LOG
#onetest com.jogamp.common.util.IntObjectHashMapTest 2>&1 | tee -a $LOG
@@ -65,7 +65,7 @@ onetest com.jogamp.common.util.locks.TestRecursiveThreadGroupLock01 2>&1 | tee -
#onetest com.jogamp.common.nio.TestPointerBufferEndian 2>&1 | tee -a $LOG
#onetest com.jogamp.common.nio.TestStructAccessorEndian 2>&1 | tee -a $LOG
#onetest com.jogamp.gluegen.test.junit.generation.Test1p1JavaEmitter 2>&1 | tee -a $LOG
-#onetest com.jogamp.gluegen.test.junit.generation.Test1p2ProcAddressEmitter 2>&1 | tee -a $LOG
+onetest com.jogamp.gluegen.test.junit.generation.Test1p2ProcAddressEmitter 2>&1 | tee -a $LOG
#onetest com.jogamp.common.util.TestPlatform01 2>&1 | tee -a $LOG
#onetest com.jogamp.common.util.TestRunnableTask01 2>&1 | tee -a $LOG
#onetest com.jogamp.common.util.TestIOUtil01 2>&1 | tee -a $LOG
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(" }");
}
diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/BaseClass.java b/src/junit/com/jogamp/gluegen/test/junit/generation/BaseClass.java
index 4673805..8d9c73a 100644
--- a/src/junit/com/jogamp/gluegen/test/junit/generation/BaseClass.java
+++ b/src/junit/com/jogamp/gluegen/test/junit/generation/BaseClass.java
@@ -685,10 +685,34 @@ public class BaseClass extends JunitTracer {
TK_Surface surface = binding.createSurface();
- assertAPTR(0x123456789abcdef0L, surface.getCtx());
+ final long surfaceContext = surface.getCtx();
+ assertAPTR(0x123456789abcdef0L, surfaceContext);
+
+ TK_ContextWrapper ctxWrapper = surface.getCtxWrapper();
+ final long wrapperContext = ctxWrapper.getCtx();
+ assertAPTR(0xA23456781abcdef0L, wrapperContext);
TK_Engine engine = surface.getEngine();
- assertAPTR(0x123456789abcdef0L, engine.getCtx());
+ final long engineContext = engine.getCtx();
+ assertAPTR(0xB23456782abcdef0L, engineContext);
+ Assert.assertEquals(0x0111, engine.render(0x0100, 0x0010, 0x0001));
+
+ surface.setCtx(surfaceContext);
+ assertAPTR(surfaceContext, surface.getCtx());
+ assertAPTR(wrapperContext, ctxWrapper.getCtx());
+ assertAPTR(engineContext, engine.getCtx());
+ Assert.assertEquals(0x0111, engine.render(0x0100, 0x0010, 0x0001));
+
+ ctxWrapper.setCtx(wrapperContext);
+ assertAPTR(surfaceContext, surface.getCtx());
+ assertAPTR(wrapperContext, ctxWrapper.getCtx());
+ assertAPTR(engineContext, engine.getCtx());
+ Assert.assertEquals(0x0111, engine.render(0x0100, 0x0010, 0x0001));
+
+ engine.setCtx(engineContext);
+ assertAPTR(surfaceContext, surface.getCtx());
+ assertAPTR(wrapperContext, ctxWrapper.getCtx());
+ assertAPTR(engineContext, engine.getCtx());
Assert.assertEquals(0x0111, engine.render(0x0100, 0x0010, 0x0001));
TK_Dimension dimension = surface.getBounds();
diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/test1.c b/src/junit/com/jogamp/gluegen/test/junit/generation/test1.c
index ae3c8a5..ebb1e08 100644
--- a/src/junit/com/jogamp/gluegen/test/junit/generation/test1.c
+++ b/src/junit/com/jogamp/gluegen/test/junit/generation/test1.c
@@ -259,10 +259,11 @@ MYAPI TK_Surface * MYAPIENTRY createSurface() {
s->getClip = _TK_getClip;
s->ctx = (void *) 0x123456789abcdef0UL;
+ s->ctxWrapper.ctx = (void *) 0xA23456781abcdef0UL;
//s->engine = (TK_Engine *) calloc(1, sizeof(TK_Engine));
//s->engine->ctx = (void *) 0x123456789abcdef0UL;
//s->engine->render = _TK_render;
- s->engine.ctx = (void *) 0x123456789abcdef0UL;
+ s->engine.ctx = (void *) 0xB23456782abcdef0UL;
s->engine.render = _TK_render;
s->bounds.x = 0x11111111U;
diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/test1.h b/src/junit/com/jogamp/gluegen/test/junit/generation/test1.h
index 6c38a03..76a15f2 100644
--- a/src/junit/com/jogamp/gluegen/test/junit/generation/test1.h
+++ b/src/junit/com/jogamp/gluegen/test/junit/generation/test1.h
@@ -143,8 +143,13 @@ typedef struct {
int32_t (MYAPIENTRY *render) (int x, int y, int ps);
} TK_Engine;
+typedef struct {
+ TK_Context ctx;
+} TK_ContextWrapper;
+
typedef struct tk_Surface {
TK_Context ctx;
+ TK_ContextWrapper ctxWrapper;
// const TK_Engine * engine;
TK_Engine engine;
TK_Dimension bounds;