From 2138fc787c1e497be7f373aa68b3f751c955008f Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 29 Mar 2010 04:24:20 +0200 Subject: New Int64Buffer type, which is being used for gluegen 'long *' --- .../com/jogamp/gluegen/test/junit/BaseTest1.java | 96 ++++++++++++++-------- src/junit/com/jogamp/gluegen/test/junit/test1.c | 48 ++++++++--- src/junit/com/jogamp/gluegen/test/junit/test1.h | 22 +++-- 3 files changed, 114 insertions(+), 52 deletions(-) (limited to 'src/junit/com/jogamp/gluegen/test') 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 #include +#include 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 %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 %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 %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); -- cgit v1.2.3