summaryrefslogtreecommitdiffstats
path: root/src/junit/com/jogamp/gluegen
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2014-06-17 08:26:36 +0200
committerSven Gothel <[email protected]>2014-06-17 08:26:36 +0200
commitf4e753ff1f39be381307ffdb0fb6bb7a2d323eff (patch)
tree156e7c1bdad95420754098fb3fe9522b4cf38edd /src/junit/com/jogamp/gluegen
parenta75276408c9bcff77f568cf72b6c71e421a07552 (diff)
GlueGen: Add support for 'compound array call-by-value'
Completing commit c3054a01990e55ab35756ea23ab7d7c05f24dd37 by allowing passing compound arrays via 'call-by-value. - Creating linear temp heap, copying NIO values into it and passing to C function. Copy-back if not 'const', see below. - Respect 'const' qualifier to skip write-back of temp heap passed to C function - See tag: // FIXME: Compound and Compound-Arrays for code changes and validation of completeness - triggers for compound arrays are: - javaType.isArrayOfCompoundTypeWrappers() - type.isArray() - simplified const query by c-type: FunctionEmitter.isBaseTypeConst(ctype) +++ Tests: Added call-by-value to test1.[ch] binding test!
Diffstat (limited to 'src/junit/com/jogamp/gluegen')
-rw-r--r--src/junit/com/jogamp/gluegen/test/junit/generation/BaseClass.java24
-rw-r--r--src/junit/com/jogamp/gluegen/test/junit/generation/test1.c15
-rw-r--r--src/junit/com/jogamp/gluegen/test/junit/generation/test1.h3
3 files changed, 42 insertions, 0 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 79af1b7..900d959 100644
--- a/src/junit/com/jogamp/gluegen/test/junit/generation/BaseClass.java
+++ b/src/junit/com/jogamp/gluegen/test/junit/generation/BaseClass.java
@@ -1011,5 +1011,29 @@ public class BaseClass extends JunitTracer {
System.err.println("ch11.3: sameInstanceByRef "+sameInstanceByRef);
Assert.assertFalse(sameInstanceByVal);
Assert.assertFalse(sameInstanceByRef);
+
+ final TK_Dimension dim2 = binding.getBoundsValue(1, 2, 3, 4);
+ final TK_Dimension[] sumands = { dim1, dim2 };
+ final TK_Dimension dimSum = binding.addDimensions(sumands);
+ {
+ dumpDim("ch11.4: sum-dim ", dimSum);
+ Assert.assertEquals(11+1, dimSum.getX());
+ Assert.assertEquals(22+2, dimSum.getY());
+ Assert.assertEquals(33+3, dimSum.getWidth());
+ Assert.assertEquals(44+4, dimSum.getHeight());
+ }
+ binding.zeroDimensions(sumands);
+ {
+ dumpDim("ch11.5: zero-dim[0] ", sumands[0]);
+ dumpDim("ch11.5: zero-dim[1] ", sumands[1]);
+ Assert.assertEquals(0, sumands[0].getX());
+ Assert.assertEquals(0, sumands[0].getY());
+ Assert.assertEquals(0, sumands[0].getWidth());
+ Assert.assertEquals(0, sumands[0].getHeight());
+ Assert.assertEquals(0, sumands[1].getX());
+ Assert.assertEquals(0, sumands[1].getY());
+ Assert.assertEquals(0, sumands[1].getWidth());
+ Assert.assertEquals(0, sumands[1].getHeight());
+ }
}
}
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 9b2fb2d..ca24444 100644
--- a/src/junit/com/jogamp/gluegen/test/junit/generation/test1.c
+++ b/src/junit/com/jogamp/gluegen/test/junit/generation/test1.c
@@ -528,3 +528,18 @@ 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]) {
+ 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 void MYAPIENTRY zeroDimensions(TK_Dimension s[2]) {
+ s[0].x = 0;
+ s[0].y = 0;
+ s[0].width = 0;
+ s[0].height = 0;
+ s[1].x = 0;
+ s[1].y = 0;
+ s[1].width = 0;
+ s[1].height = 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 779e65d..a487f7a 100644
--- a/src/junit/com/jogamp/gluegen/test/junit/generation/test1.h
+++ b/src/junit/com/jogamp/gluegen/test/junit/generation/test1.h
@@ -250,3 +250,6 @@ 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 void MYAPIENTRY zeroDimensions(TK_Dimension s[2]);
+