summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/antlr/com/jogamp/gluegen/cgram/HeaderParser.g15
-rw-r--r--src/java/com/jogamp/gluegen/JavaEmitter.java129
-rw-r--r--src/java/com/jogamp/gluegen/cgram/types/StructLayout.java34
-rw-r--r--src/junit/com/jogamp/gluegen/test/junit/generation/BaseClass.java68
-rw-r--r--src/junit/com/jogamp/gluegen/test/junit/generation/test1-common.cfg6
-rw-r--r--src/junit/com/jogamp/gluegen/test/junit/generation/test1.c5
-rw-r--r--src/junit/com/jogamp/gluegen/test/junit/generation/test1.h16
7 files changed, 212 insertions, 61 deletions
diff --git a/src/antlr/com/jogamp/gluegen/cgram/HeaderParser.g b/src/antlr/com/jogamp/gluegen/cgram/HeaderParser.g
index 75cf413..01f10c3 100644
--- a/src/antlr/com/jogamp/gluegen/cgram/HeaderParser.g
+++ b/src/antlr/com/jogamp/gluegen/cgram/HeaderParser.g
@@ -297,7 +297,7 @@ options {
private void handleArrayExpr(TypeBox tb, AST t) {
if (t != null) {
try {
- int len = parseIntConstExpr(t);
+ final int len = parseIntConstExpr(t);
tb.setType(canonicalize(new ArrayType(tb.type(), SizeThunk.mul(SizeThunk.constant(len), tb.type().getSize()), len, 0)));
return;
} catch (RecognitionException e) {
@@ -782,4 +782,17 @@ nonemptyAbstractDeclarator[TypeBox tb]
constants. Can be made more complicated as necessary. */
intConstExpr returns [int i] { i = -1; }
: n:Number { return Integer.parseInt(n.getText()); }
+ | e:ID {
+ final String enumName = e.getText();
+ final EnumType enumType = enumHash.get(enumName);
+ if( null == enumType ) {
+ throw new IllegalArgumentException("Error: intConstExpr ID "+enumName+" recognized, but no containing enum-type found");
+ }
+ final long enumValue = enumType.getEnumValue(enumName);
+ System.err.println("INFO: intConstExpr: enum[Type "+enumType.getName()+", name "+enumName+", value "+enumValue+"]");
+ if( (long)Integer.MIN_VALUE > enumValue || (long)Integer.MAX_VALUE < enumValue ) {
+ throw new IndexOutOfBoundsException("Error: intConstExpr ID "+enumName+" enum-value "+enumValue+" out of int range");
+ }
+ return (int)enumValue;
+ }
;
diff --git a/src/java/com/jogamp/gluegen/JavaEmitter.java b/src/java/com/jogamp/gluegen/JavaEmitter.java
index 18e8b81..822c1c9 100644
--- a/src/java/com/jogamp/gluegen/JavaEmitter.java
+++ b/src/java/com/jogamp/gluegen/JavaEmitter.java
@@ -951,16 +951,22 @@ public class JavaEmitter implements GlueEmitter {
javaWriter.println(" private static final int mdIdx = MachineDescriptionRuntime.getStatic().ordinal();");
javaWriter.println();
// generate all offset and size arrays
- generateOffsetAndSizeArrays(javaWriter, " ", containingTypeName, structType, null); /* w/o offset */
+ generateOffsetAndSizeArrays(javaWriter, " ", containingTypeName, structType, null, null); /* w/o offset */
+ if( GlueGen.debug() ) {
+ System.err.printf("SE.__: t %s: %s%n", structType, containingTypeName);
+ }
for (int i = 0; i < structType.getNumFields(); i++) {
final Field field = structType.getField(i);
final Type fieldType = field.getType();
if (!cfg.shouldIgnoreInInterface(name + " " + field.getName())) {
final String renamed = cfg.getJavaSymbolRename(field.getName());
- final String fieldName = renamed==null ? field.getName() : renamed;
+ final String fieldName = null==renamed ? field.getName() : renamed;
if (fieldType.isFunctionPointer()) {
- // no offset/size for function pointer ..
+ // no offset/size for function pointer ..
+ if( GlueGen.debug() ) {
+ System.err.printf("SE.os.%02d: t %s: %s / %s (%s)%n", (i+1), fieldType, field, fieldName, "SKIP FuncPtr");
+ }
} else if (fieldType.isCompound()) {
// FIXME: will need to support this at least in order to
// handle the union in jawt_Win32DrawingSurfaceInfo (fabricate
@@ -969,17 +975,18 @@ public class JavaEmitter implements GlueEmitter {
throw new RuntimeException("Anonymous structs as fields not supported yet (field \"" +
field + "\" in type \"" + name + "\")");
}
-
- generateOffsetAndSizeArrays(javaWriter, " ", fieldName, fieldType, field);
+ if( GlueGen.debug() ) {
+ System.err.printf("SE.os.%02d: t %s: %s / %s (%s)%n", (i+1), fieldType, field, fieldName, "compound");
+ }
+ generateOffsetAndSizeArrays(javaWriter, " ", fieldName, fieldType, field, null);
} else if (fieldType.isArray()) {
- Type baseElementType = field.getType().asArray().getBaseElementType();
-
- if(!baseElementType.isPrimitive())
- break;
-
- generateOffsetAndSizeArrays(javaWriter, " ", fieldName, null, field); /* w/o size */
+ final Type baseElementType = field.getType().asArray().getBaseElementType();
+ if( GlueGen.debug() ) {
+ System.err.printf("SE.os.%02d: t %s: %s / %s - baseType %s (%s)%n", (i+1), fieldType, field, fieldName, baseElementType, "array");
+ }
+ generateOffsetAndSizeArrays(javaWriter, " ", fieldName, fieldType, field, null);
} else {
- JavaType externalJavaType = null;
+ final JavaType externalJavaType;
try {
externalJavaType = typeToJavaType(fieldType, false, machDescJava);
} catch (Exception e) {
@@ -987,19 +994,26 @@ public class JavaEmitter implements GlueEmitter {
field.getName() + "\" in type \"" + name + "\"");
throw(e);
}
+ if( GlueGen.debug() ) {
+ System.err.printf("SE.os.%02d: t %s: %s / %s - javaType %s (%s)%n", (i+1), fieldType, field, fieldName, externalJavaType.getDumpString(), "MISC");
+ }
if (externalJavaType.isPrimitive()) {
// Primitive type
- generateOffsetAndSizeArrays(javaWriter, " ", fieldName, null, field); /* w/o size */
+ generateOffsetAndSizeArrays(javaWriter, " ", fieldName, null, field, null); /* w/o size */
} else if (externalJavaType.isCPrimitivePointerType()) {
// FIXME: Primitive Pointer type
- generateOffsetAndSizeArrays(javaWriter, "//", fieldName, fieldType, field);
+ generateOffsetAndSizeArrays(javaWriter, "// Skipped C-Primitive-Ptr-Type: ", fieldName, fieldType, field, externalJavaType.getDumpString());
} else {
- // FIXME
- LOG.log(WARNING, "Complicated fields (field \"{0}\" of type \"{1}\") not implemented yet: "+externalJavaType.getDumpString(), new Object[]{field, name});
+ // FIXME ???
+ generateOffsetAndSizeArrays(javaWriter, "// Skipped Complicated Field: ", fieldName, fieldType, field, externalJavaType.getDumpString());
+ LOG.log(WARNING, "Complicated fields (field \"{0}\" of type \"{1}\") not implemented yet: {2}",
+ new Object[]{field, name, externalJavaType.getDumpString()});
// throw new RuntimeException("Complicated fields (field \"" + field + "\" of type \"" + t +
// "\") not implemented yet");
}
}
+ } else if( GlueGen.debug() ) {
+ System.err.printf("SE.os.%02d: t %s: %s (IGNORED)%n", (i+1), fieldType, field);
}
}
javaWriter.println();
@@ -1032,11 +1046,14 @@ public class JavaEmitter implements GlueEmitter {
final String fieldName = renamed==null ? field.getName() : renamed;
if (fieldType.isFunctionPointer()) {
+ if( GlueGen.debug() ) {
+ System.err.printf("SE.ac.%02d: t %s: %s / %s (%s)%n", (i+1), fieldType, field, fieldName, "funcPtr");
+ }
try {
// Emit method call and associated native code
- FunctionType funcType = fieldType.asPointer().getTargetType().asFunction();
- FunctionSymbol funcSym = new FunctionSymbol(fieldName, funcType);
- MethodBinding binding = bindFunction(funcSym, containingType, containingCType, machDescJava);
+ final FunctionType funcType = fieldType.asPointer().getTargetType().asFunction();
+ final FunctionSymbol funcSym = new FunctionSymbol(fieldName, funcType);
+ final MethodBinding binding = bindFunction(funcSym, containingType, containingCType, machDescJava);
binding.findThisPointer(); // FIXME: need to provide option to disable this on per-function basis
javaWriter.println();
@@ -1105,6 +1122,9 @@ public class JavaEmitter implements GlueEmitter {
throw new RuntimeException("Anonymous structs as fields not supported yet (field \"" +
field + "\" in type \"" + name + "\")");
}
+ if( GlueGen.debug() ) {
+ System.err.printf("SE.ac.%02d: t %s: %s / %s (%s)%n", (i+1), fieldType, field, fieldName, "compound");
+ }
javaWriter.println();
generateGetterSignature(javaWriter, false, fieldType.getName(), capitalizeString(fieldName));
@@ -1114,30 +1134,60 @@ public class JavaEmitter implements GlueEmitter {
javaWriter.println(" }");
} else if (fieldType.isArray()) {
+ final Type baseElementType = field.getType().asArray().getBaseElementType();
+ final JavaType paramType = typeToJavaType(baseElementType, false, machDescJava);
- Type baseElementType = field.getType().asArray().getBaseElementType();
-
- if(!baseElementType.isPrimitive())
- break;
-
- String paramType = typeToJavaType(baseElementType, false, machDescJava).getName();
- String capitalized = capitalizeString(fieldName);
+ final String paramTypeName = paramType.getName();
+ final String capitalized = capitalizeString(fieldName);
+ if( GlueGen.debug() ) {
+ System.err.printf("SE.ac.%02d: t %s: %s / %s - baseType %s, paramType %s (%s)%n", (i+1), fieldType, field, fieldName, baseElementType, paramType.getDumpString(), "array");
+ }
// Setter
javaWriter.println();
- generateSetterSignature(javaWriter, false, containingTypeName, capitalized, paramType+"[]");
+ generateSetterSignature(javaWriter, false, containingTypeName, capitalized, paramTypeName+"[]");
javaWriter.println(" {");
- javaWriter.print (" accessor.set" + capitalizeString(paramType) + "sAt(" + fieldName+"_offset[mdIdx], val);");
- javaWriter.println(" return this;");
+ if(baseElementType.isPrimitive()) {
+ javaWriter.print (" accessor.set" + capitalizeString(paramTypeName) + "sAt(" + fieldName+"_offset[mdIdx], val);");
+ javaWriter.println(" return this;");
+ } else {
+ javaWriter.println(" final int elemSize = "+paramTypeName+".size();");
+ javaWriter.println(" final ByteBuffer destB = getBuffer();");
+ javaWriter.println(" int offset = "+fieldName+"_offset[mdIdx];");
+ javaWriter.println(" final int total = "+fieldType.asArray().getLength()+" * elemSize;");
+ javaWriter.println(" if( total > "+fieldName+"_size[mdIdx] ) { throw new IndexOutOfBoundsException(\"total \"+total+\" > size \"+"+fieldName+"_size[mdIdx]+\", elemSize \"+elemSize+\" * "+fieldType.asArray().getLength()+"\"); };");
+ javaWriter.println(" final int limes = offset + total;");
+ javaWriter.println(" if( limes >= destB.limit() ) { throw new IndexOutOfBoundsException(\"limes \"+limes+\" >= buffer.limit \"+destB.limit()+\", elemOff \"+offset+\", elemSize \"+elemSize+\" * "+fieldType.asArray().getLength()+"\"); };");
+ javaWriter.println(" for(int e=0; e<"+fieldType.asArray().getLength()+"; e++) {");
+ javaWriter.println(" final "+paramTypeName+" source = val[e];");
+ javaWriter.println(" final ByteBuffer sourceB = source.getBuffer();");
+ javaWriter.println(" for(int f=0; f<elemSize; f++) {");
+ javaWriter.println(" if( offset >= limes ) { throw new IndexOutOfBoundsException(\"elem-byte[\"+e+\"][\"+f+\"]: offset \"+offset+\" >= limes \"+limes+\", elemSize \"+elemSize+\" * "+fieldType.asArray().getLength()+"\"); };");
+ javaWriter.println(" destB.put(offset++, sourceB.get(f));");
+ javaWriter.println(" }");
+ javaWriter.println(" }");
+ javaWriter.println(" return this;");
+ }
javaWriter.println(" }");
javaWriter.println();
// Getter
- generateGetterSignature(javaWriter, false, paramType+"[]", capitalized);
+ generateGetterSignature(javaWriter, false, paramTypeName+"[]", capitalized);
javaWriter.println(" {");
- javaWriter.print (" return accessor.get" + capitalizeString(paramType) + "sAt(" + fieldName+"_offset[mdIdx], new " +paramType+"["+fieldType.asArray().getLength()+"]);");
+ if(baseElementType.isPrimitive()) {
+ javaWriter.print (" return accessor.get" + capitalizeString(paramTypeName) + "sAt(" + fieldName+"_offset[mdIdx], new " +paramTypeName+"["+fieldType.asArray().getLength()+"]);");
+ } else {
+ javaWriter.println(" final "+paramTypeName+"[] res = new "+paramTypeName+"["+fieldType.asArray().getLength()+"];");
+ javaWriter.println(" int offset = "+fieldName+"_offset[mdIdx];");
+ javaWriter.println(" final int elemSize = "+paramTypeName+".size();");
+ javaWriter.println(" for(int e=0; e<"+fieldType.asArray().getLength()+"; e++) {");
+ javaWriter.println(" res[e] = "+paramTypeName+".create(accessor.slice(offset, elemSize));");
+ javaWriter.println(" offset += elemSize;");
+ javaWriter.println(" }");
+ javaWriter.println(" return res;");
+ }
javaWriter.println(" }");
} else {
- JavaType javaType = null;
+ final JavaType javaType;
try {
javaType = typeToJavaType(fieldType, false, machDescJava);
@@ -1146,6 +1196,9 @@ public class JavaEmitter implements GlueEmitter {
field.getName() + "\" in type \"" + name + "\"");
throw(e);
}
+ if( GlueGen.debug() ) {
+ System.err.printf("SE.ac.%02d: t %s: %s / %s - javaType %s (%s)%n", (i+1), fieldType, field, fieldName, javaType.getDumpString(), "MISC");
+ }
if (javaType.isPrimitive()) {
// Primitive type
final boolean fieldTypeNativeSizeFixed = fieldType.getSize().hasFixedNativeSize();
@@ -1210,6 +1263,9 @@ public class JavaEmitter implements GlueEmitter {
jniWriter.flush();
jniWriter.close();
}
+ if( GlueGen.debug() ) {
+ System.err.printf("SE.XX: t %s: %s%n", structType, containingTypeName);
+ }
}
@Override
public void endStructs() throws Exception {}
@@ -1250,7 +1306,7 @@ public class JavaEmitter implements GlueEmitter {
writer.print(" public " + (abstractMethod ? "abstract " : "") + returnTypeName + " set" + capitalizedFieldName + "(" + paramTypeName + " val)");
}
- private void generateOffsetAndSizeArrays(PrintWriter writer, String prefix, String fieldName, Type fieldType, Field field) {
+ private void generateOffsetAndSizeArrays(PrintWriter writer, String prefix, String fieldName, Type fieldType, Field field, String postfix) {
if(null != field) {
writer.print(prefix+"private static final int[] "+fieldName+"_offset = new int[] { ");
for( int i=0; i < machDescTargetConfigs.length; i++ ) {
@@ -1271,7 +1327,12 @@ public class JavaEmitter implements GlueEmitter {
writer.print(fieldType.getSize(machDescTargetConfigs[i].md) +
" /* " + machDescTargetConfigs[i].name() + " */");
}
- writer.println(" };");
+ writer.print(" };");
+ if( null != postfix ) {
+ writer.println(postfix);
+ } else {
+ writer.println();
+ }
}
}
diff --git a/src/java/com/jogamp/gluegen/cgram/types/StructLayout.java b/src/java/com/jogamp/gluegen/cgram/types/StructLayout.java
index 11501e1..f105f1f 100644
--- a/src/java/com/jogamp/gluegen/cgram/types/StructLayout.java
+++ b/src/java/com/jogamp/gluegen/cgram/types/StructLayout.java
@@ -40,6 +40,9 @@
package com.jogamp.gluegen.cgram.types;
+import com.jogamp.common.os.MachineDescription;
+import com.jogamp.gluegen.GlueGen;
+
/** Encapsulates algorithm for laying out data structures. Note that
this ends up embedding code in various places via SizeThunks. If
the 32-bit and 64-bit ports on a given platform differ
@@ -48,7 +51,7 @@ package com.jogamp.gluegen.cgram.types;
SizeThunks maintained in various places. */
public class StructLayout {
- private int baseOffset;
+ private final int baseOffset;
protected StructLayout(int baseOffset) {
this.baseOffset = baseOffset;
@@ -60,12 +63,21 @@ public class StructLayout {
* - 2) add the aligned size of the new data type
* - 3) add trailing padding (largest element size)
*/
- int n = t.getNumFields();
+ final int n = t.getNumFields();
SizeThunk curOffset = SizeThunk.constant(baseOffset);
SizeThunk maxSize = SizeThunk.constant(0);
+
+ final MachineDescription dbgMD;
+ if( GlueGen.debug() ) {
+ dbgMD = MachineDescription.StaticConfig.X86_64_UNIX.md;
+ System.err.printf("SL.__: o %03d, s %03d, t %s{%d}%n", curOffset.computeSize(dbgMD), 0, t, t.getNumFields());
+ } else {
+ dbgMD = null;
+ }
+
for (int i = 0; i < n; i++) {
- Field f = t.getField(i);
- Type ft = f.getType();
+ final Field f = t.getField(i);
+ final Type ft = f.getType();
if (ft.isInt() || ft.isFloat() || ft.isDouble() || ft.isPointer()) {
final SizeThunk sz = ft.getSize();
curOffset = SizeThunk.align(curOffset, sz);
@@ -75,6 +87,9 @@ public class StructLayout {
} else {
curOffset = SizeThunk.add(curOffset, sz);
}
+ if( GlueGen.debug() ) {
+ System.err.printf("SL.%02d: o %03d, s %03d, t %s: %s%n", (i+1), f.getOffset(dbgMD), ft.getSize(dbgMD), ft, f);
+ }
} else if (ft.isCompound()) {
final CompoundType ct = ft.asCompound();
if(!ct.isLayouted()) {
@@ -88,8 +103,11 @@ public class StructLayout {
} else {
curOffset = SizeThunk.add(curOffset, sz);
}
+ if( GlueGen.debug() ) {
+ System.err.printf("SL.%02d: o %03d, s %03d, t %s{%d}: %s%n", (i+1), f.getOffset(dbgMD), ft.getSize(dbgMD), ft, ct.getNumFields(), f);
+ }
} else if (ft.isArray()) {
- ArrayType arrayType = ft.asArray();
+ final ArrayType arrayType = ft.asArray();
if(!arrayType.isLayouted()) {
CompoundType compoundElementType = arrayType.getBaseElementType().asCompound();
if (compoundElementType != null) {
@@ -104,6 +122,9 @@ public class StructLayout {
curOffset = SizeThunk.align(curOffset, sz);
f.setOffset(curOffset);
curOffset = SizeThunk.add(curOffset, sz);
+ if( GlueGen.debug() ) {
+ System.err.printf("SL.%02d: o %03d, s %03d, t %s: %s%n", (i+1), f.getOffset(dbgMD), ft.getSize(dbgMD), ft, f);
+ }
} else {
// FIXME
String name = t.getName();
@@ -123,6 +144,9 @@ public class StructLayout {
curOffset = SizeThunk.align(curOffset, curOffset);
t.setSize(curOffset);
}
+ if( GlueGen.debug() ) {
+ System.err.printf("SL.XX: o %03d, s %03d, t %s{%d}%n%n", curOffset.computeSize(dbgMD), t.getSize(dbgMD), t, t.getNumFields());
+ }
t.setLayouted();
}
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 cc00373..3bfb5c4 100644
--- a/src/junit/com/jogamp/gluegen/test/junit/generation/BaseClass.java
+++ b/src/junit/com/jogamp/gluegen/test/junit/generation/BaseClass.java
@@ -990,27 +990,30 @@ public class BaseClass extends JunitTracer {
/** Test compound access call-by-value */
public void chapter11TestCompoundCallByValue(Bindingtest1 binding) throws Exception {
-
+ int sub = 0;
{
final TK_Surface surface = binding.createSurface();
final TK_Dimension dim0 = surface.getBounds();
- assertDim("ch11.0: ref-dim ", 0x11111111, 0x22222222, 0x33333333, 0x44444444, dim0);
+ assertDim("ch11."+sub+": ref-dim ", 0x11111111, 0x22222222, 0x33333333, 0x44444444, dim0);
final TK_Dimension dim1 = binding.getSurfaceBoundsValue(surface);
- assertDim("ch11.0: val-dim ", 0x11111111, 0x22222222, 0x33333333, 0x44444444, dim1);
+ assertDim("ch11."+sub+": val-dim ", 0x11111111, 0x22222222, 0x33333333, 0x44444444, dim1);
binding.destroySurface(surface);
}
{
+ sub++;
final TK_Dimension dim0 = binding.getBoundsValue(11, 22, 33, 44);
- assertDim("ch11.1: val-dim ", 11, 22, 33, 44, dim0);
+ assertDim("ch11."+sub+": val-dim ", 11, 22, 33, 44, dim0);
+ sub++;
final TK_Surface surface = binding.getSurfaceValue(dim0);
final TK_Dimension dim1 = binding.getSurfaceBoundsValue(surface);
- assertDim("ch11.2: val-dim ", 11, 22, 33, 44, dim1);
+ assertDim("ch11."+sub+": val-dim ", 11, 22, 33, 44, dim1);
+ sub++;
final boolean sameInstanceByVal = binding.isSameInstanceByVal(dim0, dim1);
final boolean sameInstanceByRef = binding.isSameInstanceByRef(dim0, dim1);
- System.err.println("ch11.3: sameInstanceByVal "+sameInstanceByVal);
- System.err.println("ch11.3: sameInstanceByRef "+sameInstanceByRef);
+ System.err.println("ch11."+sub+": sameInstanceByVal "+sameInstanceByVal);
+ System.err.println("ch11."+sub+": sameInstanceByRef "+sameInstanceByRef);
Assert.assertFalse(sameInstanceByVal);
Assert.assertFalse(sameInstanceByRef);
}
@@ -1018,37 +1021,62 @@ public class BaseClass extends JunitTracer {
final TK_Dimension dim1 = binding.getBoundsValue(11, 22, 33, 44);
final TK_Dimension dim2 = binding.getBoundsValue(1, 2, 3, 4);
final TK_Dimension[] sumands = { dim1, dim2 };
- final TK_Dimension dimSum = binding.addDimensions(sumands);
- assertDim("ch11.4: sum-dim ", 11+1, 22+2, 33+3, 44+4, dimSum);
- binding.zeroDimensions(sumands);
- assertDim("ch11.5: zero-dim[0] ", 0, 0, 0, 0, sumands[0]);
- assertDim("ch11.5: zero-dim[1] ", 0, 0, 0, 0, sumands[1]);
+ {
+ sub++;
+ final TK_Dimension dimSum = binding.addDimensions(sumands);
+ assertDim("ch11."+sub+": sum-dimArray ", 11+1, 22+2, 33+3, 44+4, dimSum);
+ }
+
+ final TK_DimensionPair dimPair = TK_DimensionPair.create();
+ dimPair.setPair(sumands);
+ {
+ sub++;
+ final TK_Dimension[] dimsGet = dimPair.getPair();
+ assertDim("ch11."+sub+": dimsGet[0] ", 11, 22, 33, 44, dimsGet[0]);
+ assertDim("ch11."+sub+": dimsGet[1] ", 1, 2, 3, 4, dimsGet[1]);
+ }
+ {
+ sub++;
+ final TK_Dimension dimSum = binding.addDimensionPair(dimPair);
+ assertDim("ch11."+sub+": sum-dimPair ", 11+1, 22+2, 33+3, 44+4, dimSum);
+ }
+ {
+ sub++;
+ binding.zeroDimensions(sumands);
+ assertDim("ch11."+sub+": zero-dim[0] ", 0, 0, 0, 0, sumands[0]);
+ assertDim("ch11."+sub+": zero-dim[1] ", 0, 0, 0, 0, sumands[1]);
+ }
}
{
+ sub++;
final TK_Dimension dim0 = binding.getBoundsValue(0, 0, 0, 0);
final TK_Dimension[] dim0A = { dim0 };
binding.copyPrimToDimensions(new int[] { 11, 22}, 0, new int[] { 100, 200}, 0, dim0A);
- assertDim("ch11.6: copyPrim2Dim ", 11, 22, 100, 200, dim0);
+ assertDim("ch11."+sub+": copyPrim2Dim ", 11, 22, 100, 200, dim0);
+
+ sub++;
final int[] pos = { 0, 0 };
final int[] size = { 0, 0 };
binding.copyDimensionsToPrim(dim0, pos, 0, size, 0);
- assertDim("ch11.7: copyDim2Prim ", 11, 22, 100, 200, pos, size);
+ assertDim("ch11."+sub+": copyDim2Prim ", 11, 22, 100, 200, pos, size);
}
{
+ sub++;
final int expRGBAi = 0x112233aa;
final byte[] expRGBAb = { (byte)0xaa, 0x33, 0x22, 0x11 };
final int hasRGBAi = binding.rgbaToInt(expRGBAb, 0);
- System.err.println("ch11.8: expRGBAb 0x"+
+ System.err.println("ch11."+sub+": expRGBAb 0x"+
Integer.toHexString(expRGBAb[3])+", 0x"+
Integer.toHexString(expRGBAb[2])+", 0x"+
Integer.toHexString(expRGBAb[1])+", 0x"+
Integer.toHexString(expRGBAb[0]) );
- System.err.println("ch11.8: hasRGBAi 0x"+Integer.toHexString(hasRGBAi));
+ System.err.println("ch11."+sub+": hasRGBAi 0x"+Integer.toHexString(hasRGBAi));
Assert.assertEquals(expRGBAi, hasRGBAi);
+ sub++;
final byte[] hasRGBAb = new byte[] { 0, 0, 0, 0 };
binding.intToRgba(hasRGBAi, hasRGBAb, 0);
- System.err.println("ch11.9: hasRGBAb 0x"+
+ System.err.println("ch11."+sub+": hasRGBAb 0x"+
Integer.toHexString(hasRGBAb[3])+", 0x"+
Integer.toHexString(hasRGBAb[2])+", 0x"+
Integer.toHexString(hasRGBAb[1])+", 0x"+
@@ -1056,15 +1084,17 @@ public class BaseClass extends JunitTracer {
Assert.assertArrayEquals(expRGBAb, hasRGBAb);
}
{
+ sub++;
final int[] result = { 0 };
binding.addInt(new int[] { 1, 2}, 0, result, 0);
- System.err.println("ch11.10: addInt "+result[0]);
+ System.err.println("ch11."+sub+": addInt "+result[0]);
Assert.assertEquals(3, result[0]);
}
{
+ sub++;
final byte[] result = { 0 };
binding.addByte(new byte[] { 1, 2}, 0, result, 0);
- System.err.println("ch11.11: addByte "+result[0]);
+ System.err.println("ch11."+sub+": addByte "+result[0]);
Assert.assertEquals(3, result[0]);
}
}
diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/test1-common.cfg b/src/junit/com/jogamp/gluegen/test/junit/generation/test1-common.cfg
index 89689cb..d4e32cc 100644
--- a/src/junit/com/jogamp/gluegen/test/junit/generation/test1-common.cfg
+++ b/src/junit/com/jogamp/gluegen/test/junit/generation/test1-common.cfg
@@ -36,6 +36,11 @@ CustomCCode #include "test1.h"
Opaque long TK_Context
+StructPackage TK_Dimension com.jogamp.gluegen.test.junit.generation
+EmitStruct TK_Dimension
+StructPackage TK_DimensionPair com.jogamp.gluegen.test.junit.generation
+EmitStruct TK_DimensionPair
+
StructPackage TK_Surface com.jogamp.gluegen.test.junit.generation
EmitStruct TK_Surface
# Implements TK_Surface TḴ_???
@@ -56,6 +61,7 @@ Import com.jogamp.common.os.*
Import com.jogamp.common.nio.*
Import com.jogamp.gluegen.test.junit.generation.TK_Surface
Import com.jogamp.gluegen.test.junit.generation.TK_Dimension
+Import com.jogamp.gluegen.test.junit.generation.TK_DimensionPair
Import com.jogamp.gluegen.test.junit.generation.TK_Engine
Import com.jogamp.gluegen.test.junit.generation.TK_ComplicatedSuperSet
Import com.jogamp.gluegen.test.junit.generation.TK_ComplicatedSubSet
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 7581d20..3dc1ac5 100644
--- a/src/junit/com/jogamp/gluegen/test/junit/generation/test1.c
+++ b/src/junit/com/jogamp/gluegen/test/junit/generation/test1.c
@@ -528,11 +528,14 @@ MYAPI Bool MYAPIENTRY isSameInstanceByVal(TK_Dimension s1, TK_Dimension s2) {
MYAPI Bool MYAPIENTRY isSameInstanceByRef(const TK_Dimension *s1, const TK_Dimension *s2) {
return s1 == s2;
}
-MYAPI TK_Dimension MYAPIENTRY addDimensions(const TK_Dimension s[2]) {
+MYAPI TK_Dimension MYAPIENTRY addDimensions(const TK_Dimension s[TWO]) {
TK_Dimension r = { s[0].x + s[1].x, s[0].y + s[1].y,
s[0].width + s[1].width, s[0].height + s[1].height };
return r;
}
+MYAPI TK_Dimension MYAPIENTRY addDimensionPair(const TK_DimensionPair s) {
+ return addDimensions(s.pair);
+}
MYAPI void MYAPIENTRY zeroDimensions(TK_Dimension s[2]) {
s[0].x = 0;
s[0].y = 0;
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 dcf5cfc..7343172 100644
--- a/src/junit/com/jogamp/gluegen/test/junit/generation/test1.h
+++ b/src/junit/com/jogamp/gluegen/test/junit/generation/test1.h
@@ -234,6 +234,19 @@ typedef struct {
// 120 gross 64bit/linux
} TK_ComplicatedSuperSet;
+typedef enum {
+ ZERO = 0,
+ ONE = 1,
+ TWO = 2,
+ THREE = 3
+} TK_Numbers;
+
+typedef struct {
+ int32_t i1;
+ TK_Dimension pair[TWO];
+ int32_t i2;
+} TK_DimensionPair;
+
MYAPI TK_Surface * MYAPIENTRY createSurface();
MYAPI void MYAPIENTRY destroySurface(TK_Surface * surface);
@@ -250,7 +263,8 @@ MYAPI TK_Surface MYAPIENTRY getSurfaceValue(TK_Dimension bounds);
MYAPI TK_Dimension MYAPIENTRY getSurfaceBoundsValue(TK_Surface s);
MYAPI Bool MYAPIENTRY isSameInstanceByVal(TK_Dimension s1, TK_Dimension s2);
MYAPI Bool MYAPIENTRY isSameInstanceByRef(const TK_Dimension *s1, const TK_Dimension *s2);
-MYAPI TK_Dimension MYAPIENTRY addDimensions(const TK_Dimension s[2]);
+MYAPI TK_Dimension MYAPIENTRY addDimensions(const TK_Dimension s[TWO]);
+MYAPI TK_Dimension MYAPIENTRY addDimensionPair(const TK_DimensionPair s);
MYAPI void MYAPIENTRY zeroDimensions(TK_Dimension s[2]);
MYAPI void MYAPIENTRY copyPrimToDimensions(const int pos[2], const int size[2], TK_Dimension dest[1]);