diff options
-rw-r--r-- | src/java/com/jogamp/gluegen/runtime/Int64Buffer.java | 14 | ||||
-rw-r--r-- | src/java/com/jogamp/gluegen/runtime/PointerBuffer.java | 14 | ||||
-rw-r--r-- | src/java/com/sun/gluegen/CMethodBindingEmitter.java | 7 | ||||
-rw-r--r-- | src/java/com/sun/gluegen/JavaEmitter.java | 62 | ||||
-rw-r--r-- | src/java/com/sun/gluegen/JavaMethodBindingEmitter.java | 12 | ||||
-rw-r--r-- | src/junit/com/jogamp/gluegen/test/junit/BaseTest1.java | 115 | ||||
-rw-r--r-- | src/junit/com/jogamp/gluegen/test/junit/test1-common.cfg | 15 | ||||
-rw-r--r-- | src/junit/com/jogamp/gluegen/test/junit/test1.c | 55 | ||||
-rw-r--r-- | src/junit/com/jogamp/gluegen/test/junit/test1.h | 19 |
9 files changed, 290 insertions, 23 deletions
diff --git a/src/java/com/jogamp/gluegen/runtime/Int64Buffer.java b/src/java/com/jogamp/gluegen/runtime/Int64Buffer.java index 5f7cc33..98d0834 100644 --- a/src/java/com/jogamp/gluegen/runtime/Int64Buffer.java +++ b/src/java/com/jogamp/gluegen/runtime/Int64Buffer.java @@ -152,4 +152,18 @@ public abstract class Int64Buffer { public abstract Int64Buffer put(long value); + public Int64Buffer put(Int64Buffer src) { + if (remaining() < src.remaining()) { + throw new IndexOutOfBoundsException(); + } + while (src.hasRemaining()) { + put(src.get()); + } + return this; + } + + public String toString() { + return "Int64Buffer[capacity "+capacity+", position "+position+", elementSize "+elementSize()+", ByteBuffer.capacity "+bb.capacity()+"]"; + } + } diff --git a/src/java/com/jogamp/gluegen/runtime/PointerBuffer.java b/src/java/com/jogamp/gluegen/runtime/PointerBuffer.java index a89dace..0adbb36 100644 --- a/src/java/com/jogamp/gluegen/runtime/PointerBuffer.java +++ b/src/java/com/jogamp/gluegen/runtime/PointerBuffer.java @@ -156,4 +156,18 @@ public abstract class PointerBuffer { public abstract PointerBuffer put(long value); + public PointerBuffer put(PointerBuffer src) { + if (remaining() < src.remaining()) { + throw new IndexOutOfBoundsException(); + } + while (src.hasRemaining()) { + put(src.get()); + } + return this; + } + + public String toString() { + return "PointerBuffer[capacity "+capacity+", position "+position+", elementSize "+elementSize()+", ByteBuffer.capacity "+bb.capacity()+"]"; + } + } diff --git a/src/java/com/sun/gluegen/CMethodBindingEmitter.java b/src/java/com/sun/gluegen/CMethodBindingEmitter.java index c91e992..022df39 100644 --- a/src/java/com/sun/gluegen/CMethodBindingEmitter.java +++ b/src/java/com/sun/gluegen/CMethodBindingEmitter.java @@ -1009,7 +1009,12 @@ public class CMethodBindingEmitter extends FunctionEmitter System.err.println( "WARNING: No capacity specified for java.nio.Buffer return " + "value for function \"" + binding + "\";" + - " assuming size of equivalent C return type (sizeof(" + cReturnType.getName() + ")): " + binding); + " assuming size of equivalent C return type (sizeof(" + cReturnType.getName() + ")): " + binding); + /** + throw new RuntimeException( + "WARNING: No capacity specified for java.nio.Buffer return " + + "value for function \"" + binding + "\";" + + " C return type is " + cReturnType.getName() + ": " + binding); */ } writer.println(");"); } else if (javaReturnType.isString()) { diff --git a/src/java/com/sun/gluegen/JavaEmitter.java b/src/java/com/sun/gluegen/JavaEmitter.java index 0a92735..25aeb16 100644 --- a/src/java/com/sun/gluegen/JavaEmitter.java +++ b/src/java/com/sun/gluegen/JavaEmitter.java @@ -1215,13 +1215,40 @@ public class JavaEmitter implements GlueEmitter { (opt.getTargetType().getName().equals("JNIEnv"))) { return JavaType.createForJNIEnv(); } + Type t = cType; // Opaque specifications override automatic conversions - TypeInfo info = cfg.typeInfo(cType, typedefDictionary); + // in case the identity is being used .. not if ptr-ptr + TypeInfo info = cfg.typeInfo(t, typedefDictionary); if (info != null) { - return info.javaType(); + boolean isPointerPointer = false; + if (t.pointerDepth() > 0 || t.arrayDimension() > 0) { + Type targetType; // target type + if (t.isPointer()) { + // t is <type>*, we need to get <type> + targetType = t.asPointer().getTargetType(); + } else { + // t is <type>[], we need to get <type> + targetType = t.asArray().getElementType(); + } + if (t.pointerDepth() == 2 || t.arrayDimension() == 2) { + // Get the target type of the target type (targetType was computer earlier + // as to be a pointer to the target type, so now we need to get its + // target type) + if (targetType.isPointer()) { + isPointerPointer = true; + + // t is<type>**, targetType is <type>*, we need to get <type> + Type bottomType = targetType.asPointer().getTargetType(); + System.out.println("INFO: Opaque Type: "+t+", targetType: "+targetType+", bottomType: "+bottomType+" is ptr-ptr"); + } + } + } + if(!isPointerPointer) { + return info.javaType(); + } } - Type t = cType; + if (t.isInt() || t.isEnum()) { switch ((int) t.getSize(curMachDesc)) { case 1: return javaType(Byte.TYPE); @@ -1302,11 +1329,16 @@ public class JavaEmitter implements GlueEmitter { if (targetType.isPointer()) { // t is<type>**, targetType is <type>*, we need to get <type> bottomType = targetType.asPointer().getTargetType(); + return JavaType.forNIOPointerBufferClass(); } else { // t is<type>[][], targetType is <type>[], we need to get <type> bottomType = targetType.asArray().getElementType(); + System.out.println("WARNING: typeToJavaType(ptr-ptr): "+t+", targetType: "+targetType+", bottomType: "+bottomType+" -> Unhandled!"); } + // Warning: The below code is not backed up by an implementation, + // the only working variant is a ptr-ptr type which results in a PointerBuffer. + // if (bottomType.isPrimitive()) { if (bottomType.isInt()) { switch ((int) bottomType.getSize(curMachDesc)) { @@ -1700,6 +1732,8 @@ public class JavaEmitter implements GlueEmitter { binding.renameMethodName(cfg.getJavaSymbolRename(sym.getName())); + // System.out.println("bindFunction(0) "+sym.getReturnType()); + if (cfg.returnsString(binding.getName())) { PointerType prt = sym.getReturnType().asPointer(); if (prt == null || @@ -1714,6 +1748,8 @@ public class JavaEmitter implements GlueEmitter { binding.setJavaReturnType(typeToJavaType(sym.getReturnType(), false, curMachDesc)); } + // System.out.println("bindFunction(1) "+binding.getJavaReturnType()); + // List of the indices of the arguments in this function that should be // converted from byte[] or short[] to String List<Integer> stringArgIndices = cfg.stringArguments(binding.getName()); @@ -1721,22 +1757,23 @@ public class JavaEmitter implements GlueEmitter { for (int i = 0; i < sym.getNumArguments(); i++) { Type cArgType = sym.getArgumentType(i); JavaType mappedType = typeToJavaType(cArgType, true, curMachDesc); - //System.out.println("C arg type -> \"" + cArgType + "\"" ); - //System.out.println(" Java -> \"" + mappedType + "\"" ); + // System.out.println("C arg type -> \"" + cArgType + "\"" ); + // System.out.println(" Java -> \"" + mappedType + "\"" ); // Take into account any ArgumentIsString configuration directives that apply if (stringArgIndices != null && stringArgIndices.contains(i)) { - //System.out.println("Forcing conversion of " + binding.getName() + " arg #" + i + " from byte[] to String "); + // System.out.println("Forcing conversion of " + binding.getName() + " arg #" + i + " from byte[] to String "); if (mappedType.isCVoidPointerType() || mappedType.isCCharPointerType() || mappedType.isCShortPointerType() || + mappedType.isNIOPointerBuffer() || (mappedType.isArray() && (mappedType.getJavaClass() == ArrayTypes.byteBufferArrayClass) || (mappedType.getJavaClass() == ArrayTypes.shortBufferArrayClass))) { // convert mapped type from: // void*, byte[], and short[] to String // ByteBuffer[] and ShortBuffer[] to String[] - if (mappedType.isArray()) { + if (mappedType.isArray() || mappedType.isNIOPointerBuffer()) { mappedType = javaType(ArrayTypes.stringArrayClass); } else { mappedType = javaType(String.class); @@ -1753,8 +1790,9 @@ public class JavaEmitter implements GlueEmitter { //System.out.println("During binding of [" + sym + "], added mapping from C type: " + cArgType + " to Java type: " + mappedType); } - //System.err.println("---> " + binding); - //System.err.println(" ---> " + binding.getCSymbol()); + // System.out.println("---> " + binding); + // System.out.println(" ---> " + binding.getCSymbol()); + // System.out.println("bindFunction(3) "+binding); return binding; } @@ -1764,6 +1802,8 @@ public class JavaEmitter implements GlueEmitter { MethodBinding result = inputBinding; boolean arrayPossible = false; + // System.out.println("lowerMethodBindingPointerTypes(0): "+result); + for (int i = 0; i < inputBinding.getNumArguments(); i++) { JavaType t = inputBinding.getJavaArgumentType(i); if (t.isCPrimitivePointerType()) { @@ -1818,6 +1858,8 @@ public class JavaEmitter implements GlueEmitter { } } + // System.out.println("lowerMethodBindingPointerTypes(1): "+result); + // Always return primitive pointer types as NIO buffers JavaType t = result.getJavaReturnType(); if (t.isCPrimitivePointerType()) { @@ -1840,6 +1882,8 @@ public class JavaEmitter implements GlueEmitter { } } + // System.out.println("lowerMethodBindingPointerTypes(2): "+result); + if (canProduceArrayVariant != null) { canProduceArrayVariant[0] = arrayPossible; } diff --git a/src/java/com/sun/gluegen/JavaMethodBindingEmitter.java b/src/java/com/sun/gluegen/JavaMethodBindingEmitter.java index b5b5b9c..4153e32 100644 --- a/src/java/com/sun/gluegen/JavaMethodBindingEmitter.java +++ b/src/java/com/sun/gluegen/JavaMethodBindingEmitter.java @@ -730,11 +730,17 @@ public class JavaMethodBindingEmitter extends FunctionEmitter if (!returnType.isNIOByteBuffer()) { // See whether we have to expand pointers to longs if (getBinding().getCReturnType().pointerDepth() >= 2) { - if (!returnType.isNIOPointerBuffer()) { + if (returnType.isNIOPointerBuffer()) { + writer.println(" return PointerBuffer.wrap(_res);"); + } else if (returnType.isNIOInt64Buffer()) { + writer.println(" return Int64Buffer.wrap(_res);"); + } else { throw new RuntimeException("While emitting glue code for " + getName() + - ": can not legally make pointers opaque to anything but longs"); + ": can not legally make pointers opaque to anything but PointerBuffer or Int64Buffer/long"); } - writer.println(" return PointerBuffer.wrap(_res);"); + } else if (getBinding().getCReturnType().pointerDepth() == 1 && + returnType.isNIOInt64Buffer()) { + writer.println(" return Int64Buffer.wrap(_res);"); } else { String returnTypeName = returnType.getName().substring("java.nio.".length()); writer.println(" return _res.as" + returnTypeName + "();"); diff --git a/src/junit/com/jogamp/gluegen/test/junit/BaseTest1.java b/src/junit/com/jogamp/gluegen/test/junit/BaseTest1.java index c53d142..420dc2b 100644 --- a/src/junit/com/jogamp/gluegen/test/junit/BaseTest1.java +++ b/src/junit/com/jogamp/gluegen/test/junit/BaseTest1.java @@ -35,6 +35,7 @@ package com.jogamp.gluegen.test.junit; import com.jogamp.gluegen.runtime.Buffers; import com.jogamp.gluegen.runtime.PointerBuffer; import com.jogamp.gluegen.runtime.Int64Buffer; +import com.jogamp.gluegen.runtime.Platform; import java.nio.*; import java.io.File; import java.lang.reflect.InvocationTargetException; @@ -89,6 +90,7 @@ public class BaseTest1 { long context = 0; ByteBuffer bb=null; Int64Buffer lb=null; + PointerBuffer pb=null; IntBuffer ib=null; long[] larray = null; int larray_offset = 0; @@ -103,10 +105,16 @@ public class BaseTest1 { 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.arrayTestFoo1(context, lb); + result = binding.arrayTestFoo1(context, larray, larray_offset); result = binding.arrayTestFooNioOnly(context, lb); + lb = binding.arrayTestFoo2(lb); + lb = binding.arrayTestFoo2(larray, larray_offset); + + pb = binding.arrayTestFoo3ArrayToPtrPtr(lb); + pb = binding.arrayTestFoo3PtrPtr(pb); + result = binding.bufferTest(bb); result = binding.bufferTestNioOnly(bb); @@ -128,6 +136,9 @@ public class BaseTest1 { i = binding.intArrayRead(ib, i); i = binding.intArrayRead(iarray, iarray_offset, i); + long cfg=0; + cfg = binding.typeTestAnonSingle(cfg); + pb = binding.typeTestAnonPointer(pb); } /** @@ -192,15 +203,84 @@ public class BaseTest1 { result = binding.arrayTestInt64(context, larray1, larray1_offset); Assert.assertTrue("Wrong result: "+result, 1+8000==result); - result = binding.arrayTestFoo(context, lb1); + result = binding.arrayTestFoo1(context, lb1); Assert.assertTrue("Wrong result: "+result, 1+8000==result); - result = binding.arrayTestFoo(context, larray1, larray1_offset); + result = binding.arrayTestFoo1(context, larray1, larray1_offset); Assert.assertTrue("Wrong result: "+result, 1+8000==result); result = binding.arrayTestFooNioOnly(context, lb1); Assert.assertTrue("Wrong result: "+result, 1+8000==result); + { + lb2.rewind(); + Int64Buffer lb3 = Int64Buffer.allocateDirect(BindingTest1.ARRAY_SIZE); + lb3.put(lb2); + lb3.rewind(); + lb2.rewind(); + + // System.out.println("lb3: "+lb3); + Assert.assertTrue("Wrong result: "+lb3.capacity(), BindingTest1.ARRAY_SIZE == lb3.capacity()); + Assert.assertTrue("Wrong result: "+lb3.remaining(), BindingTest1.ARRAY_SIZE == lb3.remaining()); + + Int64Buffer lbR = binding.arrayTestFoo2(lb3); + // System.out.println("lbR: "+lbR); + + Assert.assertNotNull(lbR); + Assert.assertTrue("Wrong result: "+lb3.capacity(), BindingTest1.ARRAY_SIZE == lb3.capacity()); + Assert.assertTrue("Wrong result: "+lb3.remaining(), BindingTest1.ARRAY_SIZE == lb3.remaining()); + Assert.assertTrue("Wrong result: "+lbR.capacity(), BindingTest1.ARRAY_SIZE == lbR.capacity()); + Assert.assertTrue("Wrong result: "+lbR.remaining(), BindingTest1.ARRAY_SIZE == lbR.remaining()); + int j=0; + for(j=0; j<BindingTest1.ARRAY_SIZE; j++) { + Assert.assertTrue("Wrong result: s:"+lb3.get(j)+" d: "+lbR.get(j), 1+lb3.get(j)==lbR.get(j)); + } + } + { + long[] larray3 = new long[BindingTest1.ARRAY_SIZE]; + for(i=0; i<BindingTest1.ARRAY_SIZE; i++) { + larray3[i]= larray2[i]; + } + + Int64Buffer lbR = binding.arrayTestFoo2(larray3, 0); + + Assert.assertNotNull(lbR); + Assert.assertTrue("Wrong result: "+lbR.capacity(), BindingTest1.ARRAY_SIZE == lbR.capacity()); + Assert.assertTrue("Wrong result: "+lbR.remaining(), BindingTest1.ARRAY_SIZE == lbR.remaining()); + int j=0; + for(j=0; j<BindingTest1.ARRAY_SIZE; j++) { + Assert.assertTrue("Wrong result: s:"+larray3[j]+" d: "+lbR.get(j), 1+larray3[j]==lbR.get(j)); + } + } + { + lb2.rewind(); + Int64Buffer lb3 = Int64Buffer.allocateDirect(BindingTest1.ARRAY_SIZE*BindingTest1.ARRAY_SIZE); + int j=0; + for(j=0; j<BindingTest1.ARRAY_SIZE; j++) { + lb3.put(lb2); + lb2.rewind(); + } + lb3.rewind(); + + // System.out.println("lb3: "+lb3); + Assert.assertTrue("Wrong result: "+lb3.capacity(), BindingTest1.ARRAY_SIZE*BindingTest1.ARRAY_SIZE == lb3.capacity()); + Assert.assertTrue("Wrong result: "+lb3.remaining(), BindingTest1.ARRAY_SIZE*BindingTest1.ARRAY_SIZE == lb3.remaining()); + + PointerBuffer pb = binding.arrayTestFoo3ArrayToPtrPtr(lb3); + // System.out.println("pb: "+pb); + Assert.assertTrue("Wrong result: "+pb.capacity(), BindingTest1.ARRAY_SIZE == pb.capacity()); + Assert.assertTrue("Wrong result: "+pb.remaining(), BindingTest1.ARRAY_SIZE == pb.remaining()); + + PointerBuffer pb2 = binding.arrayTestFoo3PtrPtr(pb); + + Assert.assertNotNull(pb2); + Assert.assertTrue("Wrong result: "+pb2.capacity(), BindingTest1.ARRAY_SIZE == pb2.capacity()); + Assert.assertTrue("Wrong result: "+pb2.remaining(), BindingTest1.ARRAY_SIZE == pb2.remaining()); + for(j=0; j<BindingTest1.ARRAY_SIZE; j++) { + Assert.assertTrue("Wrong result: s:"+lb2.get(j)+" d: "+lb3.get(j), 1+lb2.get(j)==lb3.get(j)); + } + } + result = binding.bufferTest(lb.getBuffer()); Assert.assertTrue("Wrong result: "+result, 10==result); @@ -251,6 +331,33 @@ public class BaseTest1 { i = binding.intArrayRead(iarray, 0, 3); Assert.assertTrue("Wrong result: "+i, 6==i); + + { + long cfg_base = 0xAABBCCDD11223344L; + + PointerBuffer pb = PointerBuffer.allocateDirect(BindingTest1.ARRAY_SIZE); + for(i=0; i<BindingTest1.ARRAY_SIZE; i++) { + long cfg_native; + if(Platform.is32Bit()) { + cfg_native = (cfg_base+i) & 0x00000000FFFFFFFFL; // umask 1st 32bit + } else { + cfg_native = (cfg_base+i); + } + long cfg = binding.typeTestAnonSingle(cfg_base + i); + Assert.assertTrue("Wrong result: 0x"+Long.toHexString(cfg_native)+"+1 != 0x"+Long.toHexString(cfg), (cfg_native+1)==cfg); + pb.put(i, cfg_base+i); + + long t = pb.get(i); + Assert.assertTrue("Wrong result: 0x"+Long.toHexString(cfg_native)+" != 0x"+Long.toHexString(t), cfg_native==t); + } + pb.rewind(); + PointerBuffer pb2 = binding.typeTestAnonPointer(pb); + Assert.assertTrue("Wrong result: "+pb2.capacity(), BindingTest1.ARRAY_SIZE == pb2.capacity()); + Assert.assertTrue("Wrong result: "+pb2.remaining(), BindingTest1.ARRAY_SIZE == pb2.remaining()); + for(i=0; i<BindingTest1.ARRAY_SIZE; i++) { + Assert.assertTrue("Wrong result: 0x"+Long.toHexString(pb.get(i))+"+1 != 0x"+Long.toHexString(pb2.get(i)), (pb.get(i)+1)==pb2.get(i)); + } + } } /** diff --git a/src/junit/com/jogamp/gluegen/test/junit/test1-common.cfg b/src/junit/com/jogamp/gluegen/test/junit/test1-common.cfg index d775424..2709e80 100644 --- a/src/junit/com/jogamp/gluegen/test/junit/test1-common.cfg +++ b/src/junit/com/jogamp/gluegen/test/junit/test1-common.cfg @@ -8,6 +8,21 @@ ReturnsString intToStr ArgumentIsString strToInt 0 ArgumentIsString stringArrayRead 0 +ReturnValueCapacity arrayTestFoo2 ARRAY_SIZE * sizeof(foo) +ReturnValueCapacity arrayTestFoo3ArrayToPtrPtr ARRAY_SIZE * sizeof(foo *) +ReturnValueCapacity arrayTestFoo3PtrPtr ARRAY_SIZE * sizeof(foo *) +ReturnValueCapacity typeTestAnonPointer ARRAY_SIZE * sizeof(MYAPIConfig) + +# +# This allows a single element of MYAPIConfig, +# an anonymous struct pointer, to be treated as a long value. +# Arrays of such type (pointer pointer) are still +# treated through a PointerBuffer to achieve architecture +# coherence (32bit/64bit pointer); +# +# typedef struct __MYAPIConfig * MYAPIConfig; +Opaque long MYAPIConfig + CustomCCode #include "test1.h" # Imports needed by all glue code diff --git a/src/junit/com/jogamp/gluegen/test/junit/test1.c b/src/junit/com/jogamp/gluegen/test/junit/test1.c index 0fa4abb..f654467 100644 --- a/src/junit/com/jogamp/gluegen/test/junit/test1.c +++ b/src/junit/com/jogamp/gluegen/test/junit/test1.c @@ -2,6 +2,7 @@ #include <assert.h> #include <stdlib.h> #include <stdio.h> +#include <string.h> foo nopTest() { return 42; @@ -31,7 +32,38 @@ int64_t arrayTestInt64(int64_t context, int64_t * array) { return r+context; } -foo arrayTestFoo(int64_t context, foo * array) { +foo * arrayTestFoo2( foo * array ) { + int i; + foo * result = calloc(ARRAY_SIZE, sizeof(foo)); + assert(NULL!=array); + for(i=0; i<ARRAY_SIZE; i++) { + result[i] = array[i] + 1; + // printf("array[%d]: %d -> %d\n", i, (int)array[i], (int)result[i]); + } + return result; +} + +foo * * arrayTestFoo3ArrayToPtrPtr(foo * array) { + int j; + foo * * result = calloc(ARRAY_SIZE, sizeof(foo *)); + for(j=0; j<ARRAY_SIZE; j++) { + result[j] = array + ARRAY_SIZE * j ; + } + return result; +} + +foo * * arrayTestFoo3PtrPtr(foo * * array ) { + int i,j; + assert(NULL!=array); + for(j=0; j<ARRAY_SIZE; j++) { + for(i=0; i<ARRAY_SIZE; i++) { + array[j][i] += 1; + } + } + return array; +} + +foo arrayTestFoo1(int64_t context, foo * array) { foo r=0; int i; assert(NULL!=array); @@ -51,7 +83,7 @@ foo bufferTest(void * object) { foo mixedTest(int64_t context, void * object, foo * array){ assert(NULL!=object); assert(NULL!=array); - return arrayTestFoo(context, array) + bufferTest(object); + return arrayTestFoo1(context, array) + bufferTest(object); } foo doubleTest(int64_t context, void * object1, foo * array1, void * object2, foo * array2) { @@ -59,14 +91,14 @@ foo doubleTest(int64_t context, void * object1, foo * array1, void * object2, fo assert(NULL!=array1); assert(NULL!=object2); assert(NULL!=array2); - return arrayTestFoo(context, array1) + - arrayTestFoo( 0, array2) + + return arrayTestFoo1(context, array1) + + arrayTestFoo1( 0, array2) + bufferTest(object1) + bufferTest(object2); } foo arrayTestFooNioOnly(int64_t context, foo * array ) { - return arrayTestFoo(context, array); + return arrayTestFoo1(context, array); } foo bufferTestNioOnly(void * object) { @@ -125,3 +157,16 @@ int intArrayWrite(int * * ints, int num) { return s; } */ +MYAPIConfig typeTestAnonSingle(const MYAPIConfig a) { + return (MYAPIConfig) ( ((void *)a) + 1 ); +} + +MYAPIConfig * MYAPIENTRY typeTestAnonPointer(const MYAPIConfig * a) { + int j; + MYAPIConfig * result = calloc(ARRAY_SIZE, sizeof(MYAPIConfig)); + for(j=0; j<ARRAY_SIZE; j++) { + result[j] = (MYAPIConfig) ( ((void *)a[j]) + 1 ); + } + return result; +} + diff --git a/src/junit/com/jogamp/gluegen/test/junit/test1.h b/src/junit/com/jogamp/gluegen/test/junit/test1.h index 2d92607..d0e50e5 100644 --- a/src/junit/com/jogamp/gluegen/test/junit/test1.h +++ b/src/junit/com/jogamp/gluegen/test/junit/test1.h @@ -25,7 +25,16 @@ MYAPI int32_t MYAPIENTRY arrayTestInt32(int64_t context, int32_t * array ); MYAPI int64_t MYAPIENTRY arrayTestInt64(int64_t context, int64_t * array ); /** Returns Sum(array) + context */ -MYAPI foo MYAPIENTRY arrayTestFoo(int64_t context, foo * array ); +MYAPI foo MYAPIENTRY arrayTestFoo1(int64_t context, foo * array ); + +/** Returns a copy of the passed array, each element incr by 1 */ +MYAPI foo * MYAPIENTRY arrayTestFoo2(foo * array ); + +/** Returns a array-array of the passed array, split at ARRAY size - IDENTITY! */ +MYAPI foo * * MYAPIENTRY arrayTestFoo3ArrayToPtrPtr(foo * array); + +/** Returns a the passed array-array, each element incr by 1 - IDENTITY !*/ +MYAPI foo * * MYAPIENTRY arrayTestFoo3PtrPtr(foo * * array ); /** Returns *((foo *)object) */ MYAPI foo MYAPIENTRY bufferTest(void * object); @@ -63,3 +72,11 @@ MYAPI int MYAPIENTRY intArrayRead(const int * ints, int num); /** Increases the elements by 1, and returns the sum MYAPI int MYAPIENTRY intArrayWrite(int * * ints, int num); */ +typedef struct __MYAPIConfig * MYAPIConfig; + +/** Returns the passed MYAPIConfig incremented by 1 */ +MYAPI MYAPIConfig MYAPIENTRY typeTestAnonSingle(const MYAPIConfig a); + +/** Return a copy of the passed MYAPIConfig*, incremented by 1 */ +MYAPI MYAPIConfig * MYAPIENTRY typeTestAnonPointer(const MYAPIConfig * a); + |