diff options
Diffstat (limited to 'src/junit/com/jogamp/gluegen')
6 files changed, 720 insertions, 10 deletions
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 3bfb5c4..fd64ba9 100644 --- a/src/junit/com/jogamp/gluegen/test/junit/generation/BaseClass.java +++ b/src/junit/com/jogamp/gluegen/test/junit/generation/BaseClass.java @@ -36,6 +36,7 @@ import com.jogamp.junit.util.JunitTracer; import java.nio.ByteBuffer; import java.nio.ByteOrder; +import java.nio.FloatBuffer; import java.nio.IntBuffer; import java.nio.LongBuffer; import java.util.Arrays; @@ -978,13 +979,28 @@ public class BaseClass extends JunitTracer { Assert.assertEquals(2, surface.getClipSize()); + TK_Dimension[] allclips = surface.getClips(0, new TK_Dimension[surface.getClipSize()]); + for(int i=0; i<surface.getClipSize(); i++) { - TK_Dimension clip = surface.getClip(i); - Assert.assertEquals(0x44444444 * (i+1) + 0x11111111, clip.getX()); - Assert.assertEquals(0x44444444 * (i+1) + 0x22222222, clip.getY()); - Assert.assertEquals(0x44444444 * (i+1) + 0x33333333, clip.getWidth()); - Assert.assertEquals(0x44444444 * (i+1) + 0x44444444, clip.getHeight()); + TK_Dimension clip0 = surface.getClip(i); + Assert.assertEquals(0x44444444 * (i+1) + 0x11111111, clip0.getX()); + Assert.assertEquals(0x44444444 * (i+1) + 0x22222222, clip0.getY()); + Assert.assertEquals(0x44444444 * (i+1) + 0x33333333, clip0.getWidth()); + Assert.assertEquals(0x44444444 * (i+1) + 0x44444444, clip0.getHeight()); + + TK_Dimension[] clip1 = new TK_Dimension[1]; + surface.getClips(i, clip1); + Assert.assertEquals(0x44444444 * (i+1) + 0x11111111, clip1[0].getX()); + Assert.assertEquals(0x44444444 * (i+1) + 0x22222222, clip1[0].getY()); + Assert.assertEquals(0x44444444 * (i+1) + 0x33333333, clip1[0].getWidth()); + Assert.assertEquals(0x44444444 * (i+1) + 0x44444444, clip1[0].getHeight()); + + Assert.assertEquals(0x44444444 * (i+1) + 0x11111111, allclips[i].getX()); + Assert.assertEquals(0x44444444 * (i+1) + 0x22222222, allclips[i].getY()); + Assert.assertEquals(0x44444444 * (i+1) + 0x33333333, allclips[i].getWidth()); + Assert.assertEquals(0x44444444 * (i+1) + 0x44444444, allclips[i].getHeight()); } + binding.destroySurface(surface); } @@ -1028,10 +1044,10 @@ public class BaseClass extends JunitTracer { } final TK_DimensionPair dimPair = TK_DimensionPair.create(); - dimPair.setPair(sumands); + dimPair.setPair(0, sumands); { sub++; - final TK_Dimension[] dimsGet = dimPair.getPair(); + final TK_Dimension[] dimsGet = dimPair.getPair(0, new TK_Dimension[2]); assertDim("ch11."+sub+": dimsGet[0] ", 11, 22, 33, 44, dimsGet[0]); assertDim("ch11."+sub+": dimsGet[1] ", 1, 2, 3, 4, dimsGet[1]); } @@ -1098,4 +1114,441 @@ public class BaseClass extends JunitTracer { Assert.assertEquals(3, result[0]); } } + + public static final float EPSILON = 1.1920929E-7f; // Float.MIN_VALUE == 1.4e-45f ; double EPSILON 2.220446049250313E-16d + + /** Test array and pointer bindings of structs */ + public void chapter12TestStructArrayModelConst(Bindingtest1 binding) throws Exception { + final TK_ModelConst model = binding.createModelConst(); + + Assert.assertEquals(3, model.getIntxxPointerCustomLenVal()); + Assert.assertEquals(3, model.getInt32PointerCustomLenVal()); + Assert.assertEquals(3, model.getInt32ArrayFixedLenArrayLength()); + Assert.assertEquals(3, model.getStructArrayFixedLenArrayLength()); + Assert.assertEquals(3, model.getStructPointerCustomLenVal()); + + // field: int32ArrayFixedLen + // CType['int32_t *', size [fixed false, lnx64 12], [array*1]], with array length of 3 + { + final int size = model.getInt32ArrayFixedLenArrayLength(); + final int[] all = model.getInt32ArrayFixedLen(0, new int[size]); + final IntBuffer allB = model.getInt32ArrayFixedLen(); + Assert.assertEquals(size, allB.limit()); + for(int i=0; i<size; i++) { + Assert.assertEquals(21 + i, all[i]); + Assert.assertEquals(21 + i, allB.get(i)); + final int[] s = model.getInt32ArrayFixedLen(i, new int[1]); + Assert.assertEquals(21 + i, s[0]); + } + } + + // field: int32ArrayOneElem + // CType['int32_t *', size [fixed false, lnx64 4], [array*1]], with array length of 1 + { + Assert.assertEquals(30, model.getInt32ArrayOneElem()); + } + + // field: int32PointerCustomLen + // field: CType['int32_t *', size [fixed false, lnx64 8], [pointer*1]], with array length of getInt32PointerCustomLenVal() + { + final int size = model.getInt32PointerCustomLenVal(); + final IntBuffer all = model.getInt32PointerCustomLen(); + Assert.assertEquals(size, all.limit()); + for(int i=0; i<size; i++) { + Assert.assertEquals(31 + i, all.get(i)); + } + } + + // field: int32PointerOneElem + // CType['int32_t *', size [fixed false, lnx64 8], [pointer*1]], with array length of 1 + { + final IntBuffer all = model.getInt32PointerOneElem(); + Assert.assertEquals(1, all.limit()); + Assert.assertEquals(41, all.get(0)); + } + + // field: mat4x4 + // CType['float * *', size [fixed false, lnx64 64], [array*2]], with array length of <code>4*4</code> */ + { + Assert.assertEquals(4*4, model.getMat4x4ArrayLength()); + final FloatBuffer mat4x4 = model.getMat4x4(); + Assert.assertEquals(4*4, mat4x4.limit()); + for(int i=0; i<4; i++) { + final float[] vec4 = model.getMat4x4(i*4, new float[4]); + for(int j=0; j<4; j++) { + Assert.assertEquals(i*4+j, mat4x4.get(i*4+j), EPSILON); + Assert.assertEquals(i*4+j, vec4[j], EPSILON); + } + } + } + + // field: structArrayFixedLen + // field: CType['TK_Dimension *', size [fixed false, lnx64 48], [array*1]], with array length of 3 + { + final int size = model.getStructArrayFixedLenArrayLength(); + final TK_Dimension[] all = model.getStructArrayFixedLen(0, new TK_Dimension[size]); + for(int i=0; i<size; i++) { + Assert.assertEquals(51 + i * 10, all[i].getX()); + Assert.assertEquals(52 + i * 10, all[i].getY()); + Assert.assertEquals(53 + i * 10, all[i].getWidth()); + Assert.assertEquals(54 + i * 10, all[i].getHeight()); + } + } + + // field: structArrayOneElem + // CType['TK_Dimension *', size [fixed false, lnx64 16], [array*1]], with array length of 1 + { + final TK_Dimension all = model.getStructArrayOneElem(); + Assert.assertEquals(81, all.getX()); + Assert.assertEquals(82, all.getY()); + Assert.assertEquals(83, all.getWidth()); + Assert.assertEquals(84, all.getHeight()); + } + + // field: structPointerCustomLen + // CType['TK_Dimension *', size [fixed false, lnx64 8], [pointer*1]], with array length of getStructPointerCustomLenVal() + { + final int size = model.getStructPointerCustomLenVal(); + final TK_Dimension[] all = model.getStructPointerCustomLen(0, new TK_Dimension[size]); + for(int i=0; i<size; i++) { + Assert.assertEquals(91 + i * 10, all[i].getX()); + Assert.assertEquals(92 + i * 10, all[i].getY()); + Assert.assertEquals(93 + i * 10, all[i].getWidth()); + Assert.assertEquals(94 + i * 10, all[i].getHeight()); + } + } + + // field: structPointerOneElem + // CType['TK_Dimension *', size [fixed false, lnx64 8], [pointer*1]], with array length of 1 + { + final TK_Dimension all = model.getStructPointerOneElem(); + Assert.assertEquals(121, all.getX()); + Assert.assertEquals(122, all.getY()); + Assert.assertEquals(123, all.getWidth()); + Assert.assertEquals(124, all.getHeight()); + + } + + final long surfaceContext = model.getCtx(); + assertAPTR(0x123456789abcdef0L, surfaceContext); + + model.setCtx(surfaceContext); + assertAPTR(surfaceContext, model.getCtx()); + + { + Assert.assertEquals(12, model.getModelNameArrayFixedLenArrayLength()); + + final ByteBuffer bb = model.getModelNameArrayFixedLen(); + Assert.assertEquals(12, bb.limit()); + + final String exp = "Hello Array"; + final String has = model.getModelNameArrayFixedLenAsString(); + // System.err.println("exp '"+exp+"'"); + System.err.println("has '"+has+"'"); + // dumpStringChars("exp", exp); + dumpStringChars("has", has); + Assert.assertEquals(11, has.length()); // w/o EOS + Assert.assertEquals(exp, has); + } + { + Assert.assertEquals(14, model.getModelNamePointerCStringArrayLength()); + + final ByteBuffer bb = model.getModelNamePointerCString(); + Assert.assertEquals(14, bb.limit()); + + final String exp = "Hello CString"; + final String has = model.getModelNamePointerCStringAsString(); + // System.err.println("exp '"+exp+"'"); + System.err.println("has '"+has+"'"); + // dumpStringChars("exp", exp); + dumpStringChars("has", has); + Assert.assertEquals(13, has.length()); // w/o EOS + Assert.assertEquals(exp, has); + } + { + Assert.assertEquals(14, model.getModelNamePointerCustomLenVal()); + + final ByteBuffer bb = model.getModelNamePointerCustomLen(); + Assert.assertEquals(14, bb.limit()); + + final String exp = "Hello Pointer"; + final String has = model.getModelNamePointerCustomLenAsString(); + // System.err.println("exp '"+exp+"'"); + System.err.println("has '"+has+"'"); + // dumpStringChars("exp", exp); + dumpStringChars("has", has); + Assert.assertEquals(13, has.length()); // w/o EOS + Assert.assertEquals(exp, has); + } + + binding.destroyModelConst(model); + } + private void dumpStringChars(String prefix, String s) { + final int len = s.length(); + for(int i=0; i<len; i++) { + final char c = s.charAt(i); + System.err.printf("%s %3d: 0x%X %c%n", prefix, i, (int)c, c); + } + } + + public void chapter13TestStructArrayModelMutable(Bindingtest1 binding) throws Exception { + final TK_ModelMutable model = binding.createModelMutable(); + + Assert.assertEquals(3, model.getIntxxPointerCustomLenVal()); + Assert.assertEquals(3, model.getInt32PointerCustomLenVal()); + Assert.assertEquals(3, model.getInt32ArrayFixedLenArrayLength()); + Assert.assertEquals(3, model.getStructArrayFixedLenArrayLength()); + Assert.assertEquals(3, model.getStructPointerCustomLenVal()); + + // field: int32ArrayFixedLen + // CType['int32_t *', size [fixed false, lnx64 12], [array*1]], with array length of 3 + { + final int size = model.getInt32ArrayFixedLenArrayLength(); + { + final int[] values = new int[] { 1, 2, 3 }; + model.setInt32ArrayFixedLen(0, values); + + final int[] all = model.getInt32ArrayFixedLen(0, new int[size]); + final IntBuffer allB = model.getInt32ArrayFixedLen(); + Assert.assertEquals(size, allB.limit()); + for(int i=0; i<size; i++) { + Assert.assertEquals(1 + i, all[i]); + Assert.assertEquals(1 + i, allB.get(i)); + final int[] s = model.getInt32ArrayFixedLen(i, new int[1]); + Assert.assertEquals(1 + i, s[0]); + } + } + { + for(int i=0; i<size; i++) { + final int[] ia = new int[] { 4 + i }; + model.setInt32ArrayFixedLen(i, ia); + } + + final int[] all = model.getInt32ArrayFixedLen(0, new int[size]); + final IntBuffer allB = model.getInt32ArrayFixedLen(); + Assert.assertEquals(size, allB.limit()); + for(int i=0; i<size; i++) { + Assert.assertEquals(4 + i, all[i]); + Assert.assertEquals(4 + i, allB.get(i)); + final int[] s = model.getInt32ArrayFixedLen(i, new int[1]); + Assert.assertEquals(4 + i, s[0]); + } + } + } + + // field: int32ArrayOneElem + // CType['int32_t *', size [fixed false, lnx64 4], [array*1]], with array length of 1 + { + model.setInt32ArrayOneElem(1); + Assert.assertEquals(1, model.getInt32ArrayOneElem()); + } + + // field: int32PointerCustomLen + // field: CType['int32_t *', size [fixed false, lnx64 8], [pointer*1]], with array length of getInt32PointerCustomLenVal() + { + final int size = model.getInt32PointerCustomLenVal(); + { + final IntBuffer all0 = model.getInt32PointerCustomLen(); + Assert.assertEquals(size, all0.limit()); + for(int i=0; i<size; i++) { + all0.put(i, 1+i); + } + + final IntBuffer all1 = model.getInt32PointerCustomLen(); + Assert.assertEquals(size, all1.limit()); + for(int i=0; i<size; i++) { + Assert.assertEquals(1 + i, all1.get(i)); + } + } + } + + // field: int32PointerOneElem + // CType['int32_t *', size [fixed false, lnx64 8], [pointer*1]], with array length of 1 + { + { + final IntBuffer one0 = model.getInt32PointerOneElem(); + Assert.assertEquals(1, one0.limit()); + one0.put(0, 1); + + final IntBuffer one1 = model.getInt32PointerOneElem(); + Assert.assertEquals(1, one1.limit()); + Assert.assertEquals(1, one1.get(0)); + } + } + + + // field: mat4x4 + // CType['float * *', size [fixed false, lnx64 64], [array*2]], with array length of <code>4*4</code> */ + { + model.setMat4x4(0*4, new float[] { 11, 12, 13, 14 } ); + model.setMat4x4(1*4, new float[] { 21, 22, 23, 24 } ); + model.setMat4x4(2*4, new float[] { 31, 32, 33, 34 } ); + model.setMat4x4(3*4, new float[] { 41, 42, 43, 44 } ); + + Assert.assertEquals(4*4, model.getMat4x4ArrayLength()); + final FloatBuffer mat4x4 = model.getMat4x4(); + Assert.assertEquals(4*4, mat4x4.limit()); + for(int i=0; i<4; i++) { + final float[] vec4 = model.getMat4x4(i*4, new float[4]); + for(int j=0; j<4; j++) { + Assert.assertEquals((i+1)*10+(j+1), mat4x4.get(i*4+j), EPSILON); + Assert.assertEquals((i+1)*10+(j+1), vec4[j], EPSILON); + } + } + } + + // field: structArrayFixedLen + // field: CType['TK_Dimension *', size [fixed false, lnx64 48], [array*1]], with array length of 3 + { + final int size = model.getStructArrayFixedLenArrayLength(); + { + for(int i=0; i<size; i++) { + final TK_Dimension d = TK_Dimension.create(); + d.setX(1+i*10); + d.setY(2+i*10); + d.setWidth(3+i*10); + d.setHeight(4+i*10); + model.setStructArrayFixedLen(i, d); + } + final TK_Dimension[] all = model.getStructArrayFixedLen(0, new TK_Dimension[size]); + for(int i=0; i<size; i++) { + Assert.assertEquals(1 + i * 10, all[i].getX()); + Assert.assertEquals(2 + i * 10, all[i].getY()); + Assert.assertEquals(3 + i * 10, all[i].getWidth()); + Assert.assertEquals(4 + i * 10, all[i].getHeight()); + final TK_Dimension[] one = model.getStructArrayFixedLen(i, new TK_Dimension[1]); + Assert.assertEquals(1 + i * 10, one[0].getX()); + Assert.assertEquals(2 + i * 10, one[0].getY()); + Assert.assertEquals(3 + i * 10, one[0].getWidth()); + Assert.assertEquals(4 + i * 10, one[0].getHeight()); + } + } + { + final TK_Dimension[] da = new TK_Dimension[size]; + for(int i=0; i<size; i++) { + final TK_Dimension d = TK_Dimension.create(); + d.setX(5+i*10); + d.setY(6+i*10); + d.setWidth(7+i*10); + d.setHeight(8+i*10); + da[i] = d; + } + model.setStructArrayFixedLen(0, da); + + final TK_Dimension[] all = model.getStructArrayFixedLen(0, new TK_Dimension[size]); + for(int i=0; i<size; i++) { + Assert.assertEquals(5 + i * 10, all[i].getX()); + Assert.assertEquals(6 + i * 10, all[i].getY()); + Assert.assertEquals(7 + i * 10, all[i].getWidth()); + Assert.assertEquals(8 + i * 10, all[i].getHeight()); + final TK_Dimension[] one = model.getStructArrayFixedLen(i, new TK_Dimension[1]); + Assert.assertEquals(5 + i * 10, one[0].getX()); + Assert.assertEquals(6 + i * 10, one[0].getY()); + Assert.assertEquals(7 + i * 10, one[0].getWidth()); + Assert.assertEquals(8 + i * 10, one[0].getHeight()); + } + } + { + for(int i=0; i<size; i++) { + final TK_Dimension d = TK_Dimension.create(); + d.setX(1+i*10); + d.setY(3+i*10); + d.setWidth(5+i*10); + d.setHeight(7+i*10); + model.setStructArrayFixedLen(i, new TK_Dimension[] { d }); + } + + final TK_Dimension[] all = model.getStructArrayFixedLen(0, new TK_Dimension[size]); + for(int i=0; i<size; i++) { + Assert.assertEquals(1 + i * 10, all[i].getX()); + Assert.assertEquals(3 + i * 10, all[i].getY()); + Assert.assertEquals(5 + i * 10, all[i].getWidth()); + Assert.assertEquals(7 + i * 10, all[i].getHeight()); + final TK_Dimension[] one = model.getStructArrayFixedLen(i, new TK_Dimension[1]); + Assert.assertEquals(1 + i * 10, one[0].getX()); + Assert.assertEquals(3 + i * 10, one[0].getY()); + Assert.assertEquals(5 + i * 10, one[0].getWidth()); + Assert.assertEquals(7 + i * 10, one[0].getHeight()); + } + } + } + + // field: structArrayOneElem + // CType['TK_Dimension *', size [fixed false, lnx64 16], [array*1]], with array length of 1 + { + { + final TK_Dimension d = TK_Dimension.create(); + d.setX(1); + d.setY(2); + d.setWidth(3); + d.setHeight(4); + model.setStructArrayOneElem(d); + } + { + final TK_Dimension one = model.getStructArrayOneElem(); + Assert.assertEquals(1, one.getX()); + Assert.assertEquals(2, one.getY()); + Assert.assertEquals(3, one.getWidth()); + Assert.assertEquals(4, one.getHeight()); + } + } + + // field: structPointerCustomLen + // CType['TK_Dimension *', size [fixed false, lnx64 8], [pointer*1]], with array length of getStructPointerCustomLenVal() + { + final int size = model.getStructPointerCustomLenVal(); + { + final TK_Dimension[] all = model.getStructPointerCustomLen(0, new TK_Dimension[size]); + for(int i=0; i<size; i++) { + final TK_Dimension d = all[i]; + d.setX(1+i*10); + d.setY(2+i*10); + d.setWidth(3+i*10); + d.setHeight(4+i*10); + } + } + { + final TK_Dimension[] all = model.getStructPointerCustomLen(0, new TK_Dimension[size]); + for(int i=0; i<size; i++) { + Assert.assertEquals(1 + i * 10, all[i].getX()); + Assert.assertEquals(2 + i * 10, all[i].getY()); + Assert.assertEquals(3 + i * 10, all[i].getWidth()); + Assert.assertEquals(4 + i * 10, all[i].getHeight()); + final TK_Dimension[] one = model.getStructPointerCustomLen(i, new TK_Dimension[1]); + Assert.assertEquals(1 + i * 10, one[0].getX()); + Assert.assertEquals(2 + i * 10, one[0].getY()); + Assert.assertEquals(3 + i * 10, one[0].getWidth()); + Assert.assertEquals(4 + i * 10, one[0].getHeight()); + } + } + } + + // field: structPointerOneElem + // CType['TK_Dimension *', size [fixed false, lnx64 8], [pointer*1]], with array length of 1 + { + { + final TK_Dimension d = model.getStructPointerOneElem(); + d.setX(1); + d.setY(2); + d.setWidth(3); + d.setHeight(4); + } + { + final TK_Dimension one = model.getStructPointerOneElem(); + Assert.assertEquals(1, one.getX()); + Assert.assertEquals(2, one.getY()); + Assert.assertEquals(3, one.getWidth()); + Assert.assertEquals(4, one.getHeight()); + } + + } + + final long surfaceContext = model.getCtx(); + assertAPTR(0x123456789abcdef0L, surfaceContext); + + model.setCtx(surfaceContext); + assertAPTR(surfaceContext, model.getCtx()); + + binding.destroyModelMutable(model); + } } diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p1JavaEmitter.java b/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p1JavaEmitter.java index e63f255..e3e3ca9 100644 --- a/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p1JavaEmitter.java +++ b/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p1JavaEmitter.java @@ -132,6 +132,22 @@ public class Test1p1JavaEmitter extends BaseClass { chapter11TestCompoundCallByValue(new Bindingtest1p1Impl()); } + /** + * Test compound access read-only + */ + @Test + public void chapter12TestStructArrayModelConst() throws Exception { + chapter12TestStructArrayModelConst(new Bindingtest1p1Impl()); + } + + /** + * Test compound access read-write + */ + @Test + public void chapter13TestStructArrayModelMutable() throws Exception { + chapter13TestStructArrayModelMutable(new Bindingtest1p1Impl()); + } + public static void main(String args[]) throws IOException { String tstname = Test1p1JavaEmitter.class.getName(); org.junit.runner.JUnitCore.main(tstname); diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p2ProcAddressEmitter.java b/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p2ProcAddressEmitter.java index 07201c0..39e3948 100644 --- a/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p2ProcAddressEmitter.java +++ b/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p2ProcAddressEmitter.java @@ -30,7 +30,6 @@ package com.jogamp.gluegen.test.junit.generation; import java.io.IOException; -import com.jogamp.gluegen.test.junit.generation.impl.Bindingtest1p1Impl; import com.jogamp.gluegen.test.junit.generation.impl.Bindingtest1p2Impl; import com.jogamp.common.os.NativeLibrary; @@ -142,6 +141,22 @@ public class Test1p2ProcAddressEmitter extends BaseClass { } /** + * Test compound access read-only + */ + @Test + public void chapter12TestStructArrayModelConst() throws Exception { + chapter12TestStructArrayModelConst(new Bindingtest1p2Impl()); + } + + /** + * Test compound access read-write + */ + @Test + public void chapter13TestStructArrayModelMutable() throws Exception { + chapter13TestStructArrayModelMutable(new Bindingtest1p2Impl()); + } + + /** * Verifies unloading of the new library. */ @AfterClass 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 d4e32cc..eca133e 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 @@ -41,8 +41,12 @@ EmitStruct TK_Dimension StructPackage TK_DimensionPair com.jogamp.gluegen.test.junit.generation EmitStruct TK_DimensionPair +EmitStruct TK_Surface StructPackage TK_Surface com.jogamp.gluegen.test.junit.generation EmitStruct TK_Surface +ReturnedArrayLength TK_Surface.clips getClipSize() +IgnoreField TK_Surface GetComponent + # Implements TK_Surface TḴ_??? StructPackage TK_ComplicatedSuperSet com.jogamp.gluegen.test.junit.generation @@ -50,10 +54,44 @@ EmitStruct TK_ComplicatedSuperSet # Implements TK_ComplicatedSuperSet TḴ_??? ReturnValueCapacity createSurface sizeof(TK_Surface) -ReturnValueCapacity getClip sizeof(TK_Dimension) +ReturnValueCapacity TK_Surface.getClip sizeof(TK_Dimension) ReturnValueCapacity createComplicatedSuperSet sizeof(TK_ComplicatedSuperSet) +EmitStruct TK_ModelConst +StructPackage TK_ModelConst com.jogamp.gluegen.test.junit.generation +ReturnedArrayLength TK_ModelConst.intxxArrayCustomLen getIntxxArrayCustomLenVal() +ReturnedArrayLength TK_ModelConst.intxxPointerCustomLen getIntxxPointerCustomLenVal() +ReturnedArrayLength TK_ModelConst.int32ArrayCustomLen getInt32ArrayCustomLenVal() +ReturnedArrayLength TK_ModelConst.int32PointerCustomLen getInt32PointerCustomLenVal() +ReturnedArrayLength TK_ModelConst.structArrayCustomLen getStructArrayCustomLenVal() +ReturnedArrayLength TK_ModelConst.structPointerCustomLen getStructPointerCustomLenVal() +ReturnedArrayLength TK_ModelConst.int32PointerOneElem 1 +ReturnValueCapacity TK_ModelConst.int32PointerOneElem 1 * sizeof(int32_t) /* overridden by ReturnValueCapacity */ +ReturnedArrayLength TK_ModelConst.structPointerOneElem 1 +ReturnsString TK_ModelConst.modelNameArrayFixedLen +ReturnsString TK_ModelConst.modelNamePointerCString +ReturnsString TK_ModelConst.modelNamePointerCustomLen +ReturnedArrayLength TK_ModelConst.modelNamePointerCustomLen getModelNamePointerCustomLenVal() + +EmitStruct TK_ModelMutable +StructPackage TK_ModelMutable com.jogamp.gluegen.test.junit.generation +ReturnedArrayLength TK_ModelMutable.intxxArrayCustomLen getIntxxArrayCustomLenVal() +ReturnedArrayLength TK_ModelMutable.intxxPointerCustomLen getIntxxPointerCustomLenVal() +ReturnedArrayLength TK_ModelMutable.int32ArrayCustomLen getInt32ArrayCustomLenVal() +ReturnedArrayLength TK_ModelMutable.int32PointerCustomLen getInt32PointerCustomLenVal() +ReturnedArrayLength TK_ModelMutable.structArrayCustomLen getStructArrayCustomLenVal() +ReturnedArrayLength TK_ModelMutable.structPointerCustomLen getStructPointerCustomLenVal() +ReturnedArrayLength TK_ModelMutable.int32PointerOneElem 1 +ReturnedArrayLength TK_ModelMutable.structPointerOneElem 1 +ReturnsString TK_ModelMutable.modelNameArrayFixedLen +ReturnsString TK_ModelMutable.modelNamePointerCString +ReturnsString TK_ModelMutable.modelNamePointerCustomLen +ReturnedArrayLength TK_ModelMutable.modelNamePointerCustomLen getModelNamePointerCustomLenVal() + +ReturnValueCapacity createModelConst sizeof(TK_ModelConst) +ReturnValueCapacity createModelMutable sizeof(TK_ModelMutable) + # Imports needed by all glue code Import java.nio.* Import java.util.* @@ -65,6 +103,8 @@ 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 +Import com.jogamp.gluegen.test.junit.generation.TK_ModelConst +Import com.jogamp.gluegen.test.junit.generation.TK_ModelMutable 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 3dc1ac5..9999274 100644 --- a/src/junit/com/jogamp/gluegen/test/junit/generation/test1.c +++ b/src/junit/com/jogamp/gluegen/test/junit/generation/test1.c @@ -372,6 +372,7 @@ MYAPI TK_Surface * MYAPIENTRY createSurface() { MYAPI void MYAPIENTRY destroySurface(TK_Surface * surface) { assert(NULL!=surface); + assert(NULL!=surface->clips); free(surface->clips); // free(surface->engine); free(surface); @@ -578,3 +579,112 @@ MYAPI void MYAPIENTRY addByte(const char summands[2], char result[1]) { result[0] = summands[0] + summands[1]; } +MYAPI TK_ModelMutable * MYAPIENTRY createModelMutable() { + int i, j; + TK_ModelMutable * s = calloc(1, sizeof(TK_ModelMutable)); + + s->intxxArrayFixedLen[0]=1; + s->intxxArrayFixedLen[1]=2; + s->intxxArrayFixedLen[2]=3; + + s->intxxPointerCustomLen = calloc(3, sizeof(int)); + s->intxxPointerCustomLen[0] = 11; + s->intxxPointerCustomLen[1] = 12; + s->intxxPointerCustomLen[2] = 13; + s->intxxPointerCustomLenVal=3; + + s->int32ArrayFixedLen[0] = 21; + s->int32ArrayFixedLen[1] = 22; + s->int32ArrayFixedLen[2] = 23; + + s->int32ArrayOneElem[0] = 30; + + s->int32PointerCustomLen = calloc(3, sizeof(int)); + s->int32PointerCustomLen[0] = 31; + s->int32PointerCustomLen[1] = 32; + s->int32PointerCustomLen[2] = 33; + s->int32PointerCustomLenVal=3; + + s->int32PointerOneElem = calloc(1, sizeof(int)); + s->int32PointerOneElem[0] = 41; + + for(i=0; i<4; i++) { + for(j=0; j<4; j++) { + s->mat4x4[i][j] = i*4 + j; + } + } + + s->structArrayFixedLen[0].x = 51; + s->structArrayFixedLen[0].y = 52; + s->structArrayFixedLen[0].width = 53; + s->structArrayFixedLen[0].height = 54; + s->structArrayFixedLen[1].x = 61; + s->structArrayFixedLen[1].y = 62; + s->structArrayFixedLen[1].width = 63; + s->structArrayFixedLen[1].height = 64; + s->structArrayFixedLen[2].x = 71; + s->structArrayFixedLen[2].y = 72; + s->structArrayFixedLen[2].width = 73; + s->structArrayFixedLen[2].height = 74; + + s->structArrayOneElem[0].x = 81; + s->structArrayOneElem[0].y = 82; + s->structArrayOneElem[0].width = 83; + s->structArrayOneElem[0].height = 84; + + s->structPointerCustomLen = (TK_Dimension *) calloc(3, sizeof(TK_Dimension)); + s->structPointerCustomLen[0].x = 91; + s->structPointerCustomLen[0].y = 92; + s->structPointerCustomLen[0].width = 93; + s->structPointerCustomLen[0].height = 94; + s->structPointerCustomLen[1].x = 101; + s->structPointerCustomLen[1].y = 102; + s->structPointerCustomLen[1].width = 103; + s->structPointerCustomLen[1].height = 104; + s->structPointerCustomLen[2].x = 111; + s->structPointerCustomLen[2].y = 112; + s->structPointerCustomLen[2].width = 113; + s->structPointerCustomLen[2].height = 114; + s->structPointerCustomLenVal = 3; + + s->structPointerOneElem = (TK_Dimension *) calloc(1, sizeof(TK_Dimension)); + s->structPointerOneElem[0].x = 121; + s->structPointerOneElem[0].y = 122; + s->structPointerOneElem[0].width = 123; + s->structPointerOneElem[0].height = 124; + + s->ctx = (void *) 0x123456789abcdef0UL; + + strncpy(s->modelNameArrayFixedLen, "Hello Array", sizeof(s->modelNameArrayFixedLen)); + + s->modelNamePointerCString = calloc(13+1, sizeof(char)); + strncpy(s->modelNamePointerCString, "Hello CString", 13+1); + + s->modelNamePointerCustomLen = calloc(13+1, sizeof(char)); + strncpy(s->modelNamePointerCustomLen, "Hello Pointer", 13+1); + s->modelNamePointerCustomLenVal = 13+1; + + return s; +} + +MYAPI void MYAPIENTRY destroyModelMutable(TK_ModelMutable * s) { + assert(NULL!=s); + assert(NULL!=s->intxxPointerCustomLen); + assert(NULL!=s->int32PointerCustomLen); + assert(NULL!=s->int32PointerOneElem); + assert(NULL!=s->structPointerCustomLen); + free(s->intxxPointerCustomLen); + free(s->int32PointerCustomLen); + free(s->int32PointerOneElem); + free(s->structPointerCustomLen); + free(s->modelNamePointerCString); + free(s->modelNamePointerCustomLen); + free(s); +} + +MYAPI TK_ModelConst * MYAPIENTRY createModelConst() { + return (TK_ModelConst *)createModelMutable(); +} +MYAPI void MYAPIENTRY destroyModelConst(TK_ModelConst * s) { + destroyModelMutable((TK_ModelMutable *)s); +} 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 7343172..ebb41d3 100644 --- a/src/junit/com/jogamp/gluegen/test/junit/generation/test1.h +++ b/src/junit/com/jogamp/gluegen/test/junit/generation/test1.h @@ -183,15 +183,23 @@ typedef struct { TK_Context ctx; } TK_ContextWrapper; +struct _jobject; +typedef struct _jobject *jobject; +struct JNINativeInterface_; +typedef const struct JNINativeInterface_ *JNIEnv; + + typedef struct tk_Surface { TK_Context ctx; TK_ContextWrapper ctxWrapper; - // const TK_Engine * engine; TK_Engine engine; TK_Dimension bounds; int32_t clipSize; TK_Dimension * clips; TK_Dimension * (MYAPIENTRY *getClip) (struct tk_Surface * ds, int idx); + + jobject (MYAPIENTRY *GetComponent)(JNIEnv* env, void* platformInfo); + } TK_Surface; typedef struct { @@ -274,3 +282,71 @@ MYAPI void MYAPIENTRY intToRgba(int irgba, char rgbaSink[4]); MYAPI void MYAPIENTRY addInt(const int summands[2], int result[1]); MYAPI void MYAPIENTRY addByte(const char summands[2], char result[1]); +typedef struct { + const int intxxArrayFixedLen[3]; + + const int * intxxPointerCustomLen; + const int intxxPointerCustomLenVal; + + const int32_t int32ArrayFixedLen[3]; + const int32_t int32ArrayOneElem[1]; + + const int32_t * int32PointerCustomLen; + const int32_t int32PointerCustomLenVal; + + const int32_t * int32PointerOneElem; + + const float mat4x4[4][4]; + + const TK_Dimension structArrayFixedLen[3]; + const TK_Dimension structArrayOneElem[1]; + + const TK_Dimension * structPointerCustomLen; + const int32_t structPointerCustomLenVal; + const TK_Dimension * structPointerOneElem; + + const TK_Context ctx; + + const char modelNameArrayFixedLen[12]; /* 'Hello Array' len=11+1 */ + const char * modelNamePointerCString; /* 'Hello CString' len=13+1 */ + const char * modelNamePointerCustomLen; /* 'Hello Pointer' len=13+1 */ + const int modelNamePointerCustomLenVal; /* 13+1 */ + +} TK_ModelConst; + +typedef struct { + int intxxArrayFixedLen[3]; + + int * intxxPointerCustomLen; + int intxxPointerCustomLenVal; + + int32_t int32ArrayFixedLen[3]; + int32_t int32ArrayOneElem[1]; + + int32_t * int32PointerCustomLen; + int32_t int32PointerCustomLenVal; + + int32_t * int32PointerOneElem; + + float mat4x4[4][4]; + + TK_Dimension structArrayFixedLen[3]; + TK_Dimension structArrayOneElem[1]; + + TK_Dimension * structPointerCustomLen; + int32_t structPointerCustomLenVal; + TK_Dimension * structPointerOneElem; + + TK_Context ctx; + + char modelNameArrayFixedLen[12]; /* 'Hello Array' len=11+1 */ + const char * modelNamePointerCString; /* 'Hello CString' len=13+1 */ + char * modelNamePointerCustomLen; /* 'Hello Pointer' len=13+1 */ + int modelNamePointerCustomLenVal; /* 13+1 */ + +} TK_ModelMutable; + +MYAPI TK_ModelConst * MYAPIENTRY createModelConst(); +MYAPI void MYAPIENTRY destroyModelConst(TK_ModelConst * s); +MYAPI TK_ModelMutable * MYAPIENTRY createModelMutable(); +MYAPI void MYAPIENTRY destroyModelMutable(TK_ModelMutable * s); |