summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/java/com/jogamp/gluegen/runtime/Buffers.java13
-rwxr-xr-xsrc/java/com/jogamp/gluegen/runtime/CPU.java100
-rw-r--r--src/java/com/jogamp/gluegen/runtime/Int64Buffer.java169
-rwxr-xr-xsrc/java/com/jogamp/gluegen/runtime/Int64BufferME_CDC_FP.java94
-rwxr-xr-xsrc/java/com/jogamp/gluegen/runtime/Int64BufferSE.java80
-rw-r--r--src/java/com/jogamp/gluegen/runtime/Platform.java67
-rw-r--r--src/java/com/jogamp/gluegen/runtime/PointerBuffer.java22
-rwxr-xr-xsrc/java/com/jogamp/gluegen/runtime/PointerBufferME_CDC_FP.java4
-rwxr-xr-xsrc/java/com/jogamp/gluegen/runtime/PointerBufferSE.java6
-rw-r--r--src/java/com/sun/gluegen/CMethodBindingEmitter.java7
-rw-r--r--src/java/com/sun/gluegen/JavaConfiguration.java4
-rw-r--r--src/java/com/sun/gluegen/JavaEmitter.java86
-rw-r--r--src/java/com/sun/gluegen/JavaMethodBindingEmitter.java14
-rw-r--r--src/java/com/sun/gluegen/JavaType.java14
-rw-r--r--src/java/com/sun/gluegen/StructLayout.java2
-rw-r--r--src/java/com/sun/gluegen/test/TestPointerBufferEndian.java4
-rw-r--r--src/java/com/sun/gluegen/test/TestStructAccessorEndian.java4
-rw-r--r--src/junit/com/jogamp/gluegen/test/junit/BaseTest1.java201
-rw-r--r--src/junit/com/jogamp/gluegen/test/junit/test1-common.cfg15
-rw-r--r--src/junit/com/jogamp/gluegen/test/junit/test1.c93
-rw-r--r--src/junit/com/jogamp/gluegen/test/junit/test1.h39
-rw-r--r--src/native/common/CPU.c2
22 files changed, 842 insertions, 198 deletions
diff --git a/src/java/com/jogamp/gluegen/runtime/Buffers.java b/src/java/com/jogamp/gluegen/runtime/Buffers.java
index 11b2739..49f6e8b 100755
--- a/src/java/com/jogamp/gluegen/runtime/Buffers.java
+++ b/src/java/com/jogamp/gluegen/runtime/Buffers.java
@@ -263,6 +263,8 @@ public class Buffers {
return ((IntBuffer) buf).isDirect();
} else if (buf instanceof ShortBuffer) {
return ((ShortBuffer) buf).isDirect();
+ } else if (buf instanceof Int64Buffer) {
+ return ((Int64Buffer) buf).isDirect();
} else if (buf instanceof PointerBuffer) {
return ((PointerBuffer) buf).isDirect();
} else if (Platform.isJavaSE()) {
@@ -305,6 +307,9 @@ public class Buffers {
return pos * SIZEOF_CHAR;
}
}
+ } else if (buf instanceof Int64Buffer) {
+ Int64Buffer int64Buffer = (Int64Buffer) buf;
+ return int64Buffer.position() * Int64Buffer.elementSize();
} else if (buf instanceof PointerBuffer) {
PointerBuffer pointerBuffer = (PointerBuffer) buf;
return pointerBuffer.position() * PointerBuffer.elementSize();
@@ -329,6 +334,8 @@ public class Buffers {
return ((IntBuffer) buf).array();
} else if (buf instanceof ShortBuffer) {
return ((ShortBuffer) buf).array();
+ } else if (buf instanceof Int64Buffer) {
+ return ((Int64Buffer) buf).array();
} else if (buf instanceof PointerBuffer) {
return ((PointerBuffer) buf).array();
}else if(Platform.isJavaSE()) {
@@ -373,6 +380,9 @@ public class Buffers {
return (SIZEOF_CHAR * (((CharBuffer) buf).arrayOffset() + pos));
}
}
+ } else if (buf instanceof Int64Buffer) {
+ Int64Buffer int64Buffer = (Int64Buffer) buf;
+ return Int64Buffer.elementSize() * (int64Buffer.arrayOffset() + int64Buffer.position());
} else if (buf instanceof PointerBuffer) {
PointerBuffer pointerBuffer = (PointerBuffer) buf;
return PointerBuffer.elementSize() * (pointerBuffer.arrayOffset() + pointerBuffer.position());
@@ -681,6 +691,9 @@ public class Buffers {
bytesRemaining = elementsRemaining * SIZEOF_CHAR;
}
}
+ } else if (buffer instanceof Int64Buffer) {
+ Int64Buffer int64Buffer = (Int64Buffer) buffer;
+ bytesRemaining = int64Buffer.remaining() * Int64Buffer.elementSize();
} else if (buffer instanceof PointerBuffer) {
PointerBuffer pointerBuffer = (PointerBuffer) buffer;
bytesRemaining = pointerBuffer.remaining() * PointerBuffer.elementSize();
diff --git a/src/java/com/jogamp/gluegen/runtime/CPU.java b/src/java/com/jogamp/gluegen/runtime/CPU.java
deleted file mode 100755
index 9c2f81e..0000000
--- a/src/java/com/jogamp/gluegen/runtime/CPU.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright (c) 2005 Sun Microsystems, Inc. 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.
- *
- * Sun gratefully acknowledges that this software was originally authored
- * and developed by Kenneth Bradley Russell and Christopher John Kline.
- */
-
-package com.jogamp.gluegen.runtime;
-
-/** Provides information to autogenerated struct accessors about what
- kind of data model (32- or 64-bit) is being used by the currently
- running process. */
-
-public class CPU {
-
- private final static boolean is32Bit;
-
- static {
-
- NativeLibrary.ensureNativeLibLoaded();
-
- // Try to use Sun's sun.arch.data.model first ..
- int bits = getPointerSizeInBits();
- if ( 32 == bits || 64 == bits ) {
- is32Bit = ( 32 == bits );
- }else {
- // We don't seem to need an AccessController.doPrivileged() block
- // here as these system properties are visible even to unsigned
- // applets
- // Note: this code is replicated in StructLayout.java
- String os = Platform.getOS().toLowerCase();
- String cpu = Platform.getArch().toLowerCase();
-
- if ((os.startsWith("windows") && cpu.equals("x86")) ||
- (os.startsWith("windows") && cpu.equals("arm")) ||
- (os.startsWith("linux") && cpu.equals("i386")) ||
- (os.startsWith("linux") && cpu.equals("x86")) ||
- (os.startsWith("mac os") && cpu.equals("ppc")) ||
- (os.startsWith("mac os") && cpu.equals("i386")) ||
- (os.startsWith("darwin") && cpu.equals("ppc")) ||
- (os.startsWith("darwin") && cpu.equals("i386")) ||
- (os.startsWith("sunos") && cpu.equals("sparc")) ||
- (os.startsWith("sunos") && cpu.equals("x86")) ||
- (os.startsWith("freebsd") && cpu.equals("i386")) ||
- (os.startsWith("hp-ux") && cpu.equals("pa_risc2.0"))) {
- is32Bit = true;
- }else if ((os.startsWith("windows") && cpu.equals("amd64")) ||
- (os.startsWith("linux") && cpu.equals("amd64")) ||
- (os.startsWith("linux") && cpu.equals("x86_64")) ||
- (os.startsWith("linux") && cpu.equals("ia64")) ||
- (os.startsWith("mac os") && cpu.equals("x86_64")) ||
- (os.startsWith("darwin") && cpu.equals("x86_64")) ||
- (os.startsWith("sunos") && cpu.equals("sparcv9")) ||
- (os.startsWith("sunos") && cpu.equals("amd64"))) {
- is32Bit = false;
- }else{
- throw new RuntimeException("Please port CPU detection (32/64 bit) to your platform (" + os + "/" + cpu + ")");
- }
- }
- }
-
- public static boolean is32Bit() {
- return is32Bit;
- }
-
- public static native int getPointerSizeInBits();
-
-}
diff --git a/src/java/com/jogamp/gluegen/runtime/Int64Buffer.java b/src/java/com/jogamp/gluegen/runtime/Int64Buffer.java
new file mode 100644
index 0000000..98d0834
--- /dev/null
+++ b/src/java/com/jogamp/gluegen/runtime/Int64Buffer.java
@@ -0,0 +1,169 @@
+/*
+ * Copyright (c) 2010, Michael Bien
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the name of Michael Bien nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 Michael Bien 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.
+ */
+
+package com.jogamp.gluegen.runtime;
+
+import java.nio.ByteBuffer;
+
+/**
+ * Hardware independent container for native int64_t arrays.
+ *
+ * The native values (NIO direct ByteBuffer) are always 64bit wide.
+ *
+ * @author Michael Bien
+ * @author Sven Gothel
+ */
+public abstract class Int64Buffer {
+
+ protected final ByteBuffer bb;
+ protected int capacity;
+ protected int position;
+ protected long[] backup;
+
+ protected Int64Buffer(ByteBuffer bb) {
+ this.bb = bb;
+ }
+
+ public static Int64Buffer allocate(int size) {
+ if (Platform.isJavaSE()) {
+ return new Int64BufferSE(ByteBuffer.wrap(new byte[elementSize() * size]));
+ } else {
+ return new Int64BufferME_CDC_FP(ByteBuffer.wrap(new byte[elementSize() * size]));
+ }
+ }
+
+ public static Int64Buffer allocateDirect(int size) {
+ if (Platform.isJavaSE()) {
+ return new Int64BufferSE(Buffers.newDirectByteBuffer(elementSize() * size));
+ } else {
+ return new Int64BufferME_CDC_FP(Buffers.newDirectByteBuffer(elementSize() * size));
+ }
+ }
+
+ public static Int64Buffer wrap(ByteBuffer src) {
+ Int64Buffer res;
+ if (Platform.isJavaSE()) {
+ res = new Int64BufferSE(src);
+ } else {
+ res = new Int64BufferME_CDC_FP(src);
+ }
+ res.updateBackup();
+ return res;
+
+ }
+
+ void updateBackup() {
+ for (int i = 0; i < capacity; i++) {
+ backup[i] = get(i);
+ }
+ }
+
+ int arrayOffset() {
+ return 0;
+ }
+
+ public static int elementSize() {
+ return Buffers.SIZEOF_LONG;
+ }
+
+ public int limit() {
+ return capacity;
+ }
+
+ public int capacity() {
+ return capacity;
+ }
+
+ public int position() {
+ return position;
+ }
+
+ public Int64Buffer position(int newPos) {
+ if (0 > newPos || newPos >= capacity) {
+ throw new IndexOutOfBoundsException("Sorry to interrupt, but the position "+newPos+" was out of bounds. " +
+ "My capacity is "+capacity()+".");
+ }
+ position = newPos;
+ return this;
+ }
+
+ public int remaining() {
+ return capacity - position;
+ }
+
+ public boolean hasRemaining() {
+ return position < capacity;
+ }
+
+ public Int64Buffer rewind() {
+ position = 0;
+ return this;
+ }
+
+ boolean hasArray() {
+ return true;
+ }
+
+ public long[] array() {
+ return backup;
+ }
+
+ public ByteBuffer getBuffer() {
+ return bb;
+ }
+
+ public boolean isDirect() {
+ return bb.isDirect();
+ }
+
+ public long get() {
+ long r = get(position);
+ position++;
+ return r;
+ }
+
+ public abstract long get(int idx);
+
+ public abstract Int64Buffer put(int index, long value);
+
+ 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/Int64BufferME_CDC_FP.java b/src/java/com/jogamp/gluegen/runtime/Int64BufferME_CDC_FP.java
new file mode 100755
index 0000000..cedb737
--- /dev/null
+++ b/src/java/com/jogamp/gluegen/runtime/Int64BufferME_CDC_FP.java
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2003 Sun Microsystems, Inc. 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.gluegen.runtime;
+
+import java.nio.*;
+
+/**
+ * @author Sven Gothel
+ * @author Michael Bien
+ */
+final class Int64BufferME_CDC_FP extends Int64Buffer {
+
+ private IntBuffer pb;
+
+ Int64BufferME_CDC_FP(ByteBuffer bb) {
+ super(bb);
+ this.pb = bb.asIntBuffer();
+
+ capacity = bb.capacity() / elementSize();
+
+ position = 0;
+ backup = new long[capacity];
+ }
+
+ public long get(int idx) {
+ if (0 > idx || idx >= capacity) {
+ throw new IndexOutOfBoundsException();
+ }
+ idx = idx << 1; // 8-byte to 4-byte offset
+ long lo = 0x00000000FFFFFFFFL & ((long) pb.get(idx));
+ long hi = 0x00000000FFFFFFFFL & ((long) pb.get(idx + 1));
+ if (Platform.isLittleEndian()) {
+ return hi << 32 | lo;
+ }
+ return lo << 32 | hi;
+ }
+
+ public Int64Buffer put(int idx, long v) {
+ if (0 > idx || idx >= capacity) {
+ throw new IndexOutOfBoundsException();
+ }
+ backup[idx] = v;
+ idx = idx << 1; // 8-byte to 4-byte offset
+ int lo = (int) ((v) & 0x00000000FFFFFFFFL);
+ int hi = (int) ((v >> 32) & 0x00000000FFFFFFFFL);
+ if (Platform.isLittleEndian()) {
+ pb.put(idx, lo);
+ pb.put(idx + 1, hi);
+ } else {
+ pb.put(idx, hi);
+ pb.put(idx + 1, lo);
+ }
+ return this;
+ }
+
+ public Int64Buffer put(long v) {
+ put(position, v);
+ position++;
+ return this;
+ }
+}
diff --git a/src/java/com/jogamp/gluegen/runtime/Int64BufferSE.java b/src/java/com/jogamp/gluegen/runtime/Int64BufferSE.java
new file mode 100755
index 0000000..166d0c6
--- /dev/null
+++ b/src/java/com/jogamp/gluegen/runtime/Int64BufferSE.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2003 Sun Microsystems, Inc. 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.gluegen.runtime;
+
+import java.nio.*;
+
+/**
+ * @author Sven Gothel
+ * @author Michael Bien
+ */
+final class Int64BufferSE extends Int64Buffer {
+
+ private LongBuffer pb;
+
+ Int64BufferSE(ByteBuffer bb) {
+ super(bb);
+
+ this.pb = bb.asLongBuffer();
+
+ capacity = bb.capacity() / elementSize();
+
+ position = 0;
+ backup = new long[capacity];
+ }
+
+ public long get(int idx) {
+ if (0 > idx || idx >= capacity) {
+ throw new IndexOutOfBoundsException();
+ }
+ return pb.get(idx);
+ }
+
+ public Int64Buffer put(int idx, long v) {
+ if (0 > idx || idx >= capacity) {
+ throw new IndexOutOfBoundsException();
+ }
+ backup[idx] = v;
+ pb.put(idx, v);
+ return this;
+ }
+
+ public Int64Buffer put(long v) {
+ put(position, v);
+ position++;
+ return this;
+ }
+}
diff --git a/src/java/com/jogamp/gluegen/runtime/Platform.java b/src/java/com/jogamp/gluegen/runtime/Platform.java
index 8245b51..a621279 100644
--- a/src/java/com/jogamp/gluegen/runtime/Platform.java
+++ b/src/java/com/jogamp/gluegen/runtime/Platform.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, Michael Bien
+ * Copyright (c) 2010, Michael Bien, Sven Gothel
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -36,15 +36,62 @@ import java.nio.ShortBuffer;
/**
* Utility class for querying platform specific properties.
- * @author Michael Bien
+ * @author Michael Bien, Sven Gothel
*/
public class Platform {
public static final boolean JAVA_SE;
public static final boolean LITTLE_ENDIAN;
+ private final static boolean is32Bit;
+ private final static int pointerSizeInBits;
+ private final static String os, arch;
+
static {
- // platform
+ NativeLibrary.ensureNativeLibLoaded();
+
+ // We don't seem to need an AccessController.doPrivileged() block
+ // here as these system properties are visible even to unsigned
+ // applets
+ os = System.getProperty("os.name");
+ arch = System.getProperty("os.arch");
+
+ pointerSizeInBits = getPointerSizeInBitsImpl();
+
+ // Try to use Sun's sun.arch.data.model first ..
+ if ( 32 == pointerSizeInBits || 64 == pointerSizeInBits ) {
+ is32Bit = ( 32 == pointerSizeInBits );
+ }else {
+ String os_lc = os.toLowerCase();
+ String arch_lc = arch.toLowerCase();
+
+ if ((os_lc.startsWith("windows") && arch_lc.equals("x86")) ||
+ (os_lc.startsWith("windows") && arch_lc.equals("arm")) ||
+ (os_lc.startsWith("linux") && arch_lc.equals("i386")) ||
+ (os_lc.startsWith("linux") && arch_lc.equals("x86")) ||
+ (os_lc.startsWith("mac os_lc") && arch_lc.equals("ppc")) ||
+ (os_lc.startsWith("mac os_lc") && arch_lc.equals("i386")) ||
+ (os_lc.startsWith("darwin") && arch_lc.equals("ppc")) ||
+ (os_lc.startsWith("darwin") && arch_lc.equals("i386")) ||
+ (os_lc.startsWith("sunos_lc") && arch_lc.equals("sparc")) ||
+ (os_lc.startsWith("sunos_lc") && arch_lc.equals("x86")) ||
+ (os_lc.startsWith("freebsd") && arch_lc.equals("i386")) ||
+ (os_lc.startsWith("hp-ux") && arch_lc.equals("pa_risc2.0"))) {
+ is32Bit = true;
+ } else if ((os_lc.startsWith("windows") && arch_lc.equals("amd64")) ||
+ (os_lc.startsWith("linux") && arch_lc.equals("amd64")) ||
+ (os_lc.startsWith("linux") && arch_lc.equals("x86_64")) ||
+ (os_lc.startsWith("linux") && arch_lc.equals("ia64")) ||
+ (os_lc.startsWith("mac os_lc") && arch_lc.equals("x86_64")) ||
+ (os_lc.startsWith("darwin") && arch_lc.equals("x86_64")) ||
+ (os_lc.startsWith("sunos_lc") && arch_lc.equals("sparcv9")) ||
+ (os_lc.startsWith("sunos_lc") && arch_lc.equals("amd64"))) {
+ is32Bit = false;
+ }else{
+ throw new RuntimeException("Please port CPU detection (32/64 bit) to your platform (" + os_lc + "/" + arch_lc + ")");
+ }
+ }
+
// fast path
boolean se = System.getProperty("java.runtime.name").indexOf("Java SE") != -1;
@@ -69,6 +116,8 @@ public class Platform {
private Platform() {}
+ private static native int getPointerSizeInBitsImpl();
+
/**
* Returns true only if this program is running on the Java Standard Edition.
*/
@@ -87,21 +136,27 @@ public class Platform {
* Returns the OS name.
*/
public static String getOS() {
- return System.getProperty("os.name");
+ return os;
}
/**
* Returns the CPU architecture String.
*/
public static String getArch() {
- return System.getProperty("os.arch");
+ return arch;
}
/**
* Returns true if this JVM is a 32bit JVM.
*/
public static boolean is32Bit() {
- return CPU.is32Bit();
+ return is32Bit;
+ }
+
+ public static int getPointerSizeInBits() {
+ return pointerSizeInBits;
}
}
+
+
diff --git a/src/java/com/jogamp/gluegen/runtime/PointerBuffer.java b/src/java/com/jogamp/gluegen/runtime/PointerBuffer.java
index ff1bc2e..0adbb36 100644
--- a/src/java/com/jogamp/gluegen/runtime/PointerBuffer.java
+++ b/src/java/com/jogamp/gluegen/runtime/PointerBuffer.java
@@ -33,7 +33,11 @@ package com.jogamp.gluegen.runtime;
import java.nio.ByteBuffer;
/**
- * Hardware independent container for native long- and pointer arrays.
+ * 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
*/
@@ -87,7 +91,7 @@ public abstract class PointerBuffer {
}
public static int elementSize() {
- return CPU.is32Bit() ? Buffers.SIZEOF_INT : Buffers.SIZEOF_LONG;
+ return Platform.is32Bit() ? Buffers.SIZEOF_INT : Buffers.SIZEOF_LONG;
}
public int limit() {
@@ -152,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/jogamp/gluegen/runtime/PointerBufferME_CDC_FP.java b/src/java/com/jogamp/gluegen/runtime/PointerBufferME_CDC_FP.java
index 0ffd974..1134ee7 100755
--- a/src/java/com/jogamp/gluegen/runtime/PointerBufferME_CDC_FP.java
+++ b/src/java/com/jogamp/gluegen/runtime/PointerBufferME_CDC_FP.java
@@ -59,7 +59,7 @@ final class PointerBufferME_CDC_FP extends PointerBuffer {
if (0 > idx || idx >= capacity) {
throw new IndexOutOfBoundsException();
}
- if (CPU.is32Bit()) {
+ if (Platform.is32Bit()) {
return pb.get(idx);
} else {
idx = idx << 1; // 8-byte to 4-byte offset
@@ -77,7 +77,7 @@ final class PointerBufferME_CDC_FP extends PointerBuffer {
throw new IndexOutOfBoundsException();
}
backup[idx] = v;
- if (CPU.is32Bit()) {
+ if (Platform.is32Bit()) {
pb.put(idx, (int) v);
} else {
idx = idx << 1; // 8-byte to 4-byte offset
diff --git a/src/java/com/jogamp/gluegen/runtime/PointerBufferSE.java b/src/java/com/jogamp/gluegen/runtime/PointerBufferSE.java
index 9c67dda..6f131a9 100755
--- a/src/java/com/jogamp/gluegen/runtime/PointerBufferSE.java
+++ b/src/java/com/jogamp/gluegen/runtime/PointerBufferSE.java
@@ -48,7 +48,7 @@ final class PointerBufferSE extends PointerBuffer {
PointerBufferSE(ByteBuffer bb) {
super(bb);
- if (CPU.is32Bit()) {
+ if (Platform.is32Bit()) {
this.pb = bb.asIntBuffer();
} else {
this.pb = bb.asLongBuffer();
@@ -64,7 +64,7 @@ final class PointerBufferSE extends PointerBuffer {
if (0 > idx || idx >= capacity) {
throw new IndexOutOfBoundsException();
}
- if (CPU.is32Bit()) {
+ if (Platform.is32Bit()) {
return ((IntBuffer) pb).get(idx);
} else {
return ((LongBuffer) pb).get(idx);
@@ -76,7 +76,7 @@ final class PointerBufferSE extends PointerBuffer {
throw new IndexOutOfBoundsException();
}
backup[idx] = v;
- if (CPU.is32Bit()) {
+ if (Platform.is32Bit()) {
((IntBuffer) pb).put(idx, (int) v);
} else {
((LongBuffer) pb).put(idx, v);
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/JavaConfiguration.java b/src/java/com/sun/gluegen/JavaConfiguration.java
index 2bcb17a..e0a0eb6 100644
--- a/src/java/com/sun/gluegen/JavaConfiguration.java
+++ b/src/java/com/sun/gluegen/JavaConfiguration.java
@@ -104,7 +104,7 @@ public class JavaConfiguration {
/**
* The package in which the generated glue code expects to find its
- * run-time helper classes (Buffer, CPU,
+ * run-time helper classes (Buffers, Platform,
* StructAccessor). Defaults to "com.jogamp.gluegen.runtime".
*/
private String gluegenRuntimePackage = "com.jogamp.gluegen.runtime";
@@ -308,7 +308,7 @@ public class JavaConfiguration {
}
/** Returns the package in which the generated glue code expects to
- find its run-time helper classes (Buffer, CPU,
+ find its run-time helper classes (Buffers, Platform,
StructAccessor). Defaults to "com.jogamp.gluegen.runtime". */
public String gluegenRuntimePackage() {
return gluegenRuntimePackage;
diff --git a/src/java/com/sun/gluegen/JavaEmitter.java b/src/java/com/sun/gluegen/JavaEmitter.java
index 0759d81..25aeb16 100644
--- a/src/java/com/sun/gluegen/JavaEmitter.java
+++ b/src/java/com/sun/gluegen/JavaEmitter.java
@@ -700,7 +700,7 @@ public class JavaEmitter implements GlueEmitter {
// arg_direct,
// ... );
// }
- // private native void fooMethod0(Object arg, int arg_byte_offset, boolean arg_is_direct, ...);
+ // private native void fooMethod1(Object arg, int arg_byte_offset, boolean arg_is_direct, ...);
//
// Method taking primitive array argument:
// Interface class:
@@ -713,13 +713,15 @@ public class JavaEmitter implements GlueEmitter {
// }
// public void fooMethod(IntBuffer arg) {
// ... bounds checks, etc. ...
- // if (arg.isDirect()) {
- // fooMethod0(arg, computeDirectBufferByteOffset(arg));
- // } else {
- // fooMethod1(getIndirectBufferArray(arg), computeIndirectBufferByteOffset(arg));
- // }
+ //
+ // boolean arg_direct = BufferFactory.isDirect(arg);
+ //
+ // fooMethod1(arg_direct?arg:BufferFactory.getArray(arg),
+ // arg_direct?BufferFactory.getDirectBufferByteOffset(arg):BufferFactory.getIndirectBufferByteOffset(arg),
+ // arg_direct,
+ // ... );
// }
- // private native void fooMethod0(Object arg, int arg_byte_offset, boolean arg_is_direct, ...);
+ // private native void fooMethod1(Object arg, int arg_byte_offset, boolean arg_is_direct, ...);
//
// Note in particular that the public entry point taking an
// array is merely a special case of the indirect buffer case.
@@ -909,7 +911,7 @@ public class JavaEmitter implements GlueEmitter {
}
writer.println(" public static int size() {");
if (doBaseClass) {
- writer.println(" if (CPU.is32Bit()) {");
+ writer.println(" if (Platform.is32Bit()) {");
writer.println(" return " + containingTypeName + "32" + ".size();");
writer.println(" } else {");
writer.println(" return " + containingTypeName + "64" + ".size();");
@@ -925,7 +927,7 @@ public class JavaEmitter implements GlueEmitter {
writer.println(" }");
writer.println();
writer.println(" public static " + containingTypeName + " create(java.nio.ByteBuffer buf) {");
- writer.println(" if (CPU.is32Bit()) {");
+ writer.println(" if (Platform.is32Bit()) {");
writer.println(" return new " + containingTypeName + "32(buf);");
writer.println(" } else {");
writer.println(" return new " + containingTypeName + "64(buf);");
@@ -1213,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);
@@ -1300,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)) {
@@ -1698,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 ||
@@ -1712,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());
@@ -1719,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);
@@ -1751,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;
}
@@ -1762,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()) {
@@ -1794,7 +1836,7 @@ public class JavaEmitter implements GlueEmitter {
if (convertToArrays) {
result = result.replaceJavaArgumentType(i, javaType(ArrayTypes.longArrayClass));
} else {
- result = result.replaceJavaArgumentType(i, JavaType.forNIOPointerBufferClass());
+ result = result.replaceJavaArgumentType(i, JavaType.forNIOInt64BufferClass());
}
} else if (t.isCFloatPointerType()) {
arrayPossible = true;
@@ -1816,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()) {
@@ -1828,7 +1872,7 @@ public class JavaEmitter implements GlueEmitter {
} else if (t.isCInt32PointerType()) {
result = result.replaceJavaArgumentType(-1, JavaType.forNIOIntBufferClass());
} else if (t.isCInt64PointerType()) {
- result = result.replaceJavaArgumentType(-1, JavaType.forNIOPointerBufferClass());
+ result = result.replaceJavaArgumentType(-1, JavaType.forNIOInt64BufferClass());
} else if (t.isCFloatPointerType()) {
result = result.replaceJavaArgumentType(-1, JavaType.forNIOFloatBufferClass());
} else if (t.isCDoublePointerType()) {
@@ -1838,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 8db4a3b..4153e32 100644
--- a/src/java/com/sun/gluegen/JavaMethodBindingEmitter.java
+++ b/src/java/com/sun/gluegen/JavaMethodBindingEmitter.java
@@ -589,7 +589,7 @@ public class JavaMethodBindingEmitter extends FunctionEmitter
}
if (type.isNIOBuffer()) {
- if(type.isNIOPointerBuffer()) {
+ if(type.isNIOInt64Buffer() || type.isNIOPointerBuffer()) {
if (directNIOOnly) {
writer.print( getArgumentName(i)+ " != null ? " + getArgumentName(i) + ".getBuffer() : null");
} else {
@@ -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/java/com/sun/gluegen/JavaType.java b/src/java/com/sun/gluegen/JavaType.java
index 19ac945..23f48b2 100644
--- a/src/java/com/sun/gluegen/JavaType.java
+++ b/src/java/com/sun/gluegen/JavaType.java
@@ -71,6 +71,7 @@ public class JavaType {
private static JavaType nioIntBufferType;
private static JavaType nioLongBufferType;
private static JavaType nioPointerBufferType;
+ private static JavaType nioInt64BufferType;
private static JavaType nioFloatBufferType;
private static JavaType nioDoubleBufferType;
private static JavaType nioByteBufferArrayType;
@@ -194,6 +195,12 @@ public class JavaType {
return nioLongBufferType;
}
+ public static JavaType forNIOInt64BufferClass() {
+ if(nioInt64BufferType == null)
+ nioInt64BufferType = createForClass(com.jogamp.gluegen.runtime.Int64Buffer.class);
+ return nioInt64BufferType;
+ }
+
public static JavaType forNIOPointerBufferClass() {
if(nioPointerBufferType == null)
nioPointerBufferType = createForClass(com.jogamp.gluegen.runtime.PointerBuffer.class);
@@ -333,7 +340,8 @@ public class JavaType {
public boolean isNIOBuffer() {
return clazz != null && ( (java.nio.Buffer.class).isAssignableFrom(clazz) ||
- (com.jogamp.gluegen.runtime.PointerBuffer.class).isAssignableFrom(clazz) ) ;
+ (com.jogamp.gluegen.runtime.PointerBuffer.class).isAssignableFrom(clazz) ||
+ (com.jogamp.gluegen.runtime.Int64Buffer.class).isAssignableFrom(clazz) ) ;
}
public boolean isNIOByteBuffer() {
@@ -353,6 +361,10 @@ public class JavaType {
return (clazz == java.nio.LongBuffer.class);
}
+ public boolean isNIOInt64Buffer() {
+ return (clazz == com.jogamp.gluegen.runtime.Int64Buffer.class);
+ }
+
public boolean isNIOPointerBuffer() {
return (clazz == com.jogamp.gluegen.runtime.PointerBuffer.class);
}
diff --git a/src/java/com/sun/gluegen/StructLayout.java b/src/java/com/sun/gluegen/StructLayout.java
index 7045f89..76cd351 100644
--- a/src/java/com/sun/gluegen/StructLayout.java
+++ b/src/java/com/sun/gluegen/StructLayout.java
@@ -120,7 +120,7 @@ public class StructLayout {
public static StructLayout createForCurrentPlatform() {
- // Note: this code is replicated in CPU.java
+ // Note: this code is replicated in (from?) Platform.java
String os = System.getProperty("os.name").toLowerCase();
String cpu = System.getProperty("os.arch").toLowerCase();
if ((os.startsWith("windows") && cpu.equals("x86"))) {
diff --git a/src/java/com/sun/gluegen/test/TestPointerBufferEndian.java b/src/java/com/sun/gluegen/test/TestPointerBufferEndian.java
index 0126b72..96e4e87 100644
--- a/src/java/com/sun/gluegen/test/TestPointerBufferEndian.java
+++ b/src/java/com/sun/gluegen/test/TestPointerBufferEndian.java
@@ -8,12 +8,12 @@ public class TestPointerBufferEndian {
public static void main (String[] args) {
boolean direct = args.length>0 && args[0].equals("-direct");
boolean ok = true;
- int bitsPtr = CPU.getPointerSizeInBits();
+ int bitsPtr = Platform.getPointerSizeInBits();
String bitsProp = System.getProperty("sun.arch.data.model");
String os = System.getProperty("os.name");
String cpu = System.getProperty("os.arch");
System.out.println("OS: <"+os+"> CPU: <"+cpu+"> Bits: <"+bitsPtr+"/"+bitsProp+">");
- System.out.println("CPU is: "+ (CPU.is32Bit()?"32":"64") + " bit");
+ System.out.println("CPU is: "+ (Platform.is32Bit()?"32":"64") + " bit");
System.out.println("Buffer is in: "+ (Platform.isLittleEndian()?"little":"big") + " endian");
PointerBuffer ptr = direct ? PointerBuffer.allocateDirect(3) : PointerBuffer.allocate(3);
ptr.put(0, 0x0123456789ABCDEFL);
diff --git a/src/java/com/sun/gluegen/test/TestStructAccessorEndian.java b/src/java/com/sun/gluegen/test/TestStructAccessorEndian.java
index 89ccb5a..7202056 100644
--- a/src/java/com/sun/gluegen/test/TestStructAccessorEndian.java
+++ b/src/java/com/sun/gluegen/test/TestStructAccessorEndian.java
@@ -7,12 +7,12 @@ import java.nio.*;
public class TestStructAccessorEndian {
public static void main (String args[]) {
boolean ok = true;
- int bitsPtr = CPU.getPointerSizeInBits();
+ int bitsPtr = Platform.getPointerSizeInBits();
String bitsProp = System.getProperty("sun.arch.data.model");
String os = System.getProperty("os.name");
String cpu = System.getProperty("os.arch");
System.out.println("OS: <"+os+"> CPU: <"+cpu+"> Bits: <"+bitsPtr+"/"+bitsProp+">");
- System.out.println("CPU is: "+ (CPU.is32Bit()?"32":"64") + " bit");
+ System.out.println("CPU is: "+ (Platform.is32Bit()?"32":"64") + " bit");
System.out.println("Buffer is in: "+ (Platform.isLittleEndian()?"little":"big") + " endian");
ByteBuffer tst = Buffers.newDirectByteBuffer(Buffers.SIZEOF_LONG * 3);
StructAccessor acc = new StructAccessor(tst);
diff --git a/src/junit/com/jogamp/gluegen/test/junit/BaseTest1.java b/src/junit/com/jogamp/gluegen/test/junit/BaseTest1.java
index ac2d22c..420dc2b 100644
--- a/src/junit/com/jogamp/gluegen/test/junit/BaseTest1.java
+++ b/src/junit/com/jogamp/gluegen/test/junit/BaseTest1.java
@@ -34,6 +34,8 @@ 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;
@@ -87,30 +89,42 @@ public class BaseTest1 {
long result;
long context = 0;
ByteBuffer bb=null;
+ Int64Buffer lb=null;
PointerBuffer pb=null;
- LongBuffer 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.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);
- 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();
@@ -122,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);
}
/**
@@ -135,66 +152,157 @@ public class BaseTest1 {
long result;
long context = 1;
- ByteBuffer bb1 = Buffers.newDirectByteBuffer(Buffers.SIZEOF_LONG);
- LongBuffer bb1L = bb1.asLongBuffer();
- bb1L.put(0, 10);
+ Int64Buffer lb = Int64Buffer.allocateDirect(1);
+ lb.put(0, 10);
ByteBuffer bb2 = Buffers.newDirectByteBuffer(Buffers.SIZEOF_LONG);
- LongBuffer bb2L = bb2.asLongBuffer();
+ Int64Buffer bb2L = Int64Buffer.wrap(bb2);
bb2L.put(0, 100);
- PointerBuffer pb1 = PointerBuffer.allocateDirect(BindingTest1.ARRAY_SIZE);
+ IntBuffer ib1 = Buffers.newDirectByteBuffer(Buffers.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.arrayTest(context, larray1, array1_offset);
+ result = binding.arrayTestInt64(context, lb1);
Assert.assertTrue("Wrong result: "+result, 1+8000==result);
- result = binding.arrayTestNioOnly(context, pb1);
+ result = binding.arrayTestInt64(context, larray1, larray1_offset);
Assert.assertTrue("Wrong result: "+result, 1+8000==result);
- result = binding.bufferTest(bb1);
+ result = binding.arrayTestFoo1(context, lb1);
+ Assert.assertTrue("Wrong result: "+result, 1+8000==result);
+
+ 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);
- 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();
@@ -223,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 31c5f40..f654467 100644
--- a/src/junit/com/jogamp/gluegen/test/junit/test1.c
+++ b/src/junit/com/jogamp/gluegen/test/junit/test1.c
@@ -1,18 +1,76 @@
#include "test1.h"
#include <assert.h>
#include <stdlib.h>
+#include <stdio.h>
+#include <string.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 * 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);
- // 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 +80,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 arrayTestFoo1(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 arrayTestFoo1(context, array1) +
+ arrayTestFoo1( 0, array2) +
bufferTest(object1) +
bufferTest(object2);
}
-foo arrayTestNioOnly(long context, foo * array ) {
- return arrayTest(context, array);
+foo arrayTestFooNioOnly(int64_t context, foo * array ) {
+ return arrayTestFoo1(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);
}
@@ -99,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 38b4911..d0e50e5 100644
--- a/src/junit/com/jogamp/gluegen/test/junit/test1.h
+++ b/src/junit/com/jogamp/gluegen/test/junit/test1.h
@@ -11,34 +11,51 @@
#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 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);
/** 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);
@@ -55,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);
+
diff --git a/src/native/common/CPU.c b/src/native/common/CPU.c
index cde2732..0cc7adc 100644
--- a/src/native/common/CPU.c
+++ b/src/native/common/CPU.c
@@ -4,7 +4,7 @@
#include <assert.h>
JNIEXPORT jint JNICALL
-Java_com_jogamp_gluegen_runtime_CPU_getPointerSizeInBits(JNIEnv *env, jclass _unused) {
+Java_com_jogamp_gluegen_runtime_Platform_getPointerSizeInBitsImpl(JNIEnv *env, jclass _unused) {
return sizeof(void *) * 8;
}