summaryrefslogtreecommitdiffstats
path: root/src/java/com/sun/gluegen/runtime
diff options
context:
space:
mode:
authorKenneth Russel <[email protected]>2009-06-15 22:39:33 +0000
committerKenneth Russel <[email protected]>2009-06-15 22:39:33 +0000
commit90bcb596e88898f807b39c9e7c85485ab8c006b6 (patch)
treecd8364c36dc0035fde6660808a803d28e69b3fbc /src/java/com/sun/gluegen/runtime
parent9e979e542165358b5c3684078e193f9c706f1eab (diff)
Deleted obsolete source code in preparation for copying JOGL_2_SANDBOX
on to trunk git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/../svn-server-sync/gluegen/trunk@146 a78bb65f-1512-4460-ba86-f6dc96a7bf27
Diffstat (limited to 'src/java/com/sun/gluegen/runtime')
-rwxr-xr-xsrc/java/com/sun/gluegen/runtime/BufferFactory.java.javame_cdc_fp230
-rwxr-xr-xsrc/java/com/sun/gluegen/runtime/BufferFactory.java.javase284
-rwxr-xr-xsrc/java/com/sun/gluegen/runtime/BufferFactoryInternal.java115
-rwxr-xr-xsrc/java/com/sun/gluegen/runtime/CPU.java82
-rwxr-xr-xsrc/java/com/sun/gluegen/runtime/DynamicLinker.java49
-rwxr-xr-xsrc/java/com/sun/gluegen/runtime/DynamicLookupHelper.java50
-rwxr-xr-xsrc/java/com/sun/gluegen/runtime/MacOSXDynamicLinkerImpl.java49
-rwxr-xr-xsrc/java/com/sun/gluegen/runtime/NativeLibLoader.java105
-rwxr-xr-xsrc/java/com/sun/gluegen/runtime/NativeLibrary.java404
-rw-r--r--src/java/com/sun/gluegen/runtime/ProcAddressHelper.java118
-rwxr-xr-xsrc/java/com/sun/gluegen/runtime/StructAccessor.java.javame_cdc_fp135
-rwxr-xr-xsrc/java/com/sun/gluegen/runtime/StructAccessor.java.javase191
-rwxr-xr-xsrc/java/com/sun/gluegen/runtime/UnixDynamicLinkerImpl.java55
-rwxr-xr-xsrc/java/com/sun/gluegen/runtime/WindowsDynamicLinkerImpl.java38
14 files changed, 0 insertions, 1905 deletions
diff --git a/src/java/com/sun/gluegen/runtime/BufferFactory.java.javame_cdc_fp b/src/java/com/sun/gluegen/runtime/BufferFactory.java.javame_cdc_fp
deleted file mode 100755
index 622cc37..0000000
--- a/src/java/com/sun/gluegen/runtime/BufferFactory.java.javame_cdc_fp
+++ /dev/null
@@ -1,230 +0,0 @@
-/*
- * 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.
- *
- * Sun gratefully acknowledges that this software was originally authored
- * and developed by Kenneth Bradley Russell and Christopher John Kline.
- */
-
-package com.sun.gluegen.runtime;
-
-import java.nio.*;
-
-public class BufferFactory {
- public static final int SIZEOF_BYTE = 1;
- public static final int SIZEOF_SHORT = 2;
- public static final int SIZEOF_INT = 4;
- public static final int SIZEOF_FLOAT = 4;
-
- public static ByteBuffer newDirectByteBuffer(int size) {
- ByteBuffer buf = ByteBuffer.allocateDirect(size);
- return buf;
- }
-
- /** Helper routine to set a ByteBuffer to the native byte order, if
- that operation is supported by the underlying NIO
- implementation. */
- public static ByteBuffer nativeOrder(ByteBuffer buf) {
- return buf;
- }
-
- /** Helper routine to tell whether a buffer is direct or not. Null
- pointers are considered direct. isDirect() should really be
- public in Buffer and not replicated in all subclasses. */
- public static boolean isDirect(Buffer buf) {
- if (buf == null) {
- return true;
- }
- if (buf instanceof ByteBuffer) {
- return ((ByteBuffer) buf).isDirect();
- } else if (buf instanceof FloatBuffer) {
- return ((FloatBuffer) buf).isDirect();
- } else if (buf instanceof ShortBuffer) {
- return ((ShortBuffer) buf).isDirect();
- } else if (buf instanceof IntBuffer) {
- return ((IntBuffer) buf).isDirect();
- }
- throw new RuntimeException("Unexpected buffer type " + buf.getClass().getName());
- }
-
-
- /** Helper routine to get the Buffer byte offset by taking into
- account the Buffer position and the underlying type. This is
- the total offset for Direct Buffers. */
-
- public static int getDirectBufferByteOffset(Buffer buf) {
- if(buf == null) {
- return 0;
- }
- if(buf instanceof ByteBuffer) {
- return (buf.position());
- } else if (buf instanceof FloatBuffer) {
- return (buf.position() * SIZEOF_FLOAT);
- } else if (buf instanceof IntBuffer) {
- return (buf.position() * SIZEOF_INT);
- } else if (buf instanceof ShortBuffer) {
- return (buf.position() * SIZEOF_SHORT);
- }
-
- throw new RuntimeException("Disallowed array backing store type in buffer "
- + buf.getClass().getName());
- }
-
-
- /** Helper routine to return the array backing store reference from
- a Buffer object. */
-
- public static Object getArray(Buffer buf) {
- if (buf == null) {
- return null;
- }
- if(buf instanceof ByteBuffer) {
- return ((ByteBuffer) buf).array();
- } else if (buf instanceof FloatBuffer) {
- return ((FloatBuffer) buf).array();
- } else if (buf instanceof IntBuffer) {
- return ((IntBuffer) buf).array();
- } else if (buf instanceof ShortBuffer) {
- return ((ShortBuffer) buf).array();
- }
-
- throw new RuntimeException("Disallowed array backing store type in buffer "
- + buf.getClass().getName());
- }
-
-
- /** Helper routine to get the full byte offset from the beginning of
- the array that is the storage for the indirect Buffer
- object. The array offset also includes the position offset
- within the buffer, in addition to any array offset. */
-
- public static int getIndirectBufferByteOffset(Buffer buf) {
- if(buf == null) {
- return 0;
- }
- int pos = buf.position();
- if(buf instanceof ByteBuffer) {
- return (((ByteBuffer)buf).arrayOffset() + pos);
- } else if(buf instanceof FloatBuffer) {
- return (SIZEOF_FLOAT*(((FloatBuffer)buf).arrayOffset() + pos));
- } else if(buf instanceof IntBuffer) {
- return (SIZEOF_INT*(((IntBuffer)buf).arrayOffset() + pos));
- } else if(buf instanceof ShortBuffer) {
- return (SIZEOF_SHORT*(((ShortBuffer)buf).arrayOffset() + pos));
- }
-
- throw new RuntimeException("Unknown buffer type " + buf.getClass().getName());
- }
-
- public static void rangeCheck(byte[] array, int offset, int minElementsRemaining) {
- if (array == null) {
- return;
- }
-
- if (array.length < offset + minElementsRemaining) {
- throw new ArrayIndexOutOfBoundsException("Required " + minElementsRemaining + " elements in array, only had " + (array.length - offset));
- }
- }
-
- public static void rangeCheck(char[] array, int offset, int minElementsRemaining) {
- if (array == null) {
- return;
- }
-
- if (array.length < offset + minElementsRemaining) {
- throw new ArrayIndexOutOfBoundsException("Required " + minElementsRemaining + " elements in array, only had " + (array.length - offset));
- }
- }
-
- public static void rangeCheck(short[] array, int offset, int minElementsRemaining) {
- if (array == null) {
- return;
- }
-
- if (array.length < offset + minElementsRemaining) {
- throw new ArrayIndexOutOfBoundsException("Required " + minElementsRemaining + " elements in array, only had " + (array.length - offset));
- }
- }
-
- public static void rangeCheck(int[] array, int offset, int minElementsRemaining) {
- if (array == null) {
- return;
- }
-
- if (array.length < offset + minElementsRemaining) {
- throw new ArrayIndexOutOfBoundsException("Required " + minElementsRemaining + " elements in array, only had " + (array.length - offset));
- }
- }
-
- public static void rangeCheck(float[] array, int offset, int minElementsRemaining) {
- if (array == null) {
- return;
- }
-
- if (array.length < offset + minElementsRemaining) {
- throw new ArrayIndexOutOfBoundsException("Required " + minElementsRemaining + " elements in array, only had " + (array.length - offset));
- }
- }
-
- public static void rangeCheck(Buffer buffer, int minElementsRemaining) {
- if (buffer == null) {
- return;
- }
-
- if (buffer.remaining() < minElementsRemaining) {
- throw new IndexOutOfBoundsException("Required " + minElementsRemaining + " remaining elements in buffer, only had " + buffer.remaining());
- }
- }
-
- public static void rangeCheckBytes(Buffer buffer, int minBytesRemaining) {
- if (buffer == null) {
- return;
- }
-
- int elementsRemaining = buffer.remaining();
- int bytesRemaining = 0;
- if (buffer instanceof ByteBuffer) {
- bytesRemaining = elementsRemaining;
- } else if (buffer instanceof FloatBuffer) {
- bytesRemaining = elementsRemaining * SIZEOF_FLOAT;
- } else if (buffer instanceof IntBuffer) {
- bytesRemaining = elementsRemaining * SIZEOF_INT;
- } else if (buffer instanceof ShortBuffer) {
- bytesRemaining = elementsRemaining * SIZEOF_SHORT;
- }
- if (bytesRemaining < minBytesRemaining) {
- throw new IndexOutOfBoundsException("Required " + minBytesRemaining + " remaining bytes in buffer, only had " + bytesRemaining);
- }
- }
-}
diff --git a/src/java/com/sun/gluegen/runtime/BufferFactory.java.javase b/src/java/com/sun/gluegen/runtime/BufferFactory.java.javase
deleted file mode 100755
index a883316..0000000
--- a/src/java/com/sun/gluegen/runtime/BufferFactory.java.javase
+++ /dev/null
@@ -1,284 +0,0 @@
-/*
- * 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.
- *
- * Sun gratefully acknowledges that this software was originally authored
- * and developed by Kenneth Bradley Russell and Christopher John Kline.
- */
-
-package com.sun.gluegen.runtime;
-
-import java.nio.*;
-
-public class BufferFactory {
- public static final int SIZEOF_BYTE = 1;
- public static final int SIZEOF_SHORT = 2;
- public static final int SIZEOF_CHAR = 2;
- public static final int SIZEOF_INT = 4;
- public static final int SIZEOF_FLOAT = 4;
- public static final int SIZEOF_LONG = 8;
- public static final int SIZEOF_DOUBLE = 8;
-
- public static ByteBuffer newDirectByteBuffer(int size) {
- ByteBuffer buf = ByteBuffer.allocateDirect(size);
- buf.order(ByteOrder.nativeOrder());
- return buf;
- }
-
- /** Helper routine to set a ByteBuffer to the native byte order, if
- that operation is supported by the underlying NIO
- implementation. */
- public static ByteBuffer nativeOrder(ByteBuffer buf) {
- return buf.order(ByteOrder.nativeOrder());
- }
-
- /** Helper routine to tell whether a buffer is direct or not. Null
- pointers are considered direct. isDirect() should really be
- public in Buffer and not replicated in all subclasses. */
- public static boolean isDirect(Buffer buf) {
- if (buf == null) {
- return true;
- }
- if (buf instanceof ByteBuffer) {
- return ((ByteBuffer) buf).isDirect();
- } else if (buf instanceof FloatBuffer) {
- return ((FloatBuffer) buf).isDirect();
- } else if (buf instanceof DoubleBuffer) {
- return ((DoubleBuffer) buf).isDirect();
- } else if (buf instanceof CharBuffer) {
- return ((CharBuffer) buf).isDirect();
- } else if (buf instanceof ShortBuffer) {
- return ((ShortBuffer) buf).isDirect();
- } else if (buf instanceof IntBuffer) {
- return ((IntBuffer) buf).isDirect();
- } else if (buf instanceof LongBuffer) {
- return ((LongBuffer) buf).isDirect();
- }
- throw new RuntimeException("Unexpected buffer type " + buf.getClass().getName());
- }
-
-
- /** Helper routine to get the Buffer byte offset by taking into
- account the Buffer position and the underlying type. This is
- the total offset for Direct Buffers. */
-
- public static int getDirectBufferByteOffset(Buffer buf) {
- if(buf == null) {
- return 0;
- }
- if(buf instanceof ByteBuffer) {
- return (buf.position());
- } else if (buf instanceof FloatBuffer) {
- return (buf.position() * SIZEOF_FLOAT);
- } else if (buf instanceof IntBuffer) {
- return (buf.position() * SIZEOF_INT);
- } else if (buf instanceof ShortBuffer) {
- return (buf.position() * SIZEOF_SHORT);
- } else if (buf instanceof DoubleBuffer) {
- return (buf.position() * SIZEOF_DOUBLE);
- } else if (buf instanceof LongBuffer) {
- return (buf.position() * SIZEOF_LONG);
- } else if (buf instanceof CharBuffer) {
- return (buf.position() * SIZEOF_CHAR);
- }
-
- throw new RuntimeException("Disallowed array backing store type in buffer "
- + buf.getClass().getName());
- }
-
-
- /** Helper routine to return the array backing store reference from
- a Buffer object. */
-
- public static Object getArray(Buffer buf) {
- if (buf == null) {
- return null;
- }
- if(buf instanceof ByteBuffer) {
- return ((ByteBuffer) buf).array();
- } else if (buf instanceof FloatBuffer) {
- return ((FloatBuffer) buf).array();
- } else if (buf instanceof IntBuffer) {
- return ((IntBuffer) buf).array();
- } else if (buf instanceof ShortBuffer) {
- return ((ShortBuffer) buf).array();
- } else if (buf instanceof DoubleBuffer) {
- return ((DoubleBuffer) buf).array();
- } else if (buf instanceof LongBuffer) {
- return ((LongBuffer) buf).array();
- } else if (buf instanceof CharBuffer) {
- return ((CharBuffer) buf).array();
- }
-
- throw new RuntimeException("Disallowed array backing store type in buffer "
- + buf.getClass().getName());
- }
-
-
- /** Helper routine to get the full byte offset from the beginning of
- the array that is the storage for the indirect Buffer
- object. The array offset also includes the position offset
- within the buffer, in addition to any array offset. */
-
- public static int getIndirectBufferByteOffset(Buffer buf) {
- if(buf == null) {
- return 0;
- }
- int pos = buf.position();
- if(buf instanceof ByteBuffer) {
- return (((ByteBuffer)buf).arrayOffset() + pos);
- } else if(buf instanceof FloatBuffer) {
- return (SIZEOF_FLOAT*(((FloatBuffer)buf).arrayOffset() + pos));
- } else if(buf instanceof IntBuffer) {
- return (SIZEOF_INT*(((IntBuffer)buf).arrayOffset() + pos));
- } else if(buf instanceof ShortBuffer) {
- return (SIZEOF_SHORT*(((ShortBuffer)buf).arrayOffset() + pos));
- } else if(buf instanceof DoubleBuffer) {
- return (SIZEOF_DOUBLE*(((DoubleBuffer)buf).arrayOffset() + pos));
- } else if(buf instanceof LongBuffer) {
- return (SIZEOF_LONG*(((LongBuffer)buf).arrayOffset() + pos));
- } else if(buf instanceof CharBuffer) {
- return (SIZEOF_CHAR*(((CharBuffer)buf).arrayOffset() + pos));
- }
-
- throw new RuntimeException("Unknown buffer type " + buf.getClass().getName());
- }
-
- public static void rangeCheck(byte[] array, int offset, int minElementsRemaining) {
- if (array == null) {
- return;
- }
-
- if (array.length < offset + minElementsRemaining) {
- throw new ArrayIndexOutOfBoundsException("Required " + minElementsRemaining + " elements in array, only had " + (array.length - offset));
- }
- }
-
- public static void rangeCheck(char[] array, int offset, int minElementsRemaining) {
- if (array == null) {
- return;
- }
-
- if (array.length < offset + minElementsRemaining) {
- throw new ArrayIndexOutOfBoundsException("Required " + minElementsRemaining + " elements in array, only had " + (array.length - offset));
- }
- }
-
- public static void rangeCheck(short[] array, int offset, int minElementsRemaining) {
- if (array == null) {
- return;
- }
-
- if (array.length < offset + minElementsRemaining) {
- throw new ArrayIndexOutOfBoundsException("Required " + minElementsRemaining + " elements in array, only had " + (array.length - offset));
- }
- }
-
- public static void rangeCheck(int[] array, int offset, int minElementsRemaining) {
- if (array == null) {
- return;
- }
-
- if (array.length < offset + minElementsRemaining) {
- throw new ArrayIndexOutOfBoundsException("Required " + minElementsRemaining + " elements in array, only had " + (array.length - offset));
- }
- }
-
- public static void rangeCheck(long[] array, int offset, int minElementsRemaining) {
- if (array == null) {
- return;
- }
-
- if (array.length < offset + minElementsRemaining) {
- throw new ArrayIndexOutOfBoundsException("Required " + minElementsRemaining + " elements in array, only had " + (array.length - offset));
- }
- }
-
- public static void rangeCheck(float[] array, int offset, int minElementsRemaining) {
- if (array == null) {
- return;
- }
-
- if (array.length < offset + minElementsRemaining) {
- throw new ArrayIndexOutOfBoundsException("Required " + minElementsRemaining + " elements in array, only had " + (array.length - offset));
- }
- }
-
- public static void rangeCheck(double[] array, int offset, int minElementsRemaining) {
- if (array == null) {
- return;
- }
-
- if (array.length < offset + minElementsRemaining) {
- throw new ArrayIndexOutOfBoundsException("Required " + minElementsRemaining + " elements in array, only had " + (array.length - offset));
- }
- }
-
- public static void rangeCheck(Buffer buffer, int minElementsRemaining) {
- if (buffer == null) {
- return;
- }
-
- if (buffer.remaining() < minElementsRemaining) {
- throw new IndexOutOfBoundsException("Required " + minElementsRemaining + " remaining elements in buffer, only had " + buffer.remaining());
- }
- }
-
- public static void rangeCheckBytes(Buffer buffer, int minBytesRemaining) {
- if (buffer == null) {
- return;
- }
-
- int elementsRemaining = buffer.remaining();
- int bytesRemaining = 0;
- if (buffer instanceof ByteBuffer) {
- bytesRemaining = elementsRemaining;
- } else if (buffer instanceof FloatBuffer) {
- bytesRemaining = elementsRemaining * SIZEOF_FLOAT;
- } else if (buffer instanceof IntBuffer) {
- bytesRemaining = elementsRemaining * SIZEOF_INT;
- } else if (buffer instanceof ShortBuffer) {
- bytesRemaining = elementsRemaining * SIZEOF_SHORT;
- } else if (buffer instanceof DoubleBuffer) {
- bytesRemaining = elementsRemaining * SIZEOF_DOUBLE;
- } else if (buffer instanceof LongBuffer) {
- bytesRemaining = elementsRemaining * SIZEOF_LONG;
- } else if (buffer instanceof CharBuffer) {
- bytesRemaining = elementsRemaining * SIZEOF_CHAR;
- }
- if (bytesRemaining < minBytesRemaining) {
- throw new IndexOutOfBoundsException("Required " + minBytesRemaining + " remaining bytes in buffer, only had " + bytesRemaining);
- }
- }
-}
diff --git a/src/java/com/sun/gluegen/runtime/BufferFactoryInternal.java b/src/java/com/sun/gluegen/runtime/BufferFactoryInternal.java
deleted file mode 100755
index 7a0e6a8..0000000
--- a/src/java/com/sun/gluegen/runtime/BufferFactoryInternal.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
-
- * Copyright (c) 2006 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.sun.gluegen.runtime;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Field;
-import java.nio.*;
-import sun.misc.Unsafe;
-
-public class BufferFactoryInternal {
- private static final long addressFieldOffset;
- private static final Constructor directByteBufferConstructor;
-
- static {
- try {
- Field f = Buffer.class.getDeclaredField("address");
- addressFieldOffset = UnsafeAccess.getUnsafe().objectFieldOffset(f);
-
- Class directByteBufferClass = Class.forName("java.nio.DirectByteBuffer");
- directByteBufferConstructor = directByteBufferClass.getDeclaredConstructor(new Class[] { Long.TYPE, Integer.TYPE });
- directByteBufferConstructor.setAccessible(true);
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
- public static long getDirectBufferAddress(Buffer buf) {
- return ((buf == null) ? 0 : UnsafeAccess.getUnsafe().getLong(buf, addressFieldOffset));
- }
-
- public static ByteBuffer newDirectByteBuffer(long address, int capacity) {
- try {
- if (address == 0) {
- return null;
- }
- return (ByteBuffer) directByteBufferConstructor.newInstance(new Object[] { new Long(address), new Integer(capacity) });
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
- public static long newCString(String str) {
- byte[] strBytes = str.getBytes();
- long strBlock = UnsafeAccess.getUnsafe().allocateMemory(strBytes.length+1);
- for (int i = 0; i < strBytes.length; i++) {
- UnsafeAccess.getUnsafe().putByte(strBlock+i, strBytes[i]);
- }
- UnsafeAccess.getUnsafe().putByte(strBlock+strBytes.length, (byte)0); // null termination
- return strBlock;
- }
-
- public static void freeCString(long cStr) {
- UnsafeAccess.getUnsafe().freeMemory(cStr);
- }
-
- public static String newJavaString(long cStr) {
- if (cStr == 0) {
- return null;
- }
- int numChars = 0;
- while (UnsafeAccess.getUnsafe().getByte(cStr + numChars) != 0) {
- ++numChars;
- }
- byte[] bytes = new byte[numChars];
- for (int i = 0; i < numChars; i++) {
- bytes[i] = UnsafeAccess.getUnsafe().getByte(cStr + i);
- }
- return new String(bytes);
- }
-
- public static int arrayBaseOffset(Object array) {
- return UnsafeAccess.getUnsafe().arrayBaseOffset(array.getClass());
- }
- public static int arrayIndexScale(Object array) {
- return UnsafeAccess.getUnsafe().arrayIndexScale(array.getClass());
- }
-}
diff --git a/src/java/com/sun/gluegen/runtime/CPU.java b/src/java/com/sun/gluegen/runtime/CPU.java
deleted file mode 100755
index e3a215f..0000000
--- a/src/java/com/sun/gluegen/runtime/CPU.java
+++ /dev/null
@@ -1,82 +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.sun.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 static boolean is32Bit;
-
- static {
- // 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 = System.getProperty("os.name").toLowerCase();
- String cpu = System.getProperty("os.arch").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("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("sunos") && cpu.equals("sparcv9")) ||
- (os.startsWith("sunos") && cpu.equals("amd64"))) {
- } else {
- throw new RuntimeException("Please port CPU detection (32/64 bit) to your platform (" + os + "/" + cpu + ")");
- }
- }
-
- public static boolean is32Bit() {
- return is32Bit;
- }
-}
diff --git a/src/java/com/sun/gluegen/runtime/DynamicLinker.java b/src/java/com/sun/gluegen/runtime/DynamicLinker.java
deleted file mode 100755
index d0ee39b..0000000
--- a/src/java/com/sun/gluegen/runtime/DynamicLinker.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 2006 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.sun.gluegen.runtime;
-
-/** Provides an abstract interface to the OS's low-level dynamic
- linking functionality. */
-
-interface DynamicLinker {
- public long openLibrary(String pathname);
- public long lookupSymbol(long libraryHandle, String symbolName);
- public void closeLibrary(long libraryHandle);
-}
diff --git a/src/java/com/sun/gluegen/runtime/DynamicLookupHelper.java b/src/java/com/sun/gluegen/runtime/DynamicLookupHelper.java
deleted file mode 100755
index 07417f9..0000000
--- a/src/java/com/sun/gluegen/runtime/DynamicLookupHelper.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (c) 2003-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.sun.gluegen.runtime;
-
-/** Interface callers may use to use the ProcAddressHelper's {@link
- ProcAddressHelper#resetProcAddressTable resetProcAddressTable}
- helper method to install function pointers into a
- ProcAddressTable. This must typically be written with native
- code. */
-
-public interface DynamicLookupHelper {
- public long dynamicLookupFunction(String funcName);
-}
diff --git a/src/java/com/sun/gluegen/runtime/MacOSXDynamicLinkerImpl.java b/src/java/com/sun/gluegen/runtime/MacOSXDynamicLinkerImpl.java
deleted file mode 100755
index f998d07..0000000
--- a/src/java/com/sun/gluegen/runtime/MacOSXDynamicLinkerImpl.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/* !---- DO NOT EDIT: This file autogenerated by com\sun\gluegen\JavaEmitter.java on Mon Jul 31 16:27:00 PDT 2006 ----! */
-
-package com.sun.gluegen.runtime;
-
-import com.sun.gluegen.runtime.*;
-
-public class MacOSXDynamicLinkerImpl implements DynamicLinker
-{
-
- public static final int RTLD_LAZY = 0x1;
- public static final int RTLD_NOW = 0x2;
- public static final int RTLD_LOCAL = 0x4;
- public static final int RTLD_GLOBAL = 0x8;
-
- /** Interface to C language function: <br> <code> int dlclose(void * __handle); </code> */
- private static native int dlclose(long __handle);
-
- /** Interface to C language function: <br> <code> char * dlerror(void); </code> */
- private static native java.lang.String dlerror();
-
- /** Interface to C language function: <br> <code> void * dlopen(const char * __path, int __mode); </code> */
- private static native long dlopen(java.lang.String __path, int __mode);
-
- /** Interface to C language function: <br> <code> void * dlsym(void * __handle, const char * __symbol); </code> */
- private static native long dlsym(long __handle, java.lang.String __symbol);
-
-
- // --- Begin CustomJavaCode .cfg declarations
- public long openLibrary(String pathname) {
- // Note we use RTLD_GLOBAL visibility to allow this functionality to
- // be used to pre-resolve dependent libraries of JNI code without
- // requiring that all references to symbols in those libraries be
- // looked up dynamically via the ProcAddressTable mechanism; in
- // other words, one can actually link against the library instead of
- // having to dlsym all entry points. System.loadLibrary() uses
- // RTLD_LOCAL visibility so can't be used for this purpose.
- return dlopen(pathname, RTLD_LAZY | RTLD_GLOBAL);
- }
-
- public long lookupSymbol(long libraryHandle, String symbolName) {
- return dlsym(libraryHandle, symbolName);
- }
-
- public void closeLibrary(long libraryHandle) {
- dlclose(libraryHandle);
- }
- // ---- End CustomJavaCode .cfg declarations
-
-} // end of class MacOSXDynamicLinkerImpl
diff --git a/src/java/com/sun/gluegen/runtime/NativeLibLoader.java b/src/java/com/sun/gluegen/runtime/NativeLibLoader.java
deleted file mode 100755
index 0e6e3da..0000000
--- a/src/java/com/sun/gluegen/runtime/NativeLibLoader.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Copyright (c) 2006 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.sun.gluegen.runtime;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.security.*;
-
-/** Class providing control over whether GlueGen loads the native code
- associated with the NativeLibrary implementation. Alternative app
- launchers such as those running within applets may want to disable
- this default loading behavior and load the native code via another
- (manual) mechanism. */
-public class NativeLibLoader {
- private static volatile boolean loadingEnabled = true;
- private static volatile boolean didLoading;
-
- public static void disableLoading() {
- loadingEnabled = false;
- }
-
- public static void enableLoading() {
- loadingEnabled = true;
- }
-
- public static void loadGlueGenRT() {
- if (!didLoading && loadingEnabled) {
- synchronized (NativeLibLoader.class) {
- if (!didLoading && loadingEnabled) {
- didLoading = true;
- AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- loadLibraryInternal("gluegen-rt");
- return null;
- }
- });
- }
- }
- }
- }
-
- private static void loadLibraryInternal(String libraryName) {
- String sunAppletLauncher = System.getProperty("sun.jnlp.applet.launcher");
- boolean usingJNLPAppletLauncher = Boolean.valueOf(sunAppletLauncher).booleanValue();
-
- if (usingJNLPAppletLauncher) {
- try {
- Class jnlpAppletLauncherClass = Class.forName("org.jdesktop.applet.util.JNLPAppletLauncher");
- Method jnlpLoadLibraryMethod = jnlpAppletLauncherClass.getDeclaredMethod("loadLibrary", new Class[] { String.class });
- jnlpLoadLibraryMethod.invoke(null, new Object[] { libraryName });
- } catch (Exception e) {
- Throwable t = e;
- if (t instanceof InvocationTargetException) {
- t = ((InvocationTargetException) t).getTargetException();
- }
- if (t instanceof Error)
- throw (Error) t;
- if (t instanceof RuntimeException) {
- throw (RuntimeException) t;
- }
- // Throw UnsatisfiedLinkError for best compatibility with System.loadLibrary()
- throw (UnsatisfiedLinkError) new UnsatisfiedLinkError().initCause(e);
- }
- } else {
- System.loadLibrary(libraryName);
- }
- }
-}
diff --git a/src/java/com/sun/gluegen/runtime/NativeLibrary.java b/src/java/com/sun/gluegen/runtime/NativeLibrary.java
deleted file mode 100755
index 1341012..0000000
--- a/src/java/com/sun/gluegen/runtime/NativeLibrary.java
+++ /dev/null
@@ -1,404 +0,0 @@
-/*
- * Copyright (c) 2006 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.sun.gluegen.runtime;
-
-import java.io.*;
-import java.lang.reflect.*;
-import java.security.*;
-import java.util.*;
-
-/** Provides low-level, relatively platform-independent access to
- shared ("native") libraries. The core library routines
- <code>System.load()</code> and <code>System.loadLibrary()</code>
- in general provide suitable functionality for applications using
- native code, but are not flexible enough to support certain kinds
- of glue code generation and deployment strategies. This class
- supports direct linking of native libraries to other shared
- objects not necessarily installed on the system (in particular,
- via the use of dlopen(RTLD_GLOBAL) on Unix platforms) as well as
- manual lookup of function names to support e.g. GlueGen's
- ProcAddressTable glue code generation style without additional
- supporting code needed in the generated library. */
-
-public class NativeLibrary {
- private static final int WINDOWS = 1;
- private static final int UNIX = 2;
- private static final int MACOSX = 3;
- private static boolean DEBUG;
- private static int platform;
- private static DynamicLinker dynLink;
- private static String[] prefixes;
- private static String[] suffixes;
-
- static {
- // Determine platform we're running on
- AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- String osName = System.getProperty("os.name").toLowerCase();
- if (osName.startsWith("wind")) {
- platform = WINDOWS;
- } else if (osName.startsWith("mac os x")) {
- platform = MACOSX;
- } else {
- platform = UNIX;
- }
-
- DEBUG = (System.getProperty("gluegen.debug.NativeLibrary") != null);
-
- return null;
- }
- });
- // Instantiate dynamic linker implementation
- switch (platform) {
- case WINDOWS:
- dynLink = new WindowsDynamicLinkerImpl();
- prefixes = new String[] { "" };
- suffixes = new String[] { ".dll" };
- break;
- case UNIX:
- dynLink = new UnixDynamicLinkerImpl();
- prefixes = new String[] { "lib" };
- suffixes = new String[] { ".so" };
- break;
- case MACOSX:
- dynLink = new MacOSXDynamicLinkerImpl();
- prefixes = new String[] { "lib", "" };
- suffixes = new String[] { ".dylib", ".jnilib", "" };
- break;
- default:
- throw new InternalError("Platform not initialized properly");
- }
- }
-
- // Platform-specific representation for the handle to the open
- // library. This is an HMODULE on Windows and a void* (the result of
- // a dlopen() call) on Unix and Mac OS X platforms.
- private long libraryHandle;
-
- // May as well keep around the path to the library we opened
- private String libraryPath;
-
- // Private constructor to prevent arbitrary instances from floating around
- private NativeLibrary(long libraryHandle, String libraryPath) {
- this.libraryHandle = libraryHandle;
- this.libraryPath = libraryPath;
- }
-
- /** Opens the given native library, assuming it has the same base
- name on all platforms, looking first in the system's search
- path, and in the context of the specified ClassLoader, which is
- used to help find the library in the case of e.g. Java Web Start. */
- public static NativeLibrary open(String libName, ClassLoader loader) {
- return open(libName, libName, libName, true, loader);
- }
-
- /** Opens the given native library, assuming it has the given base
- names (no "lib" prefix or ".dll/.so/.dylib" suffix) on the
- Windows, Unix and Mac OS X platforms, respectively, and in the
- context of the specified ClassLoader, which is used to help find
- the library in the case of e.g. Java Web Start. The
- searchSystemPathFirst argument changes the behavior to first
- search the default system path rather than searching it last.
- Note that we do not currently handle DSO versioning on Unix.
- Experience with JOAL and OpenAL has shown that it is extremely
- problematic to rely on a specific .so version (for one thing,
- ClassLoader.findLibrary on Unix doesn't work with files not
- ending in .so, for example .so.0), and in general if this
- dynamic loading facility is used correctly the version number
- will be irrelevant.
- */
- public static NativeLibrary open(String windowsLibName,
- String unixLibName,
- String macOSXLibName,
- boolean searchSystemPathFirst,
- ClassLoader loader) {
- List possiblePaths = enumerateLibraryPaths(windowsLibName,
- unixLibName,
- macOSXLibName,
- searchSystemPathFirst,
- loader);
- // Iterate down these and see which one if any we can actually find.
- for (Iterator iter = possiblePaths.iterator(); iter.hasNext(); ) {
- String path = (String) iter.next();
- if (DEBUG) {
- System.out.println("Trying to load " + path);
- }
- ensureNativeLibLoaded();
- long res = dynLink.openLibrary(path);
- if (res != 0) {
- if (DEBUG) {
- System.out.println("Successfully loaded " + path + ": res = 0x" + Long.toHexString(res));
- }
- return new NativeLibrary(res, path);
- }
- }
-
- if (DEBUG) {
- System.out.println("Did not succeed in loading (" + windowsLibName + ", " + unixLibName + ", " + macOSXLibName + ")");
- }
-
- // For now, just return null to indicate the open operation didn't
- // succeed (could also throw an exception if we could tell which
- // of the openLibrary operations actually failed)
- return null;
- }
-
- /** Looks up the given function name in this native library. */
- public long lookupFunction(String functionName) {
- if (libraryHandle == 0)
- throw new RuntimeException("Library is not open");
- return dynLink.lookupSymbol(libraryHandle, functionName);
- }
-
- /** Retrieves the low-level library handle from this NativeLibrary
- object. On the Windows platform this is an HMODULE, and on Unix
- and Mac OS X platforms the void* result of calling dlopen(). */
- public long getLibraryHandle() {
- return libraryHandle;
- }
-
- /** Retrieves the path under which this library was opened. */
- public String getLibraryPath() {
- return libraryPath;
- }
-
- /** Closes this native library. Further lookup operations are not
- allowed after calling this method. */
- public void close() {
- if (libraryHandle == 0)
- throw new RuntimeException("Library already closed");
- long handle = libraryHandle;
- libraryHandle = 0;
- dynLink.closeLibrary(handle);
- }
-
- /** Given the base library names (no prefixes/suffixes) for the
- various platforms, enumerate the possible locations and names of
- the indicated native library on the system. */
- private static List enumerateLibraryPaths(String windowsLibName,
- String unixLibName,
- String macOSXLibName,
- boolean searchSystemPathFirst,
- ClassLoader loader) {
- List paths = new ArrayList();
- String libName = selectName(windowsLibName, unixLibName, macOSXLibName);
- if (libName == null)
- return paths;
-
- // Allow user's full path specification to override our building of paths
- File file = new File(libName);
- if (file.isAbsolute()) {
- paths.add(libName);
- return paths;
- }
-
- String[] baseNames = buildNames(libName);
-
- if (searchSystemPathFirst) {
- // Add just the library names to use the OS's search algorithm
- for (int i = 0; i < baseNames.length; i++) {
- paths.add(baseNames[i]);
- }
- }
-
- // The idea to ask the ClassLoader to find the library is borrowed
- // from the LWJGL library
- String clPath = getPathFromClassLoader(libName, loader);
- if (DEBUG) {
- System.out.println("Class loader path to " + libName + ": " + clPath);
- }
- if (clPath != null) {
- paths.add(clPath);
- }
-
- // Add entries from java.library.path
- String javaLibraryPath =
- (String) AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- return System.getProperty("java.library.path");
- }
- });
- if (javaLibraryPath != null) {
- StringTokenizer tokenizer = new StringTokenizer(javaLibraryPath, File.pathSeparator);
- while (tokenizer.hasMoreTokens()) {
- addPaths(tokenizer.nextToken(), baseNames, paths);
- }
- }
-
- // Add current working directory
- String userDir =
- (String) AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- return System.getProperty("user.dir");
- }
- });
- addPaths(userDir, baseNames, paths);
-
- // Add probable Mac OS X-specific paths
- if (platform == MACOSX) {
- // Add historical location
- addPaths("/Library/Frameworks/" + libName + ".Framework", baseNames, paths);
- // Add current location
- addPaths("/System/Library/Frameworks/" + libName + ".Framework", baseNames, paths);
- }
-
- if (!searchSystemPathFirst) {
- // Add just the library names to use the OS's search algorithm
- for (int i = 0; i < baseNames.length; i++) {
- paths.add(baseNames[i]);
- }
- }
-
- return paths;
- }
-
-
- private static String selectName(String windowsLibName,
- String unixLibName,
- String macOSXLibName) {
- switch (platform) {
- case WINDOWS:
- return windowsLibName;
- case UNIX:
- return unixLibName;
- case MACOSX:
- return macOSXLibName;
- default:
- throw new InternalError();
- }
- }
-
- private static String[] buildNames(String libName) {
- // If the library name already has the prefix / suffix added
- // (principally because we want to force a version number on Unix
- // operating systems) then just return the library name.
- if (libName.startsWith(prefixes[0])) {
- if (libName.endsWith(suffixes[0])) {
- return new String[] { libName };
- }
-
- int idx = libName.indexOf(suffixes[0]);
- boolean ok = true;
- if (idx >= 0) {
- // Check to see if everything after it is a Unix version number
- for (int i = idx + suffixes[0].length();
- i < libName.length();
- i++) {
- char c = libName.charAt(i);
- if (!(c == '.' || (c >= '0' && c <= '9'))) {
- ok = false;
- break;
- }
- }
- if (ok) {
- return new String[] { libName };
- }
- }
- }
-
- String[] res = new String[prefixes.length * suffixes.length];
- int idx = 0;
- for (int i = 0; i < prefixes.length; i++) {
- for (int j = 0; j < suffixes.length; j++) {
- res[idx++] = prefixes[i] + libName + suffixes[j];
- }
- }
- return res;
- }
-
- private static void addPaths(String path, String[] baseNames, List paths) {
- for (int j = 0; j < baseNames.length; j++) {
- paths.add(path + File.separator + baseNames[j]);
- }
- }
-
- private static boolean initializedFindLibraryMethod = false;
- private static Method findLibraryMethod = null;
- private static String getPathFromClassLoader(final String libName, final ClassLoader loader) {
- if (loader == null)
- return null;
- if (!initializedFindLibraryMethod) {
- AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- try {
- findLibraryMethod = ClassLoader.class.getDeclaredMethod("findLibrary",
- new Class[] { String.class });
- findLibraryMethod.setAccessible(true);
- } catch (Exception e) {
- // Fail silently disabling this functionality
- }
- initializedFindLibraryMethod = true;
- return null;
- }
- });
- }
- if (findLibraryMethod != null) {
- try {
- return (String) AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- try {
- return findLibraryMethod.invoke(loader, new Object[] { libName });
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
- });
- } catch (Exception e) {
- if (DEBUG) {
- e.printStackTrace();
- }
- // Fail silently and continue with other search algorithms
- }
- }
- return null;
- }
-
- private static volatile boolean loadedDynLinkNativeLib;
- private static void ensureNativeLibLoaded() {
- if (!loadedDynLinkNativeLib) {
- synchronized (NativeLibrary.class) {
- if (!loadedDynLinkNativeLib) {
- loadedDynLinkNativeLib = true;
- NativeLibLoader.loadGlueGenRT();
- }
- }
- }
- }
-}
diff --git a/src/java/com/sun/gluegen/runtime/ProcAddressHelper.java b/src/java/com/sun/gluegen/runtime/ProcAddressHelper.java
deleted file mode 100644
index 5c3c034..0000000
--- a/src/java/com/sun/gluegen/runtime/ProcAddressHelper.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Copyright (c) 2003-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.sun.gluegen.runtime;
-
-import java.security.*;
-
-// Debugging only
-import java.io.*;
-
-/** Helper class containing constants and methods to assist with the
- manipulation of auto-generated ProcAddressTables. */
-
-public class ProcAddressHelper {
- public static final String PROCADDRESS_VAR_PREFIX = "_addressof_";
- private static boolean DEBUG;
- private static String DEBUG_PREFIX;
- private static int debugNum;
-
- static {
- AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- DEBUG = (System.getProperty("gluegen.debug.ProcAddressHelper") != null);
- if (DEBUG) {
- DEBUG_PREFIX = System.getProperty("gluegen.debug.ProcAddressHelper.prefix");
- }
- return null;
- }
- });
- }
-
- public static void resetProcAddressTable(Object table,
- DynamicLookupHelper lookup) throws RuntimeException {
- Class tableClass = table.getClass();
- java.lang.reflect.Field[] fields = tableClass.getFields();
- PrintStream out = null;
-
- if (DEBUG) {
- if (DEBUG_PREFIX != null) {
- try {
- out = new PrintStream(new BufferedOutputStream(new FileOutputStream(DEBUG_PREFIX + File.separatorChar +
- "procaddresshelper-" + (++debugNum) + ".txt")));
- } catch (IOException e) {
- e.printStackTrace();
- out = System.err;
- }
- } else {
- out = System.err;
- }
- out.println("ProcAddressHelper.resetProcAddressTable(" + table.getClass().getName() + ")");
- }
- for (int i = 0; i < fields.length; ++i) {
- String addressFieldName = fields[i].getName();
- if (!addressFieldName.startsWith(ProcAddressHelper.PROCADDRESS_VAR_PREFIX)) {
- // not a proc address variable
- continue;
- }
- int startOfMethodName = ProcAddressHelper.PROCADDRESS_VAR_PREFIX.length();
- String funcName = addressFieldName.substring(startOfMethodName);
- try {
- java.lang.reflect.Field addressField = fields[i];
- assert(addressField.getType() == Long.TYPE);
- long newProcAddress = lookup.dynamicLookupFunction(funcName);
- // set the current value of the proc address variable in the table object
- addressField.setLong(table, newProcAddress);
- if (DEBUG) {
- out.println(" " + addressField.getName() + " = 0x" + Long.toHexString(newProcAddress));
- }
- } catch (Exception e) {
- throw new RuntimeException("Can not get proc address for method \"" +
- funcName + "\": Couldn't set value of field \"" + addressFieldName +
- "\" in class " + tableClass.getName(), e);
- }
- }
- if (DEBUG) {
- out.flush();
- if (DEBUG_PREFIX != null) {
- out.close();
- }
- }
- }
-}
diff --git a/src/java/com/sun/gluegen/runtime/StructAccessor.java.javame_cdc_fp b/src/java/com/sun/gluegen/runtime/StructAccessor.java.javame_cdc_fp
deleted file mode 100755
index 3e3f372..0000000
--- a/src/java/com/sun/gluegen/runtime/StructAccessor.java.javame_cdc_fp
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * 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.
- *
- * Sun gratefully acknowledges that this software was originally authored
- * and developed by Kenneth Bradley Russell and Christopher John Kline.
- */
-
-package com.sun.gluegen.runtime;
-
-import java.nio.*;
-
-public class StructAccessor {
- private ByteBuffer bb;
- private FloatBuffer fb;
- private IntBuffer ib;
- private ShortBuffer sb;
-
- public StructAccessor(ByteBuffer bb) {
- this.bb = bb;
- }
-
- public ByteBuffer getBuffer() {
- return bb;
- }
-
- /** Return a slice of the current ByteBuffer starting at the
- specified byte offset and extending the specified number of
- bytes. Note that this method is not thread-safe with respect to
- the other methods in this class. */
- public ByteBuffer slice(int byteOffset, int byteLength) {
- bb.position(byteOffset);
- bb.limit(byteOffset + byteLength);
- ByteBuffer newBuf = bb.slice();
- bb.position(0);
- bb.limit(bb.capacity());
- return newBuf;
- }
-
- /** Retrieves the byte at the specified slot (byte offset). */
- public byte getByteAt(int slot) {
- return bb.get(slot);
- }
-
- /** Puts a byte at the specified slot (byte offset). */
- public void setByteAt(int slot, byte v) {
- bb.put(slot, v);
- }
-
- /** Retrieves the float at the specified slot (4-byte offset). */
- public float getFloatAt(int slot) {
- return floatBuffer().get(slot);
- }
-
- /** Puts a float at the specified slot (4-byte offset). */
- public void setFloatAt(int slot, float v) {
- floatBuffer().put(slot, v);
- }
-
- /** Retrieves the int at the specified slot (4-byte offset). */
- public int getIntAt(int slot) {
- return intBuffer().get(slot);
- }
-
- /** Puts a int at the specified slot (4-byte offset). */
- public void setIntAt(int slot, int v) {
- intBuffer().put(slot, v);
- }
-
- /** Retrieves the short at the specified slot (2-byte offset). */
- public short getShortAt(int slot) {
- return shortBuffer().get(slot);
- }
-
- /** Puts a short at the specified slot (2-byte offset). */
- public void setShortAt(int slot, short v) {
- shortBuffer().put(slot, v);
- }
-
- //----------------------------------------------------------------------
- // Internals only below this point
- //
-
- private FloatBuffer floatBuffer() {
- if (fb == null) {
- fb = bb.asFloatBuffer();
- }
- return fb;
- }
-
- private IntBuffer intBuffer() {
- if (ib == null) {
- ib = bb.asIntBuffer();
- }
- return ib;
- }
-
- private ShortBuffer shortBuffer() {
- if (sb == null) {
- sb = bb.asShortBuffer();
- }
- return sb;
- }
-}
diff --git a/src/java/com/sun/gluegen/runtime/StructAccessor.java.javase b/src/java/com/sun/gluegen/runtime/StructAccessor.java.javase
deleted file mode 100755
index 5a0fa5d..0000000
--- a/src/java/com/sun/gluegen/runtime/StructAccessor.java.javase
+++ /dev/null
@@ -1,191 +0,0 @@
-/*
- * 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.
- *
- * Sun gratefully acknowledges that this software was originally authored
- * and developed by Kenneth Bradley Russell and Christopher John Kline.
- */
-
-package com.sun.gluegen.runtime;
-
-import java.nio.*;
-
-public class StructAccessor {
- private ByteBuffer bb;
- private CharBuffer cb;
- private DoubleBuffer db;
- private FloatBuffer fb;
- private IntBuffer ib;
- private LongBuffer lb;
- private ShortBuffer sb;
-
- public StructAccessor(ByteBuffer bb) {
- // Setting of byte order is concession to native code which needs
- // to instantiate these
- this.bb = bb.order(ByteOrder.nativeOrder());
- }
-
- public ByteBuffer getBuffer() {
- return bb;
- }
-
- /** Return a slice of the current ByteBuffer starting at the
- specified byte offset and extending the specified number of
- bytes. Note that this method is not thread-safe with respect to
- the other methods in this class. */
- public ByteBuffer slice(int byteOffset, int byteLength) {
- bb.position(byteOffset);
- bb.limit(byteOffset + byteLength);
- ByteBuffer newBuf = bb.slice();
- bb.position(0);
- bb.limit(bb.capacity());
- return newBuf;
- }
-
- /** Retrieves the byte at the specified slot (byte offset). */
- public byte getByteAt(int slot) {
- return bb.get(slot);
- }
-
- /** Puts a byte at the specified slot (byte offset). */
- public void setByteAt(int slot, byte v) {
- bb.put(slot, v);
- }
-
- /** Retrieves the char at the specified slot (2-byte offset). */
- public char getCharAt(int slot) {
- return charBuffer().get(slot);
- }
-
- /** Puts a char at the specified slot (2-byte offset). */
- public void setCharAt(int slot, char v) {
- charBuffer().put(slot, v);
- }
-
- /** Retrieves the double at the specified slot (8-byte offset). */
- public double getDoubleAt(int slot) {
- return doubleBuffer().get(slot);
- }
-
- /** Puts a double at the specified slot (8-byte offset). */
- public void setDoubleAt(int slot, double v) {
- doubleBuffer().put(slot, v);
- }
-
- /** Retrieves the float at the specified slot (4-byte offset). */
- public float getFloatAt(int slot) {
- return floatBuffer().get(slot);
- }
-
- /** Puts a float at the specified slot (4-byte offset). */
- public void setFloatAt(int slot, float v) {
- floatBuffer().put(slot, v);
- }
-
- /** Retrieves the int at the specified slot (4-byte offset). */
- public int getIntAt(int slot) {
- return intBuffer().get(slot);
- }
-
- /** Puts a int at the specified slot (4-byte offset). */
- public void setIntAt(int slot, int v) {
- intBuffer().put(slot, v);
- }
-
- /** Retrieves the long at the specified slot (8-byte offset). */
- public long getLongAt(int slot) {
- return longBuffer().get(slot);
- }
-
- /** Puts a long at the specified slot (8-byte offset). */
- public void setLongAt(int slot, long v) {
- longBuffer().put(slot, v);
- }
-
- /** Retrieves the short at the specified slot (2-byte offset). */
- public short getShortAt(int slot) {
- return shortBuffer().get(slot);
- }
-
- /** Puts a short at the specified slot (2-byte offset). */
- public void setShortAt(int slot, short v) {
- shortBuffer().put(slot, v);
- }
-
- //----------------------------------------------------------------------
- // Internals only below this point
- //
-
- private CharBuffer charBuffer() {
- if (cb == null) {
- cb = bb.asCharBuffer();
- }
- return cb;
- }
-
- private DoubleBuffer doubleBuffer() {
- if (db == null) {
- db = bb.asDoubleBuffer();
- }
- return db;
- }
-
- private FloatBuffer floatBuffer() {
- if (fb == null) {
- fb = bb.asFloatBuffer();
- }
- return fb;
- }
-
- private IntBuffer intBuffer() {
- if (ib == null) {
- ib = bb.asIntBuffer();
- }
- return ib;
- }
-
- private LongBuffer longBuffer() {
- if (lb == null) {
- lb = bb.asLongBuffer();
- }
- return lb;
- }
-
- private ShortBuffer shortBuffer() {
- if (sb == null) {
- sb = bb.asShortBuffer();
- }
- return sb;
- }
-}
diff --git a/src/java/com/sun/gluegen/runtime/UnixDynamicLinkerImpl.java b/src/java/com/sun/gluegen/runtime/UnixDynamicLinkerImpl.java
deleted file mode 100755
index b6a79be..0000000
--- a/src/java/com/sun/gluegen/runtime/UnixDynamicLinkerImpl.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/* !---- DO NOT EDIT: This file autogenerated by com\sun\gluegen\JavaEmitter.java on Mon Jul 31 16:26:59 PDT 2006 ----! */
-
-package com.sun.gluegen.runtime;
-
-import com.sun.gluegen.runtime.*;
-
-public class UnixDynamicLinkerImpl implements DynamicLinker
-{
-
- public static final int RTLD_LAZY = 0x00001;
- public static final int RTLD_NOW = 0x00002;
- public static final int RTLD_NOLOAD = 0x00004;
- public static final int RTLD_GLOBAL = 0x00100;
- public static final int RTLD_LOCAL = 0x00000;
- public static final int RTLD_PARENT = 0x00200;
- public static final int RTLD_GROUP = 0x00400;
- public static final int RTLD_WORLD = 0x00800;
- public static final int RTLD_NODELETE = 0x01000;
- public static final int RTLD_FIRST = 0x02000;
-
- /** Interface to C language function: <br> <code> int dlclose(void * ); </code> */
- private static native int dlclose(long arg0);
-
- /** Interface to C language function: <br> <code> char * dlerror(void); </code> */
- private static native java.lang.String dlerror();
-
- /** Interface to C language function: <br> <code> void * dlopen(const char * , int); </code> */
- private static native long dlopen(java.lang.String arg0, int arg1);
-
- /** Interface to C language function: <br> <code> void * dlsym(void * , const char * ); </code> */
- private static native long dlsym(long arg0, java.lang.String arg1);
-
-
- // --- Begin CustomJavaCode .cfg declarations
- public long openLibrary(String pathname) {
- // Note we use RTLD_GLOBAL visibility to allow this functionality to
- // be used to pre-resolve dependent libraries of JNI code without
- // requiring that all references to symbols in those libraries be
- // looked up dynamically via the ProcAddressTable mechanism; in
- // other words, one can actually link against the library instead of
- // having to dlsym all entry points. System.loadLibrary() uses
- // RTLD_LOCAL visibility so can't be used for this purpose.
- return dlopen(pathname, RTLD_LAZY | RTLD_GLOBAL);
- }
-
- public long lookupSymbol(long libraryHandle, String symbolName) {
- return dlsym(libraryHandle, symbolName);
- }
-
- public void closeLibrary(long libraryHandle) {
- dlclose(libraryHandle);
- }
- // ---- End CustomJavaCode .cfg declarations
-
-} // end of class UnixDynamicLinkerImpl
diff --git a/src/java/com/sun/gluegen/runtime/WindowsDynamicLinkerImpl.java b/src/java/com/sun/gluegen/runtime/WindowsDynamicLinkerImpl.java
deleted file mode 100755
index 553c2f2..0000000
--- a/src/java/com/sun/gluegen/runtime/WindowsDynamicLinkerImpl.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/* !---- DO NOT EDIT: This file autogenerated by com\sun\gluegen\JavaEmitter.java on Tue May 27 02:37:55 PDT 2008 ----! */
-
-package com.sun.gluegen.runtime;
-
-import com.sun.gluegen.runtime.*;
-
-public class WindowsDynamicLinkerImpl implements DynamicLinker
-{
-
-
- /** Interface to C language function: <br> <code> BOOL FreeLibrary(HANDLE hLibModule); </code> */
- private static native int FreeLibrary(long hLibModule);
-
- /** Interface to C language function: <br> <code> DWORD GetLastError(void); </code> */
- private static native int GetLastError();
-
- /** Interface to C language function: <br> <code> PROC GetProcAddressA(HANDLE hModule, LPCSTR lpProcName); </code> */
- private static native long GetProcAddressA(long hModule, java.lang.String lpProcName);
-
- /** Interface to C language function: <br> <code> HANDLE LoadLibraryW(LPCWSTR lpLibFileName); </code> */
- private static native long LoadLibraryW(java.lang.String lpLibFileName);
-
-
- // --- Begin CustomJavaCode .cfg declarations
- public long openLibrary(String libraryName) {
- return LoadLibraryW(libraryName);
- }
-
- public long lookupSymbol(long libraryHandle, String symbolName) {
- return GetProcAddressA(libraryHandle, symbolName);
- }
-
- public void closeLibrary(long libraryHandle) {
- FreeLibrary(libraryHandle);
- }
- // ---- End CustomJavaCode .cfg declarations
-
-} // end of class WindowsDynamicLinkerImpl