From 58d9dd488cbd7eee530031ef9ea523037be175cd Mon Sep 17 00:00:00 2001 From: Sven Gothel <sgothel@jausoft.com> Date: Fri, 19 Mar 2010 05:12:40 +0100 Subject: Drop PointerBuffer.wrapNative2Java(..) in favor of a simple PointerBuffer.wrap(..), due to the new semantics, ie internal integer/long presentation. Fixed the javame code in this regard. --- .../sun/gluegen/runtime/PointerBuffer.java.javase | 33 +++++----------------- 1 file changed, 7 insertions(+), 26 deletions(-) (limited to 'src/java/com/sun/gluegen/runtime/PointerBuffer.java.javase') diff --git a/src/java/com/sun/gluegen/runtime/PointerBuffer.java.javase b/src/java/com/sun/gluegen/runtime/PointerBuffer.java.javase index 57ad05c..851c400 100755 --- a/src/java/com/sun/gluegen/runtime/PointerBuffer.java.javase +++ b/src/java/com/sun/gluegen/runtime/PointerBuffer.java.javase @@ -113,26 +113,6 @@ public class PointerBuffer { return res; } - /** - * Wraps pointer arrays created by native code. - * Note: In case this is not a 64bit system, each pointer is being converted. */ - public static PointerBuffer wrapNative2Java(ByteBuffer src, boolean keepDirect) { - PointerBuffer res; - if (CPU.is32Bit()) { - // Must convert each pointer from 32-bit to 64-bit - IntBuffer buf = src.asIntBuffer(); - int len = buf.capacity(); - res = (src.isDirect() && keepDirect) ? PointerBuffer.allocateDirect(len) : PointerBuffer.allocate(len); - for (int i = 0; i < len; i++) { - res.put(i, buf.get(i)); - } - } else { - res = new PointerBuffer(src); - res.updateBackup(); - } - return res; - } - public ByteBuffer getBuffer() { return bb; } @@ -145,10 +125,11 @@ public class PointerBuffer { if(0>idx || idx>=capacity) { throw new IndexOutOfBoundsException(); } - if(CPU.is32Bit()) + if(CPU.is32Bit()) { return ((IntBuffer)pb).get(idx); - else + } else { return ((LongBuffer)pb).get(idx); + } } public long get() { @@ -162,10 +143,11 @@ public class PointerBuffer { throw new IndexOutOfBoundsException(); } backup[idx] = v; - if (CPU.is32Bit()) + if(CPU.is32Bit()) { ((IntBuffer)pb).put(idx, (int)v); - else + } else { ((LongBuffer)pb).put(idx, v); + } return this; } @@ -184,5 +166,4 @@ public class PointerBuffer { public static int elementSize() { return CPU.is32Bit() ? BufferFactory.SIZEOF_INT : BufferFactory.SIZEOF_LONG; } - -} \ No newline at end of file +} -- cgit v1.2.3