diff options
Diffstat (limited to 'src/java/com/sun/gluegen')
-rw-r--r-- | src/java/com/sun/gluegen/JavaConfiguration.java | 4 | ||||
-rw-r--r-- | src/java/com/sun/gluegen/JavaEmitter.java | 24 | ||||
-rw-r--r-- | src/java/com/sun/gluegen/JavaMethodBindingEmitter.java | 2 | ||||
-rw-r--r-- | src/java/com/sun/gluegen/JavaType.java | 14 | ||||
-rw-r--r-- | src/java/com/sun/gluegen/StructLayout.java | 2 | ||||
-rw-r--r-- | src/java/com/sun/gluegen/test/TestPointerBufferEndian.java | 4 | ||||
-rw-r--r-- | src/java/com/sun/gluegen/test/TestStructAccessorEndian.java | 4 |
7 files changed, 34 insertions, 20 deletions
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..0a92735 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);"); @@ -1794,7 +1796,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; @@ -1828,7 +1830,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()) { diff --git a/src/java/com/sun/gluegen/JavaMethodBindingEmitter.java b/src/java/com/sun/gluegen/JavaMethodBindingEmitter.java index 8db4a3b..b5b5b9c 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 { 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); |