diff options
Diffstat (limited to 'src/junit')
4 files changed, 74 insertions, 21 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 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]); |