diff options
author | Sven Gothel <[email protected]> | 2011-04-27 19:47:43 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2011-04-27 19:47:43 +0200 |
commit | 8f8aa3f73e3c9804c4a86f5d4fdac257d50d831a (patch) | |
tree | 87497a9ffd60f4d3c2be2535312a72f84087a23d /src | |
parent | a07892f07f15c96ca248fc12133748be7058241f (diff) |
NativeBuffer/PointerBuffer API/Impl Change (remove explicit backup array, alloc referenced data map if used only)
This patch doesn't impact GlueGen's code generation,
but enhance and fix PointerBuffer usage only.
remove explicit backup array
As suggested by Michael Bien with a proposed patch,
PointerBuffer's backup array is not only redundant in case it's not used,
but also erroneous - due to possible sliced buffers.
Removes the explicit backup array implementation
leaving it up to the user, ie how PointerBuffer is created (alloc/allocDirect)
and use the underlying nio's buffer backup array, if available.
This also fixes the (never tested) case of indirect w/ backup array usage
on 32bit platform size. In this case the array shall be of type int[],
holding 32bit pointer - on 64bit long[].
Previous to this patch, it was always long[].
Added more thorough tests of PointerBuffer, notably indirect w/ backup array
and native deep copy and filling of a pointer array.
alloc referenced data map if used only
As suggested by Michael Bien with a proposed patch,
the allocation of the dataMap hash map is redundant in case it's not used.
The hash map will be initialized lazy, if needed only.
Diffstat (limited to 'src')
11 files changed, 456 insertions, 349 deletions
diff --git a/src/java/com/jogamp/common/nio/AbstractBuffer.java b/src/java/com/jogamp/common/nio/AbstractBuffer.java index 870f3c0..58bab65 100644 --- a/src/java/com/jogamp/common/nio/AbstractBuffer.java +++ b/src/java/com/jogamp/common/nio/AbstractBuffer.java @@ -33,15 +33,17 @@ package com.jogamp.common.nio; import com.jogamp.common.os.*; +import java.nio.Buffer; import java.nio.ByteBuffer; /** - * @author Michael Bien * @author Sven Gothel + * @author Michael Bien */ public abstract class AbstractBuffer<B extends AbstractBuffer> implements NativeBuffer<B> { - protected final ByteBuffer bb; + protected final int elementSize; + protected final Buffer buffer; protected int capacity; protected int position; @@ -49,13 +51,22 @@ public abstract class AbstractBuffer<B extends AbstractBuffer> implements Native NativeLibrary.ensureNativeLibLoaded(); } - protected AbstractBuffer(ByteBuffer bb, int elementSize) { - this.bb = bb; + /** + * @param buffer expected in target format + * @param elementSize the target element size in bytes + */ + protected AbstractBuffer(Buffer buffer, int elementSize) { + this.elementSize = elementSize; + this.buffer = buffer; - capacity = bb.capacity() / elementSize; + capacity = buffer.capacity() /* / elementSize */; position = 0; } + public final int elementSize() { + return elementSize; + } + public final int limit() { return capacity; } @@ -90,25 +101,33 @@ public abstract class AbstractBuffer<B extends AbstractBuffer> implements Native return (B) this; } - public boolean hasArray() { - return false; + public final Buffer getBuffer() { + return buffer; } - public int arrayOffset() { - return 0; + public final boolean isDirect() { + return buffer.isDirect(); } - - public final ByteBuffer getBuffer() { - return bb; + + public final boolean hasArray() { + return buffer.hasArray(); } - public final boolean isDirect() { - return bb.isDirect(); + public final int arrayOffset() { + if(hasArray()) { + return buffer.arrayOffset(); + } else { + return 0; + } } + public Object array() throws UnsupportedOperationException { + return buffer.array(); + } + @Override public String toString() { - return "AbstractBuffer[capacity "+capacity+", position "+position+", elementSize "+(bb.capacity()/capacity)+", ByteBuffer.capacity "+bb.capacity()+"]"; + return "AbstractBuffer[direct "+isDirect()+", hasArray "+hasArray()+", capacity "+capacity+", position "+position+", elementSize "+elementSize+", buffer[capacity "+buffer.capacity()+", lim "+buffer.limit()+", pos "+buffer.position()+"]]"; } } diff --git a/src/java/com/jogamp/common/nio/AbstractLongBuffer.java b/src/java/com/jogamp/common/nio/AbstractLongBuffer.java deleted file mode 100644 index c097e2e..0000000 --- a/src/java/com/jogamp/common/nio/AbstractLongBuffer.java +++ /dev/null @@ -1,142 +0,0 @@ -/** - * Copyright 2010 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ - -/* - * Created on Saturday, March 27 2010 11:55 - */ -package com.jogamp.common.nio; - -import com.jogamp.common.os.*; -import java.nio.ByteBuffer; - -/** - * Hardware independent container for native pointer arrays. - * - * The native values (NIO direct ByteBuffer) might be 32bit or 64bit wide, - * depending of the CPU pointer width. - * - * @author Michael Bien - * @author Sven Gothel - */ -public abstract class AbstractLongBuffer<B extends AbstractLongBuffer> extends AbstractBuffer<B> { - - protected long[] backup; - - static { - NativeLibrary.ensureNativeLibLoaded(); - } - - protected AbstractLongBuffer(ByteBuffer bb, int elementSize) { - super(bb, elementSize); - - backup = new long[capacity]; - } - - final void updateBackup() { - for (int i = 0; i < capacity; i++) { - backup[i] = get(i); - } - } - - @Override - public final boolean hasArray() { - return true; - } - - public final long[] array() { - return backup; - } - - /** Absolute get method. Get the pointer value at the given index */ - public abstract long get(int idx); - - /** Relative get method. Get the pointer value at the current position and increment the position by one. */ - public final long get() { - long r = get(position); - position++; - return r; - } - - /** - * Relative bulk get method. Copy the pointer values <code> [ position .. position+length [</code> - * to the destination array <code> [ dest[offset] .. dest[offset+length] [ </code> - * and increment the position by <code>length</code>. */ - public final AbstractLongBuffer get(long[] dest, int offset, int length) { - if (dest.length<offset+length) { - throw new IndexOutOfBoundsException(); - } - if (remaining() < length) { - throw new IndexOutOfBoundsException(); - } - while(length>0) { - dest[offset++] = get(position++); - length--; - } - return this; - } - - /** Absolute put method. Put the pointer value at the given index */ - public abstract B put(int index, long value); - - /** Relative put method. Put the pointer value at the current position and increment the position by one. */ - public final B put(long value) { - put(position, value); - position++; - return (B) this; - } - - /** - * Relative bulk put method. Put the pointer values <code> [ src[offset] .. src[offset+length] [</code> - * at the current position and increment the position by <code>length</code>. */ - public final AbstractLongBuffer put(long[] src, int offset, int length) { - if (src.length<offset+length) { - throw new IndexOutOfBoundsException(); - } - if (remaining() < length) { - throw new IndexOutOfBoundsException(); - } - while(length>0) { - put(position++, src[offset++]); - length--; - } - return this; - } - - /** - * Relative bulk get method. Copy the source values <code> src[position .. capacity] [</code> - * to this buffer and increment the position by <code>capacity-position</code>. */ - public B put(B src) { - if (remaining() < src.remaining()) { - throw new IndexOutOfBoundsException(); - } - while (src.hasRemaining()) { - put(src.get()); - } - return (B) this; - } -} diff --git a/src/java/com/jogamp/common/nio/Buffers.java b/src/java/com/jogamp/common/nio/Buffers.java index ed9323e..0d30026 100755 --- a/src/java/com/jogamp/common/nio/Buffers.java +++ b/src/java/com/jogamp/common/nio/Buffers.java @@ -329,9 +329,9 @@ public class Buffers { } else if (buf instanceof CharBuffer) { return pos * SIZEOF_CHAR; } - } else if (buf instanceof PointerBuffer) { - PointerBuffer pointerBuffer = (PointerBuffer) buf; - return pointerBuffer.position() * PointerBuffer.elementSize(); + } else if (buf instanceof NativeBuffer) { + final NativeBuffer nb = (NativeBuffer) buf; + return nb.position() * nb.elementSize() ; } throw new IllegalArgumentException("Disallowed array backing store type in buffer " + buf.getClass().getName()); @@ -340,15 +340,17 @@ public class Buffers { /** * Helper routine to return the array backing store reference from * a Buffer object. + * @throws UnsupportedOperationException if the passed Object does not have an array backing store + * @throws IllegalArgumentException if the passed Object is neither of type {@link java.nio.Buffer} or {@link NativeBuffer}. */ - public static Object getArray(Object buf) { + public static Object getArray(Object buf) throws UnsupportedOperationException, IllegalArgumentException { if (buf == null) { return null; } if (buf instanceof Buffer) { return ((Buffer) buf).array(); - } else if (buf instanceof PointerBuffer) { - return ((PointerBuffer) buf).array(); + } else if (buf instanceof NativeBuffer) { + return ((NativeBuffer) buf).array(); } throw new IllegalArgumentException("Disallowed array backing store type in buffer " + buf.getClass().getName()); @@ -381,9 +383,9 @@ public class Buffers { } else if (buf instanceof CharBuffer) { return (SIZEOF_CHAR * (((CharBuffer) buf).arrayOffset() + pos)); } - } else if (buf instanceof PointerBuffer) { - PointerBuffer pointerBuffer = (PointerBuffer) buf; - return PointerBuffer.elementSize() * (pointerBuffer.arrayOffset() + pointerBuffer.position()); + } else if (buf instanceof NativeBuffer) { + final NativeBuffer nb = (NativeBuffer) buf; + return nb.elementSize() * ( nb.arrayOffset() + nb.position() ); } throw new IllegalArgumentException("Unknown buffer type " + buf.getClass().getName()); @@ -772,9 +774,9 @@ public class Buffers { } else if (buffer instanceof CharBuffer) { bytesRemaining = elementsRemaining * SIZEOF_CHAR; } - } else if (buffer instanceof PointerBuffer) { - PointerBuffer pointerBuffer = (PointerBuffer) buffer; - bytesRemaining = pointerBuffer.remaining() * PointerBuffer.elementSize(); + } else if (buffer instanceof NativeBuffer) { + final NativeBuffer nb = (NativeBuffer) buffer; + bytesRemaining = nb.remaining() * nb.elementSize(); } if (bytesRemaining < minBytesRemaining) { throw new IndexOutOfBoundsException("Required " + minBytesRemaining + " remaining bytes in buffer, only had " + bytesRemaining); diff --git a/src/java/com/jogamp/common/nio/NativeBuffer.java b/src/java/com/jogamp/common/nio/NativeBuffer.java index ad6bb39..666907f 100644 --- a/src/java/com/jogamp/common/nio/NativeBuffer.java +++ b/src/java/com/jogamp/common/nio/NativeBuffer.java @@ -31,16 +31,19 @@ */ package com.jogamp.common.nio; +import java.nio.Buffer; import java.nio.ByteBuffer; /** * Hardware independent container for various kinds of buffers. * - * @author Michael Bien * @author Sven Gothel + * @author Michael Bien */ public interface NativeBuffer<B extends NativeBuffer> { + public int elementSize(); + public int limit(); public int capacity(); @@ -53,16 +56,30 @@ public interface NativeBuffer<B extends NativeBuffer> { public boolean hasRemaining(); + /** + * @return true if this buffer has a primitive backup array, otherwise false + */ public boolean hasArray(); + /** + * @return the array offset of the optional primitive backup array of the buffer if {@link #hasArray()} is true, + * otherwise 0. + */ public int arrayOffset(); - - public ByteBuffer getBuffer(); + + /** + * @return the primitive backup array of the buffer if {@link #hasArray()} is true, + * otherwise it throws {@link java.lang.UnsupportedOperationException}. + * The returned primitive array maybe of type <code>int[]</code> or <code>long[]</code>, etc .. + * @throws UnsupportedOperationException if this object has no backup array + * @see #hasArray() + */ + public Object array() throws UnsupportedOperationException ; + + public Buffer getBuffer(); public boolean isDirect(); - public long[] array(); - public B rewind(); public B put(int index, long value); @@ -74,5 +91,4 @@ public interface NativeBuffer<B extends NativeBuffer> { public long get(); public long get(int idx); - } diff --git a/src/java/com/jogamp/common/nio/PointerBuffer.java b/src/java/com/jogamp/common/nio/PointerBuffer.java index 5f866e1..69f8bbd 100644 --- a/src/java/com/jogamp/common/nio/PointerBuffer.java +++ b/src/java/com/jogamp/common/nio/PointerBuffer.java @@ -31,10 +31,14 @@ */ package com.jogamp.common.nio; -import com.jogamp.common.os.*; -import java.nio.ByteBuffer; import java.nio.Buffer; -import java.util.HashMap; +import java.nio.ByteBuffer; +import java.nio.IntBuffer; +import java.nio.LongBuffer; + +import com.jogamp.common.os.NativeLibrary; +import com.jogamp.common.os.Platform; +import com.jogamp.common.util.LongObjectHashMap; /** * Hardware independent container for native pointer arrays. @@ -42,78 +46,184 @@ import java.util.HashMap; * The native values (NIO direct ByteBuffer) might be 32bit or 64bit wide, * depending of the CPU pointer width. * - * @author Michael Bien * @author Sven Gothel + * @author Michael Bien */ -public abstract class PointerBuffer extends AbstractLongBuffer<PointerBuffer> { - - protected HashMap<Long, Buffer> dataMap = new HashMap<Long, Buffer>(); +public class PointerBuffer extends AbstractBuffer<PointerBuffer> { + public static final int ELEMENT_SIZE = Platform.is32Bit() ? Buffers.SIZEOF_INT : Buffers.SIZEOF_LONG ; + protected LongObjectHashMap dataMap = null; static { NativeLibrary.ensureNativeLibLoaded(); } - protected PointerBuffer(ByteBuffer bb) { - super(bb, elementSize()); + /** no backup array, use for direct usage only */ + PointerBuffer(ByteBuffer bb) { + super(Platform.is32Bit() ? bb.asIntBuffer() : bb.asLongBuffer(), ELEMENT_SIZE); + } + + /** supports backup array */ + PointerBuffer(IntBuffer b) { + super(b, ELEMENT_SIZE); + } + + /** supports backup array */ + PointerBuffer(LongBuffer b) { + super(b, ELEMENT_SIZE); + } + + private final void validateDataMap() { + if(null == dataMap) { + dataMap = new LongObjectHashMap(); + dataMap.setKeyNotFoundValue(null); + } } + /** Returns a non direct PointerBuffer in native order, having a backup array */ public static PointerBuffer allocate(int size) { - return new PointerBufferSE(ByteBuffer.wrap(new byte[elementSize() * size])); + if (Platform.is32Bit()) { + return new PointerBuffer(IntBuffer.wrap(new int[size])); + } else { + return new PointerBuffer(LongBuffer.wrap(new long[size])); + } } + /** Returns a direct PointerBuffer in native order, w/o backup array */ public static PointerBuffer allocateDirect(int size) { - return new PointerBufferSE(Buffers.newDirectByteBuffer(elementSize() * size)); + return new PointerBuffer(Buffers.newDirectByteBuffer(ELEMENT_SIZE * size)); } public static PointerBuffer wrap(ByteBuffer src) { - PointerBuffer res = new PointerBufferSE(src); - res.updateBackup(); - return res; + return new PointerBuffer(src); + } + /** + * Relative bulk get method. Copy the source values <code> src[position .. capacity] [</code> + * to this buffer and increment the position by <code>capacity-position</code>. */ + public final PointerBuffer put(PointerBuffer src) { + if (remaining() < src.remaining()) { + throw new IndexOutOfBoundsException(); + } + if( null == src.dataMap && null == dataMap ) { + // fast path no dataMap usage on both + while (src.hasRemaining()) { + put(src.get()); + } + } else { + while (src.hasRemaining()) { + final long addr = src.get(); + put(addr); + if( null != src.dataMap) { + Buffer bb = (Buffer) src.dataMap.get(addr); + if(null!=bb) { + validateDataMap(); + dataMap.put(addr, bb); + } else if( null != dataMap ) { + dataMap.remove(addr); + } + } else if( null != dataMap ) { + dataMap.remove(addr); + } + } + } + return this; + } + + /** Relative get method. Get the pointer value at the current position and increment the position by one. */ + public final long get() { + long r = get(position); + position++; + return r; } - public static int elementSize() { - return Platform.is32Bit() ? Buffers.SIZEOF_INT : Buffers.SIZEOF_LONG; + /** Absolute get method. Get the pointer value at the given index */ + public final long get(int idx) { + if (0 > idx || idx >= capacity) { + throw new IndexOutOfBoundsException(); + } + if (Platform.is32Bit()) { + return (long) ((IntBuffer) buffer).get(idx) & 0x00000000FFFFFFFFL; + } else { + return ((LongBuffer) buffer).get(idx); + } + } + + /** + * Relative bulk get method. Copy the pointer values <code> [ position .. position+length [</code> + * to the destination array <code> [ dest[offset] .. dest[offset+length] [ </code> + * and increment the position by <code>length</code>. */ + public final PointerBuffer get(long[] dest, int offset, int length) { + if (dest.length<offset+length) { + throw new IndexOutOfBoundsException(); + } + if (remaining() < length) { + throw new IndexOutOfBoundsException(); + } + while(length>0) { + dest[offset++] = get(position++); + length--; + } + return this; } - @Override - public final PointerBuffer put(PointerBuffer src) { - if (remaining() < src.remaining()) { + /** Absolute put method. Put the pointer value at the given index */ + public final PointerBuffer put(int idx, long v) { + if (0 > idx || idx >= capacity) { throw new IndexOutOfBoundsException(); } - long addr; - while (src.hasRemaining()) { - addr = src.get(); - put(addr); - Long addrL = new Long(addr); - Buffer bb = (Buffer) dataMap.get(addrL); - if(null!=bb) { - dataMap.put(addrL, bb); - } else { - dataMap.remove(addrL); - } + if (Platform.is32Bit()) { + ((IntBuffer) buffer).put(idx, (int) v); + } else { + ((LongBuffer) buffer).put(idx, v); + } + return this; + } + + /** Relative put method. Put the pointer value at the current position and increment the position by one. */ + public final PointerBuffer put(long value) { + put(position, value); + position++; + return this; + } + + /** + * Relative bulk put method. Put the pointer values <code> [ src[offset] .. src[offset+length] [</code> + * at the current position and increment the position by <code>length</code>. */ + public final PointerBuffer put(long[] src, int offset, int length) { + if (src.length<offset+length) { + throw new IndexOutOfBoundsException(); + } + if (remaining() < length) { + throw new IndexOutOfBoundsException(); + } + while(length>0) { + put(position++, src[offset++]); + length--; } return this; } /** Put the address of the given direct Buffer at the given position of this pointer array. - Adding a reference of the given direct Buffer to this object. */ + Adding a reference of the given direct Buffer to this object. + + @throws IllegalArgumentException if bb is null or not a direct buffer + */ public final PointerBuffer referenceBuffer(int index, Buffer bb) { if(null==bb) { - throw new RuntimeException("Buffer is null"); + throw new IllegalArgumentException("Buffer is null"); } if(!Buffers.isDirect(bb)) { - throw new RuntimeException("Buffer is not direct"); + throw new IllegalArgumentException("Buffer is not direct"); } long mask = Platform.is32Bit() ? 0x00000000FFFFFFFFL : 0xFFFFFFFFFFFFFFFFL ; long bbAddr = getDirectBufferAddressImpl(bb) & mask; if(0==bbAddr) { throw new RuntimeException("Couldn't determine native address of given Buffer: "+bb); } - - put(index, bbAddr); - dataMap.put(new Long(bbAddr), bb); + validateDataMap(); + put(index, bbAddr); + dataMap.put(bbAddr, bb); return this; } @@ -127,8 +237,11 @@ public abstract class PointerBuffer extends AbstractLongBuffer<PointerBuffer> { } public final Buffer getReferencedBuffer(int index) { - long addr = get(index); - return dataMap.get(new Long(addr)); + if(null != dataMap) { + long addr = get(index); + return (Buffer) dataMap.get(addr); + } + return null; } public final Buffer getReferencedBuffer() { @@ -143,5 +256,4 @@ public abstract class PointerBuffer extends AbstractLongBuffer<PointerBuffer> { public String toString() { return "PointerBuffer:"+super.toString(); } - } diff --git a/src/java/com/jogamp/common/nio/PointerBufferSE.java b/src/java/com/jogamp/common/nio/PointerBufferSE.java deleted file mode 100755 index f3fdc68..0000000 --- a/src/java/com/jogamp/common/nio/PointerBufferSE.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. - * Copyright (c) 2010 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * - Redistribution of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * - Redistribution in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of Sun Microsystems, Inc. or the names of - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * This software is provided "AS IS," without a warranty of any kind. ALL - * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, - * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A - * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN - * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR - * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR - * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR - * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR - * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE - * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, - * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF - * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * - * You acknowledge that this software is not designed or intended for use - * in the design, construction, operation or maintenance of any nuclear - * facility. - */ -package com.jogamp.common.nio; - -import com.jogamp.common.os.Platform; -import java.nio.*; - -/** - * @author Sven Gothel - * @author Michael Bien - */ -final class PointerBufferSE extends PointerBuffer { - - private Buffer pb; - - PointerBufferSE(ByteBuffer bb) { - super(bb); - - if (Platform.is32Bit()) { - this.pb = bb.asIntBuffer(); - } else { - this.pb = bb.asLongBuffer(); - } - } - - public final long get(int idx) { - if (0 > idx || idx >= capacity) { - throw new IndexOutOfBoundsException(); - } - if (Platform.is32Bit()) { - return (long) ((IntBuffer) pb).get(idx) & 0x00000000FFFFFFFFL; - } else { - return ((LongBuffer) pb).get(idx); - } - } - - public final PointerBufferSE put(int idx, long v) { - if (0 > idx || idx >= capacity) { - throw new IndexOutOfBoundsException(); - } - backup[idx] = v; - if (Platform.is32Bit()) { - ((IntBuffer) pb).put(idx, (int) v); - } else { - ((LongBuffer) pb).put(idx, v); - } - return this; - } - -} 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 30ef6fd..c57a288 100644 --- a/src/junit/com/jogamp/gluegen/test/junit/generation/BaseClass.java +++ b/src/junit/com/jogamp/gluegen/test/junit/generation/BaseClass.java @@ -32,6 +32,7 @@ import com.jogamp.common.nio.Buffers; import com.jogamp.common.nio.PointerBuffer; import com.jogamp.common.os.Platform; import java.nio.ByteBuffer; +import java.nio.ByteOrder; import java.nio.IntBuffer; import java.nio.LongBuffer; @@ -70,7 +71,6 @@ public class BaseClass { */ public void chapter__TestCoverageSignature(Bindingtest1 binding) throws Exception { int i; - long result; long context = 0; ByteBuffer bb=null; LongBuffer lb=null; @@ -82,7 +82,8 @@ public class BaseClass { String[] strings = null; int[] iarray = null; int iarray_offset = 0; - long l = 0; + long result = 0; + long l = result; result = binding.arrayTestInt32(context, ib); result = binding.arrayTestInt32(context, iarray, iarray_offset); @@ -137,34 +138,90 @@ public class BaseClass { l = binding.typeTestUIntPtrT(l, l); } + ByteBuffer newByteBuffer(int size, boolean direct) { + if(direct) { + final ByteBuffer bb = Buffers.newDirectByteBuffer(size); + Assert.assertTrue(bb.isDirect()); + return bb; + } else { + final ByteBuffer bb = ByteBuffer.wrap(new byte[size]); + Assert.assertTrue(bb.hasArray()); + Assert.assertTrue(!bb.isDirect()); + bb.order(ByteOrder.nativeOrder()); + Assert.assertTrue(bb.hasArray()); + Assert.assertTrue(!bb.isDirect()); + return bb; + } + } + + IntBuffer newIntBuffer(int size, boolean direct) { + if(direct) { + final IntBuffer ib = Buffers.newDirectIntBuffer(size); + Assert.assertTrue(ib.isDirect()); + return ib; + } else { + final IntBuffer ib = IntBuffer.wrap(new int[size]); + Assert.assertTrue(ib.hasArray()); + Assert.assertTrue(!ib.isDirect()); + return ib; + } + } + + LongBuffer newLongBuffer(int size, boolean direct) { + if(direct) { + final LongBuffer lb = Buffers.newDirectLongBuffer(size); + Assert.assertTrue(lb.isDirect()); + return lb; + } else { + final LongBuffer lb = LongBuffer.wrap(new long[size]); + Assert.assertTrue(!lb.isDirect()); + Assert.assertTrue(lb.hasArray()); + return lb; + } + } + + PointerBuffer newPointerBuffer(int size, boolean direct) { + if(direct) { + final PointerBuffer pb = PointerBuffer.allocateDirect(size); + Assert.assertTrue(pb.isDirect()); + Assert.assertTrue(pb.getBuffer().isDirect()); + return pb; + } else { + final PointerBuffer pb = PointerBuffer.allocate(size); + Assert.assertTrue(pb.hasArray()); + Assert.assertTrue(!pb.isDirect()); + return pb; + } + } + /** * Verifies if all methods / signatures are properly generated, * can be invoked and functions. * This is a compilation (coverage) and runtime time (semantic) test. * This covers indirect primitive arrays and direct NIO buffers. */ - public void chapter03TestCoverageFunctionalityDirectNIOAndPrimitiveArray(Bindingtest1 binding) throws Exception { + public void chapter03TestCoverageFunctionalityNIOAndPrimitiveArray(Bindingtest1 binding, boolean direct) throws Exception { int i; long result; - long context = 1; - LongBuffer lb = Buffers.newDirectLongBuffer(1); + final long context = 1; + LongBuffer lb = newLongBuffer(1, direct); lb.put(0, 10); - ByteBuffer bb2 = Buffers.newDirectByteBuffer(Buffers.SIZEOF_LONG); + ByteBuffer bb2 = newByteBuffer(Buffers.SIZEOF_LONG, direct); LongBuffer bb2L = bb2.asLongBuffer(); bb2L.put(0, 100); - IntBuffer ib1 = Buffers.newDirectByteBuffer(Buffers.SIZEOF_INT * Bindingtest1.ARRAY_SIZE).asIntBuffer(); + IntBuffer ib1 = newIntBuffer(Bindingtest1.ARRAY_SIZE, direct); for(i=0; i<Bindingtest1.ARRAY_SIZE; i++) { ib1.put(i, 1000); } - LongBuffer lb1 = Buffers.newDirectLongBuffer(Bindingtest1.ARRAY_SIZE); + LongBuffer lb1 = newLongBuffer(Bindingtest1.ARRAY_SIZE, direct); for(i=0; i<Bindingtest1.ARRAY_SIZE; i++) { lb1.put(i, 1000); } - LongBuffer lb2 = Buffers.newDirectLongBuffer(Bindingtest1.ARRAY_SIZE); + LongBuffer lb2 = newLongBuffer(Bindingtest1.ARRAY_SIZE, direct); for(i=0; i<Bindingtest1.ARRAY_SIZE; i++) { lb2.put(i, 10000); } @@ -211,7 +268,7 @@ public class BaseClass { // LongBuffer arrayTestFoo2 ( LongBuffer ) { lb2.rewind(); - LongBuffer lb3 = Buffers.newDirectLongBuffer(Bindingtest1.ARRAY_SIZE); + LongBuffer lb3 = newLongBuffer(Bindingtest1.ARRAY_SIZE, direct); lb3.put(lb2); lb3.rewind(); lb2.rewind(); @@ -256,7 +313,7 @@ public class BaseClass { // PointerBuffer arrayTestFoo3PtrPtr(PointerBuffer) { lb2.rewind(); - LongBuffer lb3 = Buffers.newDirectLongBuffer(Bindingtest1.ARRAY_SIZE*Bindingtest1.ARRAY_SIZE); + LongBuffer lb3 = newLongBuffer(Bindingtest1.ARRAY_SIZE*Bindingtest1.ARRAY_SIZE, direct); int j; for(j=0; j<Bindingtest1.ARRAY_SIZE; j++) { lb3.put(lb2); @@ -279,18 +336,21 @@ public class BaseClass { 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*Bindingtest1.ARRAY_SIZE; j++) { - Assert.assertTrue("Wrong result: s:"+lb2.get(j%Bindingtest1.ARRAY_SIZE)+" d: "+lb3.get(j), - 1+lb2.get(j%Bindingtest1.ARRAY_SIZE)==lb3.get(j)); + Assert.assertEquals("Wrong result: s:"+lb2.get(j%Bindingtest1.ARRAY_SIZE)+" d: "+lb3.get(j), + 1+lb2.get(j%Bindingtest1.ARRAY_SIZE), lb3.get(j)); } + Assert.assertEquals(0, binding.arrayTestFoo3PtrPtrValidation(pb2, 10000)); } + // PointerBuffer.alloc*(ARRAY_SIZE) // PointerBuffer.referenceBuffer(LongBuffer.getBuffer) // " " // PointerBuffer arrayTestFoo3PtrPtr(PointerBuffer) { - PointerBuffer pb = PointerBuffer.allocateDirect(Bindingtest1.ARRAY_SIZE); + PointerBuffer pb = newPointerBuffer(Bindingtest1.ARRAY_SIZE, direct); int j; for(j=0; j<Bindingtest1.ARRAY_SIZE; j++) { + // the referenced buffer must be direct, non direct is not supported LongBuffer lb3 = Buffers.newDirectLongBuffer(Bindingtest1.ARRAY_SIZE); lb3.put(lb2); lb2.rewind(); @@ -304,27 +364,76 @@ public class BaseClass { Assert.assertTrue("Wrong result: "+pb.capacity(), Bindingtest1.ARRAY_SIZE == pb.capacity()); Assert.assertTrue("Wrong result: "+pb.remaining(), Bindingtest1.ARRAY_SIZE == pb.remaining()); Assert.assertNotNull(pb.getReferencedBuffer(0)); - Assert.assertTrue("Wrong result: "+pb.getReferencedBuffer(0)+" != "+lb2, pb.getReferencedBuffer(0).equals(lb2)); + Assert.assertTrue("Wrong result: "+pb.getReferencedBuffer(0)+" != "+lb2, pb.getReferencedBuffer(0).equals(lb2)); - PointerBuffer pb2 = binding.arrayTestFoo3PtrPtr(pb); + PointerBuffer pb2 = binding.arrayTestFoo3PtrPtr(pb); // pb2 is shallow 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++) { - ByteBuffer bb = (ByteBuffer) pb.getReferencedBuffer(j); - LongBuffer i64b = bb.asLongBuffer(); + LongBuffer i64b = (LongBuffer) pb.getReferencedBuffer(j); for(i=0; i<Bindingtest1.ARRAY_SIZE; i++) { - Assert.assertTrue("Wrong result: ["+j+"]["+i+"] s:"+lb2.get(i)+" d: "+i64b.get(i), 1+lb2.get(i)==i64b.get(i)); + Assert.assertEquals("Wrong result: ["+j+"]["+i+"] s:"+lb2.get(i)+" d: "+i64b.get(i), + 1+lb2.get(i), i64b.get(i)); } } + Assert.assertEquals(0, binding.arrayTestFoo3PtrPtrValidation(pb, 10000)); + } + + // pb = PointerBuffer.alloc*(ARRAY_SIZE) + // arrayTestFoo3CopyPtrPtrA(PointerBuffer dst, PointerBuffer src) (Native deep copy w/ alloc) + // " " + // PointerBuffer arrayTestFoo3PtrPtr(PointerBuffer) + { + PointerBuffer pbS = newPointerBuffer(Bindingtest1.ARRAY_SIZE, direct); + int j; + for(j=0; j<Bindingtest1.ARRAY_SIZE; j++) { + // the referenced buffer must be direct, non direct is not supported + LongBuffer lb3 = Buffers.newDirectLongBuffer(Bindingtest1.ARRAY_SIZE); + lb3.put(lb2); + lb2.rewind(); + lb3.rewind(); + + pbS.referenceBuffer(lb3); + } + pbS.rewind(); + Assert.assertTrue("Wrong result: "+pbS.capacity(), Bindingtest1.ARRAY_SIZE == pbS.capacity()); + Assert.assertTrue("Wrong result: "+pbS.remaining(), Bindingtest1.ARRAY_SIZE == pbS.remaining()); + Assert.assertNotNull(pbS.getReferencedBuffer(0)); + Assert.assertTrue("Wrong result: "+pbS.getReferencedBuffer(0)+" != "+lb2, pbS.getReferencedBuffer(0).equals(lb2)); + + PointerBuffer pbD = newPointerBuffer(Bindingtest1.ARRAY_SIZE, direct); + + // System.err.println("\n***pbS "+pbS); System.err.println("***pbD "+pbD); + binding.arrayTestFoo3CopyPtrPtrA(pbD, pbS); // pbD is shallow + Assert.assertTrue("Wrong result: "+pbD.capacity(), Bindingtest1.ARRAY_SIZE == pbD.capacity()); + Assert.assertTrue("Wrong result: "+pbD.remaining(), Bindingtest1.ARRAY_SIZE == pbD.remaining()); + + + PointerBuffer pbD2 = binding.arrayTestFoo3PtrPtr(pbD); // pbD2 is shallow + Assert.assertEquals(0, binding.arrayTestFoo3PtrPtrValidation(pbD, 10000)); + Assert.assertNotNull(pbD2); + Assert.assertTrue("Wrong result: "+pbD2.capacity(), Bindingtest1.ARRAY_SIZE == pbD2.capacity()); + Assert.assertTrue("Wrong result: "+pbD2.remaining(), Bindingtest1.ARRAY_SIZE == pbD2.remaining()); + Assert.assertEquals(0, binding.arrayTestFoo3PtrPtrValidation(pbD2, 10000)); } result = binding.bufferTest(lb); Assert.assertTrue("Wrong result: "+result, 10==result); - result = binding.bufferTestNioOnly(lb); - Assert.assertTrue("Wrong result: "+result, 10==result); + if(direct) { + result = binding.bufferTestNioOnly(lb); + Assert.assertTrue("Wrong result: "+result, 10==result); + } else { + Exception e = null; + try { + binding.bufferTestNioOnly(lb); + } catch (RuntimeException re) { + e = re; + } + Assert.assertNotNull(e); + } result = binding.doubleTest(context, lb, lb1, bb2, lb2); Assert.assertTrue("Wrong result: "+result, 1+10+8000+100+80000==result); @@ -332,8 +441,10 @@ public class BaseClass { result = binding.doubleTest(context, lb, larray1, larray1_offset, bb2, larray2, larray2_offset); Assert.assertTrue("Wrong result: "+result, 1+10+8000+100+80000==result); - result = binding.doubleTestNioOnly(context, lb, lb1, bb2, lb2); - Assert.assertTrue("Wrong result: "+result, 1+10+8000+100+80000==result); + if(direct) { + result = binding.doubleTestNioOnly(context, lb, lb1, bb2, lb2); + Assert.assertTrue("Wrong result: "+result, 1+10+8000+100+80000==result); + } result = binding.mixedTest(context, lb, lb1); Assert.assertTrue("Wrong result: "+result, 1+10+8000==result); @@ -341,8 +452,10 @@ public class BaseClass { result = binding.mixedTest(context, lb, larray1, larray1_offset); Assert.assertTrue("Wrong result: "+result, 1+10+8000==result); - result = binding.mixedTestNioOnly(context, lb, lb1); - Assert.assertTrue("Wrong result: "+result, 1+10+8000==result); + if(direct) { + result = binding.mixedTestNioOnly(context, lb, lb1); + Assert.assertTrue("Wrong result: "+result, 1+10+8000==result); + } result = binding.nopTest(); Assert.assertTrue("Wrong result: "+result, 42==result); @@ -356,14 +469,12 @@ public class BaseClass { i = binding.stringArrayRead(new String[] { "1234", "5678", "9a" }, 3); Assert.assertTrue("Wrong result: "+i, 10==i); - ByteBuffer bb3 = Buffers.newDirectByteBuffer(Buffers.SIZEOF_INT * 3); - IntBuffer ib = bb3.asIntBuffer(); + IntBuffer ib = newIntBuffer(3, direct); ib.put(0, 1); ib.put(1, 2); ib.put(2, 3); int[] iarray = new int[] { 1, 2, 3 }; - int iarray_offset = 0; i = binding.intArrayRead(ib, 3); Assert.assertTrue("Wrong result: "+i, 6==i); @@ -374,7 +485,7 @@ public class BaseClass { { long cfg_base = 0xAABBCCDD11223344L; - PointerBuffer pb = PointerBuffer.allocateDirect(Bindingtest1.ARRAY_SIZE); + PointerBuffer pb = newPointerBuffer(Bindingtest1.ARRAY_SIZE, direct); for(i=0; i<Bindingtest1.ARRAY_SIZE; i++) { long cfg_native; if(Platform.is32Bit()) { @@ -399,12 +510,14 @@ public class BaseClass { } } + public void chapter04TestPointerBuffer(Bindingtest1 binding) throws Exception { + } + /** * This covers indirect primitive arrays and indirect NIO buffers. */ - public void chapter04TestSomeFunctionsAllIndirect(Bindingtest1 binding) throws Exception { + public void chapter05TestSomeFunctionsAllIndirect(Bindingtest1 binding) throws Exception { int i; - long result; IntBuffer ib = IntBuffer.allocate(3); ib.put(0, 1); @@ -412,7 +525,6 @@ public class BaseClass { ib.put(2, 3); int[] iarray = new int[] { 1, 2, 3 }; - int iarray_offset = 0; i = binding.intArrayRead(ib, 3); Assert.assertTrue("Wrong result: "+i, 6==i); diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p1JavaEmitter.java b/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p1JavaEmitter.java index 5b6ac01..83faa9b 100644 --- a/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p1JavaEmitter.java +++ b/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p1JavaEmitter.java @@ -28,7 +28,10 @@ package com.jogamp.gluegen.test.junit.generation; +import java.io.IOException; + import com.jogamp.gluegen.test.junit.generation.impl.Bindingtest1p1Impl; +import com.jogamp.gluegen.test.junit.generation.impl.Bindingtest1p2Impl; import org.junit.Test; @@ -71,16 +74,40 @@ public class Test1p1JavaEmitter extends BaseClass { * This covers indirect primitive arrays and direct NIO buffers. */ @Test - public void chapter03TestCoverageFunctionalityDirectNIOAndPrimitiveArray() throws Exception { - chapter03TestCoverageFunctionalityDirectNIOAndPrimitiveArray(new Bindingtest1p1Impl()); + public void chapter03aTestCoverageFunctionalityDirectNIOAndPrimitiveArray() throws Exception { + chapter03TestCoverageFunctionalityNIOAndPrimitiveArray(new Bindingtest1p1Impl(), true); + } + + /** + * Verifies if all methods / signatures are properly generated, + * can be invoked and functions. + * This is a compilation (coverage) and runtime time (semantic) test. + * This covers indirect primitive arrays and indirect NIO buffers (nio using arrays). + */ + @Test + public void chapter03bTestCoverageFunctionalityIndirectNIOAndPrimitiveArray() throws Exception { + chapter03TestCoverageFunctionalityNIOAndPrimitiveArray(new Bindingtest1p1Impl(), false); + } + + /** + * This covers direct / indirect pointer buffers + */ + @Test + public void chapter04TestPointerBuffer() throws Exception { + chapter04TestPointerBuffer(new Bindingtest1p1Impl()); } /** * This covers indirect primitive arrays and indirect NIO buffers. */ @Test - public void chapter04TestSomeFunctionsAllIndirect() throws Exception { - chapter04TestSomeFunctionsAllIndirect(new Bindingtest1p1Impl()); + public void chapter05TestSomeFunctionsAllIndirect() throws Exception { + chapter05TestSomeFunctionsAllIndirect(new Bindingtest1p1Impl()); } + public static void main(String args[]) throws IOException { + String tstname = Test1p1JavaEmitter.class.getName(); + org.junit.runner.JUnitCore.main(tstname); + } + } diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p2ProcAddressEmitter.java b/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p2ProcAddressEmitter.java index 5323013..8fe4f86 100644 --- a/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p2ProcAddressEmitter.java +++ b/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p2ProcAddressEmitter.java @@ -28,6 +28,9 @@ package com.jogamp.gluegen.test.junit.generation; +import java.io.IOException; + +import com.jogamp.gluegen.test.junit.generation.impl.Bindingtest1p1Impl; import com.jogamp.gluegen.test.junit.generation.impl.Bindingtest1p2Impl; import com.jogamp.common.os.NativeLibrary; @@ -81,28 +84,39 @@ public class Test1p2ProcAddressEmitter extends BaseClass { * This covers indirect primitive arrays and direct NIO buffers. */ @Test - public void chapter03TestCoverageFunctionalityDirectNIOAndPrimitiveArray() throws Exception { - chapter03TestCoverageFunctionalityDirectNIOAndPrimitiveArray(new Bindingtest1p2Impl()); + public void chapter03aTestCoverageFunctionalityDirectNIOAndPrimitiveArray() throws Exception { + chapter03TestCoverageFunctionalityNIOAndPrimitiveArray(new Bindingtest1p1Impl(), true); } /** - * This covers indirect primitive arrays and indirect NIO buffers. + * Verifies if all methods / signatures are properly generated, + * can be invoked and functions. + * This is a compilation (coverage) and runtime time (semantic) test. + * This covers indirect primitive arrays and indirect NIO buffers (nio using arrays). + */ + @Test + public void chapter03bTestCoverageFunctionalityIndirectNIOAndPrimitiveArray() throws Exception { + chapter03TestCoverageFunctionalityNIOAndPrimitiveArray(new Bindingtest1p1Impl(), false); + } + + /** + * This covers direct / indirect pointer buffers */ @Test - public void chapter04TestSomeFunctionsAllIndirect() throws Exception { - chapter04TestSomeFunctionsAllIndirect(new Bindingtest1p2Impl()); + public void chapter04TestPointerBuffer() throws Exception { + this.chapter04TestPointerBuffer(new Bindingtest1p2Impl()); } - public static void main(String[] args) { - Test1p2ProcAddressEmitter test = new Test1p2ProcAddressEmitter(); - try { - test.chapter01TestLoadLibrary(); - test.chapter02TestClassExist(); - test.chapter03TestCoverageFunctionalityDirectNIOAndPrimitiveArray(); - test.chapter04TestSomeFunctionsAllIndirect(); - } catch (Exception e) { - e.printStackTrace(); - } + /** + * This covers indirect primitive arrays and indirect NIO buffers. + */ + @Test + public void chapter05TestSomeFunctionsAllIndirect() throws Exception { + chapter05TestSomeFunctionsAllIndirect(new Bindingtest1p2Impl()); } + public static void main(String args[]) throws IOException { + String tstname = Test1p2ProcAddressEmitter.class.getName(); + org.junit.runner.JUnitCore.main(tstname); + } } 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 6cf42b5..05a9889 100644 --- a/src/junit/com/jogamp/gluegen/test/junit/generation/test1.c +++ b/src/junit/com/jogamp/gluegen/test/junit/generation/test1.c @@ -54,6 +54,18 @@ MYAPI foo * * MYAPIENTRY arrayTestFoo3ArrayToPtrPtr(foo * array) { return result; } +MYAPI void MYAPIENTRY arrayTestFoo3CopyPtrPtrA(foo * * dest, const foo * * src) { + int i, j; + assert(NULL!=dest); + assert(NULL!=src); + for(j=0; j<ARRAY_SIZE; j++) { + dest[j] = calloc(ARRAY_SIZE, sizeof(foo)); + for(i=0; i<ARRAY_SIZE; i++) { + dest[j][i] = src[j][i]; + } + } +} + MYAPI foo * * MYAPIENTRY arrayTestFoo3PtrPtr(foo * * array ) { int i,j; assert(NULL!=array); @@ -65,6 +77,19 @@ MYAPI foo * * MYAPIENTRY arrayTestFoo3PtrPtr(foo * * array ) { return array; } +MYAPI int MYAPIENTRY arrayTestFoo3PtrPtrValidation(foo * * array, int startval) { + int i,j,v,p=0; + assert(NULL!=array); + for(j=0; j<ARRAY_SIZE; j++) { + for(i=0, v=startval; i<ARRAY_SIZE; i++, p++, v++) { + if(array[j][i] != v) { + return p; + } + } + } + return 0; +} + MYAPI foo MYAPIENTRY arrayTestFoo1(int64_t context, foo * array) { foo r=0; int i; 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 6230c51..5b1c241 100644 --- a/src/junit/com/jogamp/gluegen/test/junit/generation/test1.h +++ b/src/junit/com/jogamp/gluegen/test/junit/generation/test1.h @@ -46,9 +46,15 @@ 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); +/** Fills dest array ptr of ARRAY size with arrays (allocs) and copies content of src to it - COPY! */ +MYAPI void MYAPIENTRY arrayTestFoo3CopyPtrPtrA(foo * * dest, const foo * * src); + /** Returns a the passed array-array, each element incr by 1 - IDENTITY !*/ MYAPI foo * * MYAPIENTRY arrayTestFoo3PtrPtr(foo * * array ); +/** Returns 0 if ok, otherwise the linear position */ +MYAPI int MYAPIENTRY arrayTestFoo3PtrPtrValidation(foo * * array, int startval); + /** Returns *((foo *)object) */ MYAPI foo MYAPIENTRY bufferTest(void * object); |