summaryrefslogtreecommitdiffstats
path: root/src/junit/com/jogamp
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2010-03-29 04:24:20 +0200
committerSven Gothel <[email protected]>2010-03-29 04:24:20 +0200
commit2138fc787c1e497be7f373aa68b3f751c955008f (patch)
treed4b1a1dc63602bef8073e70d709faa2821b5dddd /src/junit/com/jogamp
parentca2ccb29bd3cd4d9c73ca96ce02402888ac9e9af (diff)
New Int64Buffer type, which is being used for gluegen 'long *'
Diffstat (limited to 'src/junit/com/jogamp')
-rw-r--r--src/junit/com/jogamp/gluegen/test/junit/BaseTest1.java96
-rw-r--r--src/junit/com/jogamp/gluegen/test/junit/test1.c48
-rw-r--r--src/junit/com/jogamp/gluegen/test/junit/test1.h22
3 files changed, 114 insertions, 52 deletions
diff --git a/src/junit/com/jogamp/gluegen/test/junit/BaseTest1.java b/src/junit/com/jogamp/gluegen/test/junit/BaseTest1.java
index ddf2906..f030459 100644
--- a/src/junit/com/jogamp/gluegen/test/junit/BaseTest1.java
+++ b/src/junit/com/jogamp/gluegen/test/junit/BaseTest1.java
@@ -34,6 +34,7 @@ package com.jogamp.gluegen.test.junit;
import com.jogamp.gluegen.runtime.BufferFactory;
import com.jogamp.gluegen.runtime.PointerBuffer;
+import com.jogamp.gluegen.runtime.Int64Buffer;
import java.nio.*;
import java.io.File;
import java.lang.reflect.InvocationTargetException;
@@ -87,30 +88,35 @@ public class BaseTest1 {
long result;
long context = 0;
ByteBuffer bb=null;
- PointerBuffer pb=null;
- LongBuffer lb=null;
+ Int64Buffer lb=null;
+ IntBuffer ib=null;
long[] larray = null;
- int array_offset = 0;
+ int larray_offset = 0;
String str=null;
String[] strings = null;
- IntBuffer ib = null;
int[] iarray = null;
int iarray_offset = 0;
- result = binding.arrayTest(context, pb);
- result = binding.arrayTest(context, larray, array_offset);
- result = binding.arrayTestNioOnly(context, pb);
+ result = binding.arrayTestInt32(context, ib);
+ result = binding.arrayTestInt32(context, iarray, iarray_offset);
+
+ result = binding.arrayTestInt64(context, lb);
+ result = binding.arrayTestInt64(context, larray, larray_offset);
+
+ result = binding.arrayTestFoo(context, lb);
+ result = binding.arrayTestFoo(context, larray, larray_offset);
+ result = binding.arrayTestFooNioOnly(context, lb);
result = binding.bufferTest(bb);
result = binding.bufferTestNioOnly(bb);
- result = binding.doubleTest(context, bb, pb, bb, pb);
- result = binding.doubleTest(context, bb, larray, array_offset, bb, larray, array_offset);
- result = binding.doubleTestNioOnly(context, bb, pb, bb, pb);
+ result = binding.doubleTest(context, bb, lb, bb, lb);
+ result = binding.doubleTest(context, bb, larray, larray_offset, bb, larray, larray_offset);
+ result = binding.doubleTestNioOnly(context, bb, lb, bb, lb);
- result = binding.mixedTest(context, bb, pb);
- result = binding.mixedTest(context, bb, larray, array_offset);
- result = binding.mixedTestNioOnly(context, bb, pb);
+ result = binding.mixedTest(context, bb, lb);
+ result = binding.mixedTest(context, bb, larray, larray_offset);
+ result = binding.mixedTestNioOnly(context, bb, lb);
result = binding.nopTest();
@@ -135,66 +141,88 @@ public class BaseTest1 {
long result;
long context = 1;
- ByteBuffer bb1 = BufferFactory.newDirectByteBuffer(BufferFactory.SIZEOF_LONG);
- LongBuffer bb1L = bb1.asLongBuffer();
- bb1L.put(0, 10);
+ Int64Buffer lb = Int64Buffer.allocateDirect(1);
+ lb.put(0, 10);
ByteBuffer bb2 = BufferFactory.newDirectByteBuffer(BufferFactory.SIZEOF_LONG);
- LongBuffer bb2L = bb2.asLongBuffer();
+ Int64Buffer bb2L = Int64Buffer.wrap(bb2);
bb2L.put(0, 100);
- PointerBuffer pb1 = PointerBuffer.allocateDirect(BindingTest1.ARRAY_SIZE);
+ IntBuffer ib1 = BufferFactory.newDirectByteBuffer(BufferFactory.SIZEOF_INT * BindingTest1.ARRAY_SIZE).asIntBuffer();
+ for(i=0; i<BindingTest1.ARRAY_SIZE; i++) {
+ ib1.put(i, 1000);
+ }
+
+ Int64Buffer lb1 = Int64Buffer.allocateDirect(BindingTest1.ARRAY_SIZE);
+ for(i=0; i<BindingTest1.ARRAY_SIZE; i++) {
+ lb1.put(i, 1000);
+ }
+ Int64Buffer lb2 = Int64Buffer.allocateDirect(BindingTest1.ARRAY_SIZE);
for(i=0; i<BindingTest1.ARRAY_SIZE; i++) {
- pb1.put(i, 1000);
+ lb2.put(i, 10000);
}
- PointerBuffer pb2 = PointerBuffer.allocateDirect(BindingTest1.ARRAY_SIZE);
+
+ int[] iarray1 = new int[BindingTest1.ARRAY_SIZE];
+ int iarray1_offset = 0;
for(i=0; i<BindingTest1.ARRAY_SIZE; i++) {
- pb2.put(i, 10000);
+ iarray1[i]= 1000;
}
long[] larray1 = new long[BindingTest1.ARRAY_SIZE];
- int array1_offset = 0;
+ int larray1_offset = 0;
for(i=0; i<BindingTest1.ARRAY_SIZE; i++) {
larray1[i]= 1000;
}
long[] larray2 = new long[BindingTest1.ARRAY_SIZE];
- int array2_offset = 0;
+ int larray2_offset = 0;
for(i=0; i<BindingTest1.ARRAY_SIZE; i++) {
larray2[i]= 10000;
}
- result = binding.arrayTest(context, pb1);
+ result = binding.arrayTestInt32(context, ib1);
+ Assert.assertTrue("Wrong result: "+result, 1+8000==result);
+
+ result = binding.arrayTestInt32(context, iarray1, iarray1_offset);
+ Assert.assertTrue("Wrong result: "+result, 1+8000==result);
+
+ result = binding.arrayTestInt64(context, lb1);
+ Assert.assertTrue("Wrong result: "+result, 1+8000==result);
+
+ result = binding.arrayTestInt64(context, larray1, larray1_offset);
+ Assert.assertTrue("Wrong result: "+result, 1+8000==result);
+
+ result = binding.arrayTestFoo(context, lb1);
Assert.assertTrue("Wrong result: "+result, 1+8000==result);
- result = binding.arrayTest(context, larray1, array1_offset);
+ result = binding.arrayTestFoo(context, larray1, larray1_offset);
Assert.assertTrue("Wrong result: "+result, 1+8000==result);
- result = binding.arrayTestNioOnly(context, pb1);
+ result = binding.arrayTestFooNioOnly(context, lb1);
Assert.assertTrue("Wrong result: "+result, 1+8000==result);
- result = binding.bufferTest(bb1);
+ result = binding.bufferTest(lb.getBuffer());
Assert.assertTrue("Wrong result: "+result, 10==result);
- result = binding.bufferTestNioOnly(bb1);
+ result = binding.bufferTestNioOnly(lb.getBuffer());
Assert.assertTrue("Wrong result: "+result, 10==result);
- result = binding.doubleTest(context, bb1, pb1, bb2, pb2);
+ result = binding.doubleTest(context, lb.getBuffer(), lb1, bb2, lb2);
Assert.assertTrue("Wrong result: "+result, 1+10+8000+100+80000==result);
- result = binding.doubleTest(context, bb1, larray1, array1_offset, bb2, larray2, array2_offset);
+ result = binding.doubleTest(context, lb.getBuffer(), larray1, larray1_offset, bb2, larray2, larray2_offset);
Assert.assertTrue("Wrong result: "+result, 1+10+8000+100+80000==result);
- result = binding.doubleTestNioOnly(context, bb1, pb1, bb2, pb2);
+ result = binding.doubleTestNioOnly(context, lb.getBuffer(), lb1, bb2, lb2);
Assert.assertTrue("Wrong result: "+result, 1+10+8000+100+80000==result);
- result = binding.mixedTest(context, bb1, pb1);
+ result = binding.mixedTest(context, lb.getBuffer(), lb1);
Assert.assertTrue("Wrong result: "+result, 1+10+8000==result);
- result = binding.mixedTest(context, bb1, larray1, array1_offset);
+ result = binding.mixedTest(context, lb.getBuffer(), larray1, larray1_offset);
Assert.assertTrue("Wrong result: "+result, 1+10+8000==result);
- result = binding.mixedTestNioOnly(context, bb1, pb1);
+ result = binding.mixedTestNioOnly(context, lb.getBuffer(), lb1);
Assert.assertTrue("Wrong result: "+result, 1+10+8000==result);
result = binding.nopTest();
diff --git a/src/junit/com/jogamp/gluegen/test/junit/test1.c b/src/junit/com/jogamp/gluegen/test/junit/test1.c
index 31c5f40..0fa4abb 100644
--- a/src/junit/com/jogamp/gluegen/test/junit/test1.c
+++ b/src/junit/com/jogamp/gluegen/test/junit/test1.c
@@ -1,18 +1,44 @@
#include "test1.h"
#include <assert.h>
#include <stdlib.h>
+#include <stdio.h>
foo nopTest() {
return 42;
}
-foo arrayTest(long context, foo * array) {
+int32_t arrayTestInt32(int64_t context, int32_t * array) {
+ int32_t r=0;
+ int i;
+ assert(NULL!=array);
+ // printf("array test - %p sizeof(int32_t) %d\n", array, sizeof(int32_t));
+ for(i=0; i<ARRAY_SIZE; i++) {
+ r+=array[i];
+ // printf("array[%d]: %d -> %d\n", i, array[i], r);
+ }
+ return r+context;
+}
+
+int64_t arrayTestInt64(int64_t context, int64_t * array) {
+ int64_t r=0;
+ int i;
+ assert(NULL!=array);
+ // printf("array test - %p sizeof(int64_t) %d\n", array, sizeof(int64_t));
+ for(i=0; i<ARRAY_SIZE; i++) {
+ r+=array[i];
+ // printf("array[%d]: %d -> %d\n", i, array[i], r);
+ }
+ return r+context;
+}
+
+foo arrayTestFoo(int64_t context, foo * array) {
foo r=0;
int i;
assert(NULL!=array);
- // printf("array test - %p\n", array);
+ // printf("array test - %p sizeof(foo) %d\n", array, sizeof(foo));
for(i=0; i<ARRAY_SIZE; i++) {
r+=array[i];
+ // printf("array[%d]: %d -> %d\n", i, array[i], r);
}
return r+context;
}
@@ -22,36 +48,36 @@ foo bufferTest(void * object) {
return *((foo *)object);
}
-foo mixedTest(long context, void * object, foo * array){
+foo mixedTest(int64_t context, void * object, foo * array){
assert(NULL!=object);
assert(NULL!=array);
- return arrayTest(context, array) + bufferTest(object);
+ return arrayTestFoo(context, array) + bufferTest(object);
}
-foo doubleTest(long context, void * object1, foo * array1, void * object2, foo * array2) {
+foo doubleTest(int64_t context, void * object1, foo * array1, void * object2, foo * array2) {
assert(NULL!=object1);
assert(NULL!=array1);
assert(NULL!=object2);
assert(NULL!=array2);
- return arrayTest(context, array1) +
- arrayTest( 0, array2) +
+ return arrayTestFoo(context, array1) +
+ arrayTestFoo( 0, array2) +
bufferTest(object1) +
bufferTest(object2);
}
-foo arrayTestNioOnly(long context, foo * array ) {
- return arrayTest(context, array);
+foo arrayTestFooNioOnly(int64_t context, foo * array ) {
+ return arrayTestFoo(context, array);
}
foo bufferTestNioOnly(void * object) {
return bufferTest(object);
}
-foo mixedTestNioOnly(long context, void * object, foo * array ) {
+foo mixedTestNioOnly(int64_t context, void * object, foo * array ) {
return mixedTest(context, object, array);
}
-foo doubleTestNioOnly(long context, void * object1, foo * array1, void * object2, foo * array2 ) {
+foo doubleTestNioOnly(int64_t context, void * object1, foo * array1, void * object2, foo * array2 ) {
return doubleTest(context, object1, array1, object2, array2);
}
diff --git a/src/junit/com/jogamp/gluegen/test/junit/test1.h b/src/junit/com/jogamp/gluegen/test/junit/test1.h
index 38b4911..2d92607 100644
--- a/src/junit/com/jogamp/gluegen/test/junit/test1.h
+++ b/src/junit/com/jogamp/gluegen/test/junit/test1.h
@@ -11,34 +11,42 @@
#define CONSTANT_ONE 1
#define ARRAY_SIZE 8
-typedef unsigned long foo;
+#include "gluegenint.h"
+
+typedef uint64_t foo;
/** Returns 42 */
MYAPI foo MYAPIENTRY nopTest();
/** Returns Sum(array) + context */
-MYAPI foo MYAPIENTRY arrayTest(long context, foo * array );
+MYAPI int32_t MYAPIENTRY arrayTestInt32(int64_t context, int32_t * array );
+
+/** Returns Sum(array) + context */
+MYAPI int64_t MYAPIENTRY arrayTestInt64(int64_t context, int64_t * array );
+
+/** Returns Sum(array) + context */
+MYAPI foo MYAPIENTRY arrayTestFoo(int64_t context, foo * array );
/** Returns *((foo *)object) */
MYAPI foo MYAPIENTRY bufferTest(void * object);
/** Returns Sum(array) + context + *((foo *)object) */
-MYAPI foo MYAPIENTRY mixedTest(long context, void * object, foo * array );
+MYAPI foo MYAPIENTRY mixedTest(int64_t context, void * object, foo * array );
/** Returns Sum(array1) + Sum(array2) + context + *((foo *)object1) + *((foo *)object2) */
-MYAPI foo MYAPIENTRY doubleTest(long context, void * object1, foo * array1, void * object2, foo * array2 );
+MYAPI foo MYAPIENTRY doubleTest(int64_t context, void * object1, foo * array1, void * object2, foo * array2 );
/** Returns Sum(array) + context */
-MYAPI foo MYAPIENTRY arrayTestNioOnly(long context, foo * array );
+MYAPI foo MYAPIENTRY arrayTestFooNioOnly(int64_t context, foo * array );
/** Returns *((foo *)object) */
MYAPI foo MYAPIENTRY bufferTestNioOnly(void * object);
/** Returns Sum(array) + context + *((foo *)object) */
-MYAPI foo MYAPIENTRY mixedTestNioOnly(long context, void * object, foo * array );
+MYAPI foo MYAPIENTRY mixedTestNioOnly(int64_t context, void * object, foo * array );
/** Returns Sum(array1) + Sum(array2) + context + *((foo *)object1) + *((foo *)object2) */
-MYAPI foo MYAPIENTRY doubleTestNioOnly(long context, void * object1, foo * array1, void * object2, foo * array2 );
+MYAPI foo MYAPIENTRY doubleTestNioOnly(int64_t context, void * object1, foo * array1, void * object2, foo * array2 );
/** Returns atoi(str) */
MYAPI int MYAPIENTRY strToInt(const char* str);