From 791a2749886f02ec7b8db25bf8862e8269b96da5 Mon Sep 17 00:00:00 2001
From: Harvey Harrison
* The implementation should ignore, if the library has been loaded already.
* @param libname the library to load
- * @param ignoreError if true, errors during loading the library should be ignored
+ * @param ignoreError if true, errors during loading the library should be ignored
* @param cl optional ClassLoader, used to locate the library
* @return true if library loaded successful
*/
@@ -81,12 +81,12 @@ public class JNILibLoaderBase {
* The implementation should ignore, if any library has been loaded already.
* @param libname the library to load
* @param preload the libraries to load before loading the main library if not null
- * @param preloadIgnoreError if true, errors during loading the preload-libraries should be ignored
+ * @param preloadIgnoreError if true, errors during loading the preload-libraries should be ignored
* @param cl optional ClassLoader, used to locate the library
*/
void loadLibrary(String libname, String[] preload, boolean preloadIgnoreError, ClassLoader cl);
}
-
+
private static class DefaultAction implements LoaderAction {
public boolean loadLibrary(String libname, boolean ignoreError, ClassLoader cl) {
boolean res = true;
@@ -143,13 +143,13 @@ public class JNILibLoaderBase {
public static void enableLoading() {
setLoadingAction(new DefaultAction());
}
-
+
public static synchronized void setLoadingAction(LoaderAction action) {
loaderAction = action;
}
/**
- *
+ *
* @param classFromJavaJar
* @param classJarURI
* @param jarBasename jar basename w/ suffix
@@ -170,16 +170,16 @@ public class JNILibLoaderBase {
if(TempJarCache.isInitialized()) {
final URI jarSubURI = JarUtil.getJarSubURI( classJarURI );
if(null == jarSubURI) {
- throw new IllegalArgumentException("JarSubURI is null of: "+classJarURI);
+ throw new IllegalArgumentException("JarSubURI is null of: "+classJarURI);
}
final String jarUriRoot_s = IOUtil.getURIDirname( jarSubURI.toString() );
msg.append("[ ").append(jarSubURI.toString()).append(" -> ").append(jarUriRoot_s).append(" ] + ");
-
+
final String nativeLibraryPath = "natives/"+PlatformPropsImpl.os_and_arch+"/";
final ClassLoader cl = classFromJavaJar.getClassLoader();
final URL nativeLibraryURI = cl.getResource(nativeLibraryPath);
if( null != nativeLibraryURI ) {
- // We probably have one big-fat jar file, containing java classes
+ // We probably have one big-fat jar file, containing java classes
// and all native platform libraries under 'natives/os.and.arch'!
final URI nativeJarURI = JarUtil.getJarFileURI(jarUriRoot_s+jarBasename);
if( TempJarCache.addNativeLibs(classFromJavaJar, nativeJarURI, nativeLibraryPath) ) {
@@ -188,7 +188,7 @@ public class JNILibLoaderBase {
}
}
if( !ok ) {
- // We assume one slim native jar file per 'os.and.arch'!
+ // We assume one slim native jar file per 'os.and.arch'!
final URI nativeJarURI = JarUtil.getJarFileURI(jarUriRoot_s+nativeJarBasename);
msg.append(nativeJarBasename).append(" -> slim: ").append(nativeJarURI);
ok = TempJarCache.addNativeLibs(classFromJavaJar, nativeJarURI, null /* nativeLibraryPath */);
@@ -201,22 +201,22 @@ public class JNILibLoaderBase {
}
return ok;
}
-
+
/**
* Loads and adds a JAR file's native library to the TempJarCache.
* The native library JAR file's URI is derived as follows:
*
- *
+ *
* Where:
* GLProfile.class
-> GLProfile.class
-> http://lala/
-> http://lala/'nativeJarBaseName'-'os.and.arch'.jar
*
- *
+ *
* @param classFromJavaJar GLProfile
* @param nativeJarBasename jogl-all
* @return true if the native JAR file loaded successful or were loaded already, false in case of an error
@@ -234,15 +234,15 @@ public class JNILibLoaderBase {
if(DEBUG) {
e0.printStackTrace();
}
- }
+ }
} else if(DEBUG) {
System.err.println("JNILibLoaderBase: addNativeJarLibs1: disabled due to uninitialized TempJarCache");
}
return false;
}
-
+
/**
- * Loads and adds a JAR file's native library to the TempJarCache,
+ * Loads and adds a JAR file's native library to the TempJarCache,
* calling {@link JNILibLoaderBase#addNativeJarLibs(Class[], String, String[])}
* with default JOGL deployment configuration:
* classFromJavaJar
@@ -258,7 +258,7 @@ public class JNILibLoaderBase {
*
* The native library JAR file's URI is derived as follows:
*
- *
+ *
* Where:
* GLProfile.class
-> GLProfile.class
-> http://lala/gluegen-rt.jar
-> http://lala/gluegen-rt
-> http://lala/gluegen-rt-natives-'os.and.arch'.jar
*
classesFromJavaJars
*
- * Otherwise the native JAR files will be resolved for each class's JAR file:
- *
+ * Otherwise the native JAR files will be resolved for each class's JAR file:
+ *
*
*
+ *
* Examples: @@ -309,7 +309,7 @@ public class JNILibLoaderBase { // only: jocl.jar -> jocl-natives-os.and.arch.jar addNativeJarLibs(new Class>[] { JOCLJNILibLoader.class }, null, null ); * - * + * * Newt Only: *
// either: [jogl-all.jar, jogl-all-noawt.jar, jogl-all-mobile.jar, jogl-all-android.jar] -> jogl-all-natives-os.and.arch.jar @@ -334,12 +334,12 @@ public class JNILibLoaderBase { JNILibLoaderBase.addNativeJarLibs(classesFromJavaJars, "-all", new String[] { "-noawt", "-mobile", "-core", "-android" } ); ** - * + * * @param classesFromJavaJars For each given Class, load the native library JAR. * @param singleJarMarker Optional string marker like "-all" to identify the single 'all-in-one' JAR file * after which processing of the class array shall stop. * @param stripBasenameSuffixes Optional substrings to be stripped of the base URI - * + * * @return true if either the 'all-in-one' native JAR or all native JARs loaded successful or were loaded already, * false in case of an error */ @@ -351,7 +351,7 @@ public class JNILibLoaderBase { if(TempJarCache.isInitialized()) { final StringBuilder msg = new StringBuilder(); int count = 0; - try { + try { boolean done = false; ok = true; for(int i=0; !done && ok && i
* asset resource location protocol connection. *
- * + * ** See {@link AssetURLContext#resolve(String)} how resources are being resolved. *
* *test/lala.txt
is being resolved by
* a class test.LaLaTest
, ie. using the asset aware ClassLoader,
- * one would use the following asset aware filesystem layout:
- *
+ * one would use the following asset aware filesystem layout:
+ *
* * test/LaLaTest.class * assets/test/lala.txt *- * - * The above maybe on a plain filesystem, or within a JAR or an APK file, + * + * The above maybe on a plain filesystem, or within a JAR or an APK file, * e.g.
jogamp.test.apk
.
- *
+ *
* The above would result in the following possible URLs
- * reflecting the plain and resolved state of the asset URL:
+ * reflecting the plain and resolved state of the asset URL:
* * 0 Entry test/lala.txt * 1 Plain asset:test/lala.txt @@ -38,16 +38,16 @@ import java.net.URL; ** *
- * The sub protocol URL of the resolved asset + * The sub protocol URL of the resolved asset *
* 3 Sub-URL jar:file:/data/app/jogamp.test.apk!/assets/test/lala.txt ** can be retrieved using {@link #getSubProtocol()}. * - * + * * In all above cases, the asset entry is
test/lala.txt
,
* which can be retrieved via {@link #getEntryName()}.
- *
+ *
* *
*
- * The Android ClassLoader {@link jogamp.android.launcher.AssetDexClassLoader} + * The Android ClassLoader {@link jogamp.android.launcher.AssetDexClassLoader} * resolves the resource as an asset URL in it's {@link ClassLoader#findResource(String)} implementation.
*- * Currently we attach our asset {@link java.net.URLStreamHandlerFactory} + * Currently we attach our asset {@link java.net.URLStreamHandlerFactory} * to allow {@link java.net.URL} to handle asset URLs via our asset {@link java.net.URLStreamHandler} implementation. *
*/ public class AssetURLConnection extends PiggybackURLConnectionasset
*/
public static final String asset_protocol = "asset";
-
+
/** The asset URL protocol prefix asset:
*/
public static final String asset_protocol_prefix = "asset:";
-
- /**
+
+ /**
* The optional asset folder name with ending slash assets/
.
* * Note that the asset folder is not used on all platforms using the asset protocol @@ -41,11 +41,11 @@ public abstract class AssetURLContext implements PiggybackURLContext { } }; } - + public static AssetURLStreamHandler createHandler(final ClassLoader cl) { return new AssetURLStreamHandler(create(cl)); } - + /** * Create an asset URL, suitable even w/o the registered asset URLStreamHandler. *
@@ -62,7 +62,7 @@ public abstract class AssetURLContext implements PiggybackURLContext { public static URL createURL(String path, ClassLoader cl) throws MalformedURLException { return new URL(null, path.startsWith(asset_protocol_prefix) ? path : asset_protocol_prefix + path, createHandler(cl)); } - + /** * Create an asset URL, suitable only with the registered asset URLStreamHandler. *
@@ -78,20 +78,20 @@ public abstract class AssetURLContext implements PiggybackURLContext {
public static URL createURL(String path) throws MalformedURLException {
return new URL(path.startsWith(asset_protocol_prefix) ? path : asset_protocol_prefix + path);
}
-
+
/**
- * Returns the asset handler previously set via {@link #registerHandler(ClassLoader)},
+ * Returns the asset handler previously set via {@link #registerHandler(ClassLoader)},
* or null if none was set.
*/
public static URLStreamHandler getRegisteredHandler() {
final GenericURLStreamHandlerFactory f = GenericURLStreamHandlerFactory.register();
return ( null != f ) ? f.getHandler(asset_protocol) : null;
}
-
+
/**
- * Registers the generic URLStreamHandlerFactory via {@link GenericURLStreamHandlerFactory#register()}
+ * Registers the generic URLStreamHandlerFactory via {@link GenericURLStreamHandlerFactory#register()}
* and if successful sets the asset handler
for the given ClassLoader cl
.
- *
+ *
* @return true if successful, otherwise false
*/
public static boolean registerHandler(ClassLoader cl) {
@@ -103,11 +103,11 @@ public abstract class AssetURLContext implements PiggybackURLContext {
return false;
}
}
-
- /**
+
+ /**
* Returns an asset aware ClassLoader.
*
- * The ClassLoader is required to find the asset resource
+ * The ClassLoader is required to find the asset resource
* via it's URL findResource(String)
implementation.
*
@@ -123,33 +123,33 @@ public abstract class AssetURLContext implements PiggybackURLContext { @Override public String getImplementedProtocol() { return asset_protocol; - } - + } + /** * {@inheritDoc} - *
+ *
* This implementation attempts to resolve path
in the following order:
*
new URL(path)
, use sub-protocol if asset URLnew File(path).toURI().toURL()
*
* In case of using the ClassLoader (2) and if running on Android,
* the {@link #assets_folder} is being prepended to path
if missing.
- *
* This is the asset URLStreamHandler variation - * for manual use. + * for manual use. *
** It requires passing a valid {@link AssetURLContext} * for construction, hence it's not suitable for the pkg factory model. *
*/ -public class AssetURLStreamHandler extends URLStreamHandler { +public class AssetURLStreamHandler extends URLStreamHandler { AssetURLContext ctx; - + public AssetURLStreamHandler(AssetURLContext ctx) { this.ctx = ctx; } - + @Override protected URLConnection openConnection(URL u) throws IOException { final AssetURLConnection c = new AssetURLConnection(u, ctx); c.connect(); return c; } - - + + } diff --git a/src/java/com/jogamp/common/net/GenericURLStreamHandlerFactory.java b/src/java/com/jogamp/common/net/GenericURLStreamHandlerFactory.java index 79d7f71..4ec3f19 100644 --- a/src/java/com/jogamp/common/net/GenericURLStreamHandlerFactory.java +++ b/src/java/com/jogamp/common/net/GenericURLStreamHandlerFactory.java @@ -10,30 +10,30 @@ import java.util.Map; public class GenericURLStreamHandlerFactory implements URLStreamHandlerFactory { private static GenericURLStreamHandlerFactory factory = null; - + private final Maphandler
for protocol
.
- *
+ *
* @return the previous set handler
, or null if none was set.
*/
public synchronized final URLStreamHandler setHandler(String protocol, URLStreamHandler handler) {
return protocolHandlers.put(protocol, handler);
}
-
+
/**
- * Returns the protocol
handler previously set via {@link #setHandler(String, URLStreamHandler)},
+ * Returns the protocol
handler previously set via {@link #setHandler(String, URLStreamHandler)},
* or null if none was set.
*/
public synchronized final URLStreamHandler getHandler(String protocol) {
return protocolHandlers.get(protocol);
}
-
+
@Override
public synchronized final URLStreamHandler createURLStreamHandler(String protocol) {
return getHandler(protocol);
diff --git a/src/java/com/jogamp/common/net/PiggybackURLConnection.java b/src/java/com/jogamp/common/net/PiggybackURLConnection.java
index 39f1637..3b774e8 100644
--- a/src/java/com/jogamp/common/net/PiggybackURLConnection.java
+++ b/src/java/com/jogamp/common/net/PiggybackURLConnection.java
@@ -6,10 +6,10 @@ import java.net.URL;
import java.net.URLConnection;
/**
- * Generic resource location protocol connection,
+ * Generic resource location protocol connection,
* using another sub-protocol as the vehicle for a piggyback protocol.
* - * The details of the sub-protocol can be queried using {@link #getSubProtocol()}. + * The details of the sub-protocol can be queried using {@link #getSubProtocol()}. *
** See example in {@link AssetURLConnection}. @@ -19,7 +19,7 @@ public abstract class PiggybackURLConnection exte protected URL subUrl; protected URLConnection subConn; protected I context; - + /** * @param url the specific URL for this instance * @param context the piggyback context, defining state independent code and constants @@ -34,18 +34,18 @@ public abstract class PiggybackURLConnection exte * Resolves the URL via {@link PiggybackURLContext#resolve(String)}, * see {@link AssetURLContext#resolve(String)} for an example. *
- * + * * {@inheritDoc} */ @Override public synchronized void connect() throws IOException { if(!connected) { - subConn = context.resolve(url.getPath()); - subUrl = subConn.getURL(); + subConn = context.resolve(url.getPath()); + subUrl = subConn.getURL(); connected = true; } } - + @Override public InputStream getInputStream() throws IOException { if(!connected) { @@ -53,26 +53,26 @@ public abstract class PiggybackURLConnection exte } return subConn.getInputStream(); } - - /** + + /** * Returns the entry name of the asset. ** Plain asset:test/lala.txt * Resolved asset:jar:file:/data/app/jogamp.test.apk!/assets/test/lala.txt * Result test/lala.txt - *+ * * @throws IOException is not connected **/ public abstract String getEntryName() throws IOException; - - /** + + /** * Returns the resolved sub protocol of the asset or null, ie: *
* Plain asset:test/lala.txt * Resolved asset:jar:file:/data/app/jogamp.test.apk!/assets/test/lala.txt * Result jar:file:/data/app/jogamp.test.apk!/assets/test/lala.txt *- * + * * @throws IOException is not connected */ public URL getSubProtocol() throws IOException { diff --git a/src/java/com/jogamp/common/net/PiggybackURLContext.java b/src/java/com/jogamp/common/net/PiggybackURLContext.java index 2cb48b5..9e3db69 100644 --- a/src/java/com/jogamp/common/net/PiggybackURLContext.java +++ b/src/java/com/jogamp/common/net/PiggybackURLContext.java @@ -8,11 +8,11 @@ import java.net.URLConnection; */ public interface PiggybackURLContext { - /** Returns the specific protocol, constant for this implementation. */ + /** Returns the specific protocol, constant for this implementation. */ public String getImplementedProtocol(); - - /** - * Resolving path to a URL sub protocol and return it's open URLConnection + + /** + * Resolving path to a URL sub protocol and return it's open URLConnection **/ - public URLConnection resolve(String path) throws IOException; + public URLConnection resolve(String path) throws IOException; } diff --git a/src/java/com/jogamp/common/net/asset/Handler.java b/src/java/com/jogamp/common/net/asset/Handler.java index 1063797..d622221 100644 --- a/src/java/com/jogamp/common/net/asset/Handler.java +++ b/src/java/com/jogamp/common/net/asset/Handler.java @@ -8,12 +8,12 @@ import java.net.URLStreamHandler; import com.jogamp.common.net.AssetURLConnection; import com.jogamp.common.net.AssetURLContext; -/** +/** * {@link URLStreamHandler} to handle the asset protocol. - * + * *
* This is the asset URLStreamHandler variation - * using this class ClassLoader for the pkg factory model. + * using this class ClassLoader for the pkg factory model. *
*/ public class Handler extends URLStreamHandler { @@ -23,16 +23,16 @@ public class Handler extends URLStreamHandler { return Handler.class.getClassLoader(); } }; - + public Handler() { super(); } - + @Override protected URLConnection openConnection(URL u) throws IOException { final AssetURLConnection c = new AssetURLConnection(u, localCL); c.connect(); return c; } - + } diff --git a/src/java/com/jogamp/common/nio/AbstractBuffer.java b/src/java/com/jogamp/common/nio/AbstractBuffer.java index 4afff2a..4213a4d 100644 --- a/src/java/com/jogamp/common/nio/AbstractBuffer.java +++ b/src/java/com/jogamp/common/nio/AbstractBuffer.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + /* * Created on Saturday, March 27 2010 11:55 */ @@ -51,7 +51,7 @@ public abstract class AbstractBuffer implements Native Platform.initSingleton(); // loads native gluegen-rt library } - /** + /** * capacity and elementSize should be match the equation w/ target buffer type ** capacity = elementSizeInBytes(buffer) * buffer.capacity() ) / elementSize @@ -64,14 +64,14 @@ public abstract class AbstractBuffer implements Native this.buffer = buffer; this.elementSize = elementSize; this.capacity = capacity; - + this.position = 0; } public final int elementSize() { return elementSize; } - + public final int limit() { return capacity; } @@ -113,7 +113,7 @@ public abstract class AbstractBuffer implements Native public final boolean isDirect() { return buffer.isDirect(); } - + public final boolean hasArray() { return buffer.hasArray(); } @@ -129,7 +129,7 @@ public abstract class AbstractBuffer implements Native public Object array() throws UnsupportedOperationException { return buffer.array(); } - + @Override public String toString() { return "AbstractBuffer[direct "+isDirect()+", hasArray "+hasArray()+", capacity "+capacity+", position "+position+", elementSize "+elementSize+", buffer[capacity "+buffer.capacity()+", lim "+buffer.limit()+", pos "+buffer.position()+"]]"; diff --git a/src/java/com/jogamp/common/nio/Buffers.java b/src/java/com/jogamp/common/nio/Buffers.java index 851aa69..c63a094 100644 --- a/src/java/com/jogamp/common/nio/Buffers.java +++ b/src/java/com/jogamp/common/nio/Buffers.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: - * + * * - Redistribution of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * - Redistribution in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * + * * Neither the name of Sun Microsystems, Inc. or the names of * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. - * + * * This software is provided "AS IS," without a warranty of any kind. ALL * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A @@ -29,11 +29,11 @@ * 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. */ @@ -47,7 +47,7 @@ import com.jogamp.common.util.ValueConv; /** * Utility methods allowing easy {@link java.nio.Buffer} manipulations. - * + * * @author Kenneth Russel * @author Sven Gothel * @author Michael Bien @@ -213,7 +213,7 @@ public class Buffers { /** * Calls slice on the specified buffer while maintaining the byteorder. - * @see #slice(java.nio.Buffer, int, int) + * @see #slice(java.nio.Buffer, int, int) */ @SuppressWarnings("unchecked") public static B slice(B buffer) { @@ -264,22 +264,22 @@ public class Buffers { * The returned sliced buffer's start position is not necessarily zero, * but the float position within the host ByteBuffer. * - *+ *
* The returned sliced buffer is {@link FloatBuffer#mark() marked} at it's starting position. Hence - * {@link FloatBuffer#reset()} will rewind it to start after applying relative operations like {@link FloatBuffer#get()}. + * {@link FloatBuffer#reset()} will rewind it to start after applying relative operations like {@link FloatBuffer#get()}. *
- *- * Using a ByteBuffer as the source guarantees - * keeping the source native order programmatically. - * This works around Honeycomb / Android 3.0 Issue 16434. + *
+ * Using a ByteBuffer as the source guarantees + * keeping the source native order programmatically. + * This works around Honeycomb / Android 3.0 Issue 16434. * This bug is resolved at least in Android 3.2. *
- * - * @param buf source Buffer, maybe ByteBuffer (recommended) or FloatBuffer ornull
. + * + * @param buf source Buffer, maybe ByteBuffer (recommended) or FloatBuffer ornull
. * Buffer's position is ignored and floatPos is being used. * @param backing source float array ornull
* @param floatPos {@link Buffers#SIZEOF_FLOAT} position - * @param floatSize {@link Buffers#SIZEOF_FLOAT} size + * @param floatSize {@link Buffers#SIZEOF_FLOAT} size * @return FloatBuffer w/ native byte order as given ByteBuffer */ public static final FloatBuffer slice2Float(Buffer buf, float[] backing, int floatPos, int floatSize) { @@ -318,7 +318,7 @@ public class Buffers { return res; } - + /** * Helper routine to set a ByteBuffer to the native byte order, if * that operation is supported by the underlying NIO @@ -329,7 +329,7 @@ public class Buffers { } /** - * Returns the size of a single element of the given buffer in bytes + * Returns the size of a single element of the given buffer in bytes * or0
if the given buffer isnull
. */ public static int sizeOfBufferElem(Object buffer) { @@ -358,7 +358,7 @@ public class Buffers { /** * Returns the number of remaining elements of the given anonymousbuffer
. - * + * * @param buffer Anonymous Buffer of type {@link NativeBuffer} or a derivation of {@link Buffer}. * @return Ifbuffer
is null, returns0
, otherwise the remaining size in elements. * @throws IllegalArgumentException if
buffer
is of invalid type. @@ -375,10 +375,10 @@ public class Buffers { throw new IllegalArgumentException("Unsupported anonymous buffer type: "+buffer.getClass().getCanonicalName()); } } - + /** * Returns the number of remaining bytes of the given anonymousbuffer
. - * + * * @param buffer Anonymous Buffer of type {@link NativeBuffer} or a derivation of {@link Buffer}. * @return Ifbuffer
is null, returns0
, otherwise the remaining size in bytes. * @throws IllegalArgumentException if
buffer
is of invalid type. @@ -434,11 +434,11 @@ public class Buffers { if (buf instanceof ByteBuffer) { return ((ByteBuffer) buf).isDirect(); } else if (buf instanceof IntBuffer) { - return ((IntBuffer) buf).isDirect(); + return ((IntBuffer) buf).isDirect(); } else if (buf instanceof ShortBuffer) { - return ((ShortBuffer) buf).isDirect(); + return ((ShortBuffer) buf).isDirect(); } else if (buf instanceof FloatBuffer) { - return ((FloatBuffer) buf).isDirect(); + return ((FloatBuffer) buf).isDirect(); } else if (buf instanceof DoubleBuffer) { return ((DoubleBuffer) buf).isDirect(); } else if (buf instanceof LongBuffer) { @@ -490,7 +490,7 @@ public class Buffers { * Helper routine to return the array backing store reference from * a Buffer object. * @throws UnsupportedOperationException if the passed Object does not have an array backing store - * @throws IllegalArgumentException if the passed Object is neither of type {@link java.nio.Buffer} or {@link NativeBuffer}. + * @throws IllegalArgumentException if the passed Object is neither of type {@link java.nio.Buffer} or {@link NativeBuffer}. */ public static Object getArray(Object buf) throws UnsupportedOperationException, IllegalArgumentException { if (buf == null) { @@ -557,7 +557,7 @@ public class Buffers { ByteBuffer dest = newDirectByteBuffer(orig.remaining()); dest.put(orig); dest.rewind(); - orig.position(op0); + orig.position(op0); return dest; } @@ -752,8 +752,8 @@ public class Buffers { //---------------------------------------------------------------------- // Convenient put methods with generic target Buffer w/o value range conversion, i.e. normalization - // - + // + @SuppressWarnings("unchecked") public static B put(B dest, Buffer src) { if ((dest instanceof ByteBuffer) && (src instanceof ByteBuffer)) { @@ -841,7 +841,7 @@ public class Buffers { throw new IllegalArgumentException("Float doesn't match Buffer Class: " + dest); } } - + @SuppressWarnings("unchecked") public static B putd(B dest, double v) { if (dest instanceof FloatBuffer) { @@ -855,15 +855,15 @@ public class Buffers { // Convenient put methods with generic target Buffer and value range conversion, i.e. normalization // - /** + /** * Store byte source value in given buffer after normalizing it to the destination value range * considering signed and unsigned source and destination representation. - * + * * @param dest One of {@link ByteBuffer}, {@link ShortBuffer}, {@link IntBuffer}, {@link FloatBuffer} * @param dSigned true if destination buffer holds signed values, false if destination buffer holds unsigned values * @param v source byte value to be put in dest buffer * @param sSigned true if source represents a signed value, false if source represents an unsigned value - */ + */ @SuppressWarnings("unchecked") public static B putNb(B dest, boolean dSigned, byte v, boolean sSigned) { if (dest instanceof ByteBuffer) { @@ -872,22 +872,22 @@ public class Buffers { return (B) ((ShortBuffer) dest).put( ValueConv.byte_to_short(v, sSigned, dSigned) ); } else if (dest instanceof IntBuffer) { return (B) ((IntBuffer) dest).put( ValueConv.byte_to_int(v, sSigned, dSigned) ); - } else if (dest instanceof FloatBuffer) { + } else if (dest instanceof FloatBuffer) { return (B) ((FloatBuffer) dest).put( ValueConv.byte_to_float(v, sSigned) ); } else { throw new IllegalArgumentException("Byte doesn't match Buffer Class: " + dest); } } - /** + /** * Store short source value in given buffer after normalizing it to the destination value range * considering signed and unsigned source and destination representation. - * + * * @param dest One of {@link ByteBuffer}, {@link ShortBuffer}, {@link IntBuffer}, {@link FloatBuffer} * @param dSigned true if destination buffer holds signed values, false if destination buffer holds unsigned values * @param v source short value to be put in dest buffer * @param sSigned true if source represents a signed value, false if source represents an unsigned value - */ + */ @SuppressWarnings("unchecked") public static B putNs(B dest, boolean dSigned, short v, boolean sSigned) { if (dest instanceof ByteBuffer) { @@ -896,22 +896,22 @@ public class Buffers { return (B) ((ShortBuffer) dest).put( v ); } else if (dest instanceof IntBuffer) { return (B) ((IntBuffer) dest).put( ValueConv.short_to_int(v, sSigned, dSigned) ); - } else if (dest instanceof FloatBuffer) { + } else if (dest instanceof FloatBuffer) { return (B) ((FloatBuffer) dest).put( ValueConv.short_to_float(v, sSigned) ); } else { throw new IllegalArgumentException("Byte doesn't match Buffer Class: " + dest); } } - - /** + + /** * Store short source value in given buffer after normalizing it to the destination value range * considering signed and unsigned source and destination representation. - * + * * @param dest One of {@link ByteBuffer}, {@link ShortBuffer}, {@link IntBuffer}, {@link FloatBuffer} * @param dSigned true if destination buffer holds signed values, false if destination buffer holds unsigned values * @param v source short value to be put in dest buffer * @param sSigned true if source represents a signed value, false if source represents an unsigned value - */ + */ @SuppressWarnings("unchecked") public static B putNi(B dest, boolean dSigned, int v, boolean sSigned) { if (dest instanceof ByteBuffer) { @@ -920,21 +920,21 @@ public class Buffers { return (B) ((ShortBuffer) dest).put( ValueConv.int_to_short(v, sSigned, dSigned) ); } else if (dest instanceof IntBuffer) { return (B) ((IntBuffer) dest).put( v ); - } else if (dest instanceof FloatBuffer) { + } else if (dest instanceof FloatBuffer) { return (B) ((FloatBuffer) dest).put( ValueConv.int_to_float(v, sSigned) ); } else { throw new IllegalArgumentException("Byte doesn't match Buffer Class: " + dest); } } - - /** + + /** * Store float source value in given buffer after normalizing it to the destination value range * considering signed and unsigned destination representation. - * + * * @param dest One of {@link ByteBuffer}, {@link ShortBuffer}, {@link IntBuffer}, {@link FloatBuffer} * @param dSigned true if destination buffer holds signed values, false if destination buffer holds unsigned values * @param v source float value to be put in dest buffer - */ + */ @SuppressWarnings("unchecked") public static B putNf(B dest, boolean dSigned, float v) { if (dest instanceof ByteBuffer) { @@ -943,17 +943,17 @@ public class Buffers { return (B) ((ShortBuffer) dest).put( ValueConv.float_to_short(v, dSigned) ); } else if (dest instanceof IntBuffer) { return (B) ((IntBuffer) dest).put( ValueConv.float_to_int(v, dSigned) ); - } else if (dest instanceof FloatBuffer) { + } else if (dest instanceof FloatBuffer) { return (B) ((FloatBuffer) dest).put( v ); } else { throw new IllegalArgumentException("Byte doesn't match Buffer Class: " + dest); } } - + //---------------------------------------------------------------------- - // Range check methods + // Range check methods // - + public static void rangeCheck(byte[] array, int offset, int minElementsRemaining) { if (array == null) { return; @@ -1049,13 +1049,13 @@ public class Buffers { throw new IndexOutOfBoundsException("Required " + minBytesRemaining + " remaining bytes in buffer, only had " + bytesRemaining); } } - + /** * Appends Buffer details inclusive data to a StringBuilder instance. * @param sb optional pass through StringBuilder - * @param f optional format string of one element, i.e. "%10.5f" for {@link FloatBuffer}, see {@link java.util.Formatter}, - * ornull
for unformatted output. - * Note: Caller is responsible to match the format string w/ the data type as expected in the given buffer. + * @param f optional format string of one element, i.e. "%10.5f" for {@link FloatBuffer}, see {@link java.util.Formatter}, + * ornull
for unformatted output. + * Note: Caller is responsible to match the format string w/ the data type as expected in the given buffer. * @param buffer Any valid Buffer instance * @return the modified StringBuilder containing the Buffer details */ @@ -1073,74 +1073,74 @@ public class Buffers { for(int i=0; ifactories created with createSynchronized(...) are threadsafe * * - * + * * @author Michael Bien */ public class CachedBufferFactory { @@ -67,20 +67,20 @@ public class CachedBufferFactory { * default size for internal buffer allocation. */ public static final int DEFAULT_ALLOCATION_SIZE = 1024 * 1024; - + private final int ALLOCATION_SIZE; private ByteBuffer currentBuffer; - + private CachedBufferFactory() { this(DEFAULT_ALLOCATION_SIZE, DEFAULT_ALLOCATION_SIZE); } - + private CachedBufferFactory(int initialSize, int allocationSize) { currentBuffer = Buffers.newDirectByteBuffer(initialSize); ALLOCATION_SIZE = allocationSize; } - - + + /** * Creates a factory with initial size and allocation size set to * {@link #DEFAULT_ALLOCATION_SIZE}. @@ -88,7 +88,7 @@ public class CachedBufferFactory { public static CachedBufferFactory create() { return new CachedBufferFactory(); } - + /** * Creates a factory with the specified initial size. The allocation size is set to * {@link #DEFAULT_ALLOCATION_SIZE}. @@ -96,7 +96,7 @@ public class CachedBufferFactory { public static CachedBufferFactory create(int initialSize) { return new CachedBufferFactory(initialSize, DEFAULT_ALLOCATION_SIZE); } - + /** * Creates a factory with the specified initial size. The allocation size is set to * {@link #DEFAULT_ALLOCATION_SIZE}. @@ -106,43 +106,43 @@ public class CachedBufferFactory { public static CachedBufferFactory create(int initialSize, boolean fixed) { return new CachedBufferFactory(initialSize, fixed?-1:DEFAULT_ALLOCATION_SIZE); } - + /** * Creates a factory with the specified initial size and allocation size. */ public static CachedBufferFactory create(int initialSize, int allocationSize) { return new CachedBufferFactory(initialSize, allocationSize); } - - + + /** * Synchronized version of {@link #create()}. */ public static CachedBufferFactory createSynchronized() { return new SynchronizedCachedBufferFactory(); } - + /** * Synchronized version of {@link #create(int)}. */ public static CachedBufferFactory createSynchronized(int initialSize) { return new SynchronizedCachedBufferFactory(initialSize, DEFAULT_ALLOCATION_SIZE); } - + /** * Synchronized version of {@link #create(int, boolean)}. */ public static CachedBufferFactory createSynchronized(int initialSize, boolean fixed) { return new SynchronizedCachedBufferFactory(initialSize, fixed?-1:DEFAULT_ALLOCATION_SIZE); } - + /** * Synchronized version of {@link #create(int, int)}. */ public static CachedBufferFactory createSynchronized(int initialSize, int allocationSize) { return new CachedBufferFactory(initialSize, allocationSize); } - + /** * Returns true only if this factory does not allow to allocate more buffers * as limited by the initial size. @@ -150,7 +150,7 @@ public class CachedBufferFactory { public boolean isFixed() { return ALLOCATION_SIZE == -1; } - + /** * Returns the allocation size used to create new internal buffers. * 0 means that the buffer will not grows, see {@link #isFixed()}. @@ -158,7 +158,7 @@ public class CachedBufferFactory { public int getAllocationSize() { return ALLOCATION_SIZE; } - + /** * @return true if buffer cannot grow, otherwise false */ @@ -175,7 +175,7 @@ public class CachedBufferFactory { } } public ByteBuffer newDirectByteBuffer(int size) { - + // if large enough... just create it if (size > currentBuffer.capacity()) { checkIfFixed(); @@ -194,7 +194,7 @@ public class CachedBufferFactory { currentBuffer.limit(currentBuffer.capacity()); return result; } - + public ByteBuffer newDirectByteBuffer(byte[] values, int offset, int lenght) { return (ByteBuffer)newDirectByteBuffer(lenght).put(values, offset, lenght).rewind(); @@ -326,8 +326,8 @@ public class CachedBufferFactory { public String toString() { return getClass().getName()+"[static:"+isFixed()+" alloc size:"+getAllocationSize()+"]"; } - - + + // nothing special, just synchronized private static class SynchronizedCachedBufferFactory extends CachedBufferFactory { @@ -338,12 +338,12 @@ public class CachedBufferFactory { private SynchronizedCachedBufferFactory(int size, int step) { super(size, step); } - + @Override public synchronized ByteBuffer newDirectByteBuffer(int size) { return super.newDirectByteBuffer(size); } - + } } diff --git a/src/java/com/jogamp/common/nio/NativeBuffer.java b/src/java/com/jogamp/common/nio/NativeBuffer.java index 0273976..d81da9d 100644 --- a/src/java/com/jogamp/common/nio/NativeBuffer.java +++ b/src/java/com/jogamp/common/nio/NativeBuffer.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + /* * Created on Tuesday, March 30 2010 18:22 */ @@ -43,7 +43,7 @@ import java.nio.Buffer; public interface NativeBuffer { public int elementSize(); - + public int limit(); public int capacity(); @@ -66,8 +66,8 @@ public interface NativeBuffer { * otherwise 0. */ public int arrayOffset(); - - /** + + /** * @return the primitive backup array of the buffer if {@link #hasArray()} is true, * otherwise it throws {@link java.lang.UnsupportedOperationException}. * The returned primitive array maybe of type int[]
orlong[]
, etc .. diff --git a/src/java/com/jogamp/common/nio/PointerBuffer.java b/src/java/com/jogamp/common/nio/PointerBuffer.java index df1c4b1..4a479f0 100644 --- a/src/java/com/jogamp/common/nio/PointerBuffer.java +++ b/src/java/com/jogamp/common/nio/PointerBuffer.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -60,22 +60,22 @@ public class PointerBuffer extends AbstractBuffer{ static PointerBuffer create(ByteBuffer bb) { return Platform.is32Bit() ? new PointerBuffer( bb.asIntBuffer() ) : new PointerBuffer( bb.asLongBuffer() ); } - + /** supports backup array */ PointerBuffer(IntBuffer b) { super(b, ELEMENT_SIZE, b.capacity()); } - + /** supports backup array */ PointerBuffer(LongBuffer b) { super(b, ELEMENT_SIZE, b.capacity()); } - + private final void validateDataMap() { if(null == dataMap) { dataMap = new LongObjectHashMap(); - dataMap.setKeyNotFoundValue(null); - } + dataMap.setKeyNotFoundValue(null); + } } /** Returns a non direct PointerBuffer in native order, having a backup array */ @@ -84,7 +84,7 @@ public class PointerBuffer extends AbstractBuffer { return new PointerBuffer(IntBuffer.wrap(new int[size])); } else { return new PointerBuffer(LongBuffer.wrap(new long[size])); - } + } } /** Returns a direct PointerBuffer in native order, w/o backup array */ @@ -113,9 +113,9 @@ public class PointerBuffer extends AbstractBuffer { npb.position = position; return npb; } - - /** - * Relative bulk get method. Copy the source values src[position .. capacity] [
+ + /** + * Relative bulk get method. Copy the source valuessrc[position .. capacity] [
* to this buffer and increment the position bycapacity-position
. */ public final PointerBuffer put(PointerBuffer src) { if (remaining() < src.remaining()) { @@ -145,7 +145,7 @@ public class PointerBuffer extends AbstractBuffer{ } return this; } - + /** Relative get method. Get the pointer value at the current position and increment the position by one. */ public final long get() { long r = get(position); @@ -164,9 +164,9 @@ public class PointerBuffer extends AbstractBuffer { return ((LongBuffer) buffer).get(idx); } } - - /** - * Relative bulk get method. Copy the pointer values [ position .. position+length [
+ + /** + * Relative bulk get method. Copy the pointer values[ position .. position+length [
* to the destination array[ dest[offset] .. dest[offset+length] [
* and increment the position bylength
. */ public final PointerBuffer get(long[] dest, int offset, int length) { @@ -203,8 +203,8 @@ public class PointerBuffer extends AbstractBuffer{ return this; } - /** - * Relative bulk put method. Put the pointer values [ src[offset] .. src[offset+length] [
+ /** + * Relative bulk put method. Put the pointer values[ src[offset] .. src[offset+length] [
* at the current position and increment the position bylength
. */ public final PointerBuffer put(long[] src, int offset, int length) { if (src.length{ /** Put the address of the given direct Buffer at the given position of this pointer array. Adding a reference of the given direct Buffer to this object. - - @throws IllegalArgumentException if bb is null or not a direct buffer + + @throws IllegalArgumentException if bb is null or not a direct buffer */ public final PointerBuffer referenceBuffer(int index, Buffer bb) { if(null==bb) { @@ -239,7 +239,7 @@ public class PointerBuffer extends AbstractBuffer { throw new RuntimeException("Couldn't determine native address of given Buffer: "+bb); } validateDataMap(); - put(index, bbAddr); + put(index, bbAddr); dataMap.put(bbAddr, bb); return this; } diff --git a/src/java/com/jogamp/common/nio/StructAccessor.java b/src/java/com/jogamp/common/nio/StructAccessor.java index eef9dc5..d6df083 100644 --- a/src/java/com/jogamp/common/nio/StructAccessor.java +++ b/src/java/com/jogamp/common/nio/StructAccessor.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: - * + * * - Redistribution of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * - Redistribution in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * + * * Neither the name of Sun Microsystems, Inc. or the names of * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. - * + * * This software is provided "AS IS," without a warranty of any kind. ALL * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A @@ -29,11 +29,11 @@ * 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. */ @@ -58,7 +58,7 @@ public class StructAccessor { return bb; } - /** + /** * Returns 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 @@ -116,11 +116,11 @@ public class StructAccessor { /** Retrieves the int at the specified byteOffset. */ public final int getIntAt(int byteOffset, int nativeSizeInBytes) { switch(nativeSizeInBytes) { - case 2: + case 2: return (int) bb.getShort(byteOffset) & 0x0000FFFF ; - case 4: + case 4: return bb.getInt(byteOffset); - case 8: + case 8: return (int) ( bb.getLong(byteOffset) & 0x00000000FFFFFFFFL ) ; default: throw new InternalError("invalid nativeSizeInBytes "+nativeSizeInBytes); @@ -130,20 +130,20 @@ public class StructAccessor { /** Puts a int at the specified byteOffset. */ public final void setIntAt(int byteOffset, int v, int nativeSizeInBytes) { switch(nativeSizeInBytes) { - case 2: + case 2: bb.putShort(byteOffset, (short) ( v & 0x0000FFFF ) ); break; - case 4: + case 4: bb.putInt(byteOffset, v); break; - case 8: + case 8: bb.putLong(byteOffset, (long)v & 0x00000000FFFFFFFFL ); break; default: throw new InternalError("invalid nativeSizeInBytes "+nativeSizeInBytes); } } - + /** Retrieves the float at the specified byteOffset. */ public final float getFloatAt(int byteOffset) { return bb.getFloat(byteOffset); @@ -173,13 +173,13 @@ public class StructAccessor { public final void setLongAt(int byteOffset, long v) { bb.putLong(byteOffset, v); } - + /** Retrieves the long at the specified byteOffset. */ public final long getLongAt(int byteOffset, int nativeSizeInBytes) { switch(nativeSizeInBytes) { - case 4: + case 4: return (long) bb.getInt(byteOffset) & 0x00000000FFFFFFFFL; - case 8: + case 8: return bb.getLong(byteOffset); default: throw new InternalError("invalid nativeSizeInBytes "+nativeSizeInBytes); @@ -189,17 +189,17 @@ public class StructAccessor { /** Puts a long at the specified byteOffset. */ public final void setLongAt(int byteOffset, long v, int nativeSizeInBytes) { switch(nativeSizeInBytes) { - case 4: + case 4: bb.putInt(byteOffset, (int) ( v & 0x00000000FFFFFFFFL ) ); break; - case 8: + case 8: bb.putLong(byteOffset, v); break; default: throw new InternalError("invalid nativeSizeInBytes "+nativeSizeInBytes); } } - + public final void setBytesAt(int byteOffset, byte[] v) { for (int i = 0; i < v.length; i++) { bb.put(byteOffset++, v[i]); @@ -225,18 +225,18 @@ public class StructAccessor { } return v; } - + public final void setShortsAt(int byteOffset, short[] v) { for (int i = 0; i < v.length; i++, byteOffset+=2) { bb.putShort(byteOffset, v[i]); - } + } } - + public final short[] getShortsAt(int byteOffset, short[] v) { for (int i = 0; i < v.length; i++, byteOffset+=2) { v[i] = bb.getShort(byteOffset); } - return v; + return v; } public final void setIntsAt(int byteOffset, int[] v) { diff --git a/src/java/com/jogamp/common/os/AndroidVersion.java b/src/java/com/jogamp/common/os/AndroidVersion.java index d2afbbc..a710310 100644 --- a/src/java/com/jogamp/common/os/AndroidVersion.java +++ b/src/java/com/jogamp/common/os/AndroidVersion.java @@ -34,25 +34,25 @@ import com.jogamp.common.util.ReflectionUtil; public class AndroidVersion { public static final boolean isAvailable; - - /** Development codename, or the string "REL" for official release */ + + /** Development codename, or the string "REL" for official release */ public static final String CODENAME; - + /** internal build value used by the underlying source control. */ public static final String INCREMENTAL; - + /** official build version string */ public static final String RELEASE; - + /** SDK Version number, key to VERSION_CODES */ public static final int SDK_INT; /** SDK Version string */ public static final String SDK_NAME; - + private static final String androidBuildVersion = "android.os.Build$VERSION"; private static final String androidBuildVersionCodes = "android.os.Build$VERSION_CODES"; - + static { final ClassLoader cl = AndroidVersion.class.getClassLoader(); Class> abvClass = null; @@ -65,7 +65,7 @@ public class AndroidVersion { abvcClass = ReflectionUtil.getClass(androidBuildVersionCodes, true, cl); abvcObject = abvcClass.newInstance(); } catch (Exception e) { /* n/a */ } - isAvailable = null != abvObject; + isAvailable = null != abvObject; if(isAvailable) { CODENAME = getString(abvClass, abvObject, "CODENAME"); INCREMENTAL = getString(abvClass, abvObject, "INCREMENTAL"); @@ -73,16 +73,16 @@ public class AndroidVersion { SDK_INT = getInt(abvClass, abvObject, "SDK_INT"); final IntObjectHashMap version_codes = getVersionCodes(abvcClass, abvcObject); final String sdk_name = (String) version_codes.get(SDK_INT); - SDK_NAME = ( null != sdk_name ) ? sdk_name : "SDK_"+SDK_INT ; + SDK_NAME = ( null != sdk_name ) ? sdk_name : "SDK_"+SDK_INT ; } else { CODENAME = null; INCREMENTAL = null; RELEASE = null; - SDK_INT = -1; + SDK_INT = -1; SDK_NAME = null; } } - + private static final IntObjectHashMap getVersionCodes(Class> cls, Object obj) { final Field[] fields = cls.getFields(); IntObjectHashMap map = new IntObjectHashMap( 3 * fields.length / 2, 0.75f ); @@ -93,10 +93,10 @@ public class AndroidVersion { // System.err.println(i+": "+version+": "+version_name); map.put(new Integer(version), version_name); } catch (Exception e) { e.printStackTrace(); /* n/a */ } - } + } return map; } - + private static final String getString(Class> cls, Object obj, String name) { try { Field f = cls.getField(name); @@ -112,6 +112,6 @@ public class AndroidVersion { } catch (Exception e) { e.printStackTrace(); /* n/a */ } return -1; } - + // android.os.Build.VERSION } diff --git a/src/java/com/jogamp/common/os/DynamicLibraryBundle.java b/src/java/com/jogamp/common/os/DynamicLibraryBundle.java index 56387b6..a69fd7a 100644 --- a/src/java/com/jogamp/common/os/DynamicLibraryBundle.java +++ b/src/java/com/jogamp/common/os/DynamicLibraryBundle.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.common.os; import java.util.ArrayList; @@ -43,7 +43,7 @@ import com.jogamp.common.util.RunnableExecutor; * The JNI glue-code native library, eg jogl_desktop.dll. From here on this is referred as the Glue * *- * An {@link DynamicLibraryBundleInfo} instance is being passed in the constructor, + * An {@link DynamicLibraryBundleInfo} instance is being passed in the constructor, * providing the required information about the tool and glue libraries. * The ClassLoader of it's implementation is also being used to help locating the native libraries. *
@@ -65,7 +65,7 @@ public class DynamicLibraryBundle implements DynamicLookupHelper { private final List> toolLibNames; private final List
glueLibNames; private final boolean[] toolLibLoaded; - + private int toolLibLoadedNumber; private final boolean[] glueLibLoaded; @@ -76,15 +76,15 @@ public class DynamicLibraryBundle implements DynamicLookupHelper { private HashSet toolGetProcAddressFuncNameSet; private List toolGetProcAddressFuncNameList; - /** Returns an AWT-EDT {@link RunnableExecutor} implementation if AWT is available, otherwise {@link RunnableExecutor#currentThreadExecutor}. */ + /** Returns an AWT-EDT {@link RunnableExecutor} implementation if AWT is available, otherwise {@link RunnableExecutor#currentThreadExecutor}. */ public static RunnableExecutor getDefaultRunnableExecutor() { return RunnableExecutor.currentThreadExecutor; } - - /** + + /** * Instantiates and loads all {@link NativeLibrary}s incl. JNI libraries. * - * The ClassLoader of the {@link DynamicLibraryBundleInfo} implementation class + * The ClassLoader of the {@link DynamicLibraryBundleInfo} implementation class * is being used to help locating the native libraries. *
*/ @@ -104,12 +104,12 @@ public class DynamicLibraryBundle implements DynamicLookupHelper { if( toolLibNames.size() == 0 ) { System.err.println("No Tool native library names given"); } - + if( glueLibNames.size() == 0 ) { System.err.println("No Glue native library names given"); } } - + for(int i=toolLibNames.size()-1; i>=0; i--) { toolLibLoaded[i] = false; } @@ -117,17 +117,17 @@ public class DynamicLibraryBundle implements DynamicLookupHelper { for(int i=glueLibNames.size()-1; i>=0; i--) { glueLibLoaded[i] = false; } - + info.getLibLoaderExecutor().invoke(true, new Runnable() { - public void run() { + public void run() { loadLibraries(); - } } ) ; - + } } ) ; + toolGetProcAddressFuncNameList = info.getToolGetProcAddressFuncNameList(); if( null != toolGetProcAddressFuncNameList ) { toolGetProcAddressFuncNameSet = new HashSet(toolGetProcAddressFuncNameList); toolGetProcAddressHandle = getToolGetProcAddressHandle(); - toolGetProcAddressComplete = 0 != toolGetProcAddressHandle; + toolGetProcAddressComplete = 0 != toolGetProcAddressHandle; } else { toolGetProcAddressFuncNameSet = new HashSet (); toolGetProcAddressHandle = 0; @@ -144,7 +144,7 @@ public class DynamicLibraryBundle implements DynamicLookupHelper { System.err.println(" LibLoaderExecutor: "+info.getLibLoaderExecutor().getClass().getName()); } } - + /** Unload all {@link NativeLibrary}s, and remove all references. */ public final void destroy() { if(DEBUG) { @@ -179,7 +179,7 @@ public class DynamicLibraryBundle implements DynamicLookupHelper { /** * @return true if all tool libraries are loaded, * otherwise false. - * + * * @see DynamicLibraryBundleInfo#getToolLibNames() */ public final boolean isToolLibComplete() { @@ -207,9 +207,9 @@ public class DynamicLibraryBundle implements DynamicLookupHelper { /** * @return true if the last entry has been loaded, - * while ignoring the preload dependencies. + * while ignoring the preload dependencies. * Otherwise false. - * + * * @see DynamicLibraryBundleInfo#getGlueLibNames() */ public final boolean isGlueLibComplete() { @@ -241,7 +241,7 @@ public class DynamicLibraryBundle implements DynamicLookupHelper { } protected final NativeLibrary loadFirstAvailable(List libNames, ClassLoader loader, boolean global) { - for (int i=0; i < libNames.size(); i++) { + for (int i=0; i < libNames.size(); i++) { final NativeLibrary lib = NativeLibrary.open(libNames.get(i), loader, global); if (lib != null) { return lib; @@ -256,7 +256,7 @@ public class DynamicLibraryBundle implements DynamicLookupHelper { final ClassLoader cl = info.getClass().getClassLoader(); NativeLibrary lib = null; - for (i=0; i < toolLibNames.size(); i++) { + for (i=0; i < toolLibNames.size(); i++) { final List libNames = toolLibNames.get(i); if( null != libNames && libNames.size() > 0 ) { lib = loadFirstAvailable(libNames, cl, info.shallLinkGlobal()); @@ -282,7 +282,7 @@ public class DynamicLibraryBundle implements DynamicLookupHelper { } glueLibLoadedNumber = 0; - for (i=0; i < glueLibNames.size(); i++) { + for (i=0; i < glueLibNames.size(); i++) { final String libName = glueLibNames.get(i); boolean ignoreError = true; boolean res; @@ -304,7 +304,7 @@ public class DynamicLibraryBundle implements DynamicLookupHelper { } } } - + private final long dynamicLookupFunctionOnLibs(String funcName) { if(!isToolLibLoaded() || null==funcName) { if(DEBUG_LOOKUP && !isToolLibLoaded()) { @@ -347,7 +347,7 @@ public class DynamicLibraryBundle implements DynamicLookupHelper { } return 0; } - + @Override public final long dynamicLookupFunction(String funcName) { if(!isToolLibLoaded() || null==funcName) { @@ -371,11 +371,11 @@ public class DynamicLibraryBundle implements DynamicLookupHelper { addr = dynamicLookupFunctionOnLibs(funcName); } if(0==addr && !useToolGetProcAdressFirst) { - addr = toolDynamicLookupFunction(funcName); + addr = toolDynamicLookupFunction(funcName); } return addr; } - + @Override public final boolean isFunctionAvailable(String funcName) { return 0 != dynamicLookupFunction(funcName); diff --git a/src/java/com/jogamp/common/os/DynamicLibraryBundleInfo.java b/src/java/com/jogamp/common/os/DynamicLibraryBundleInfo.java index ef44298..7be5f25 100644 --- a/src/java/com/jogamp/common/os/DynamicLibraryBundleInfo.java +++ b/src/java/com/jogamp/common/os/DynamicLibraryBundleInfo.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.common.os; import java.util.List; @@ -36,10 +36,10 @@ import com.jogamp.common.util.RunnableExecutor; public interface DynamicLibraryBundleInfo { public static final boolean DEBUG = DynamicLibraryBundle.DEBUG; - /** + /** * If a {@link SecurityManager} is installed, user needs link permissions * for the named libraries. - * + * * @return a list of Tool library names or alternative library name lists.
**
- GL/GLU example Unix: [ [ "libGL.so.1", "libGL.so", "GL" ], [ "libGLU.so", "GLU" ] ]
@@ -49,10 +49,10 @@ public interface DynamicLibraryBundleInfo { */ public List> getToolLibNames(); - /** + /** * If a {@link SecurityManager} is installed, user needs link permissions * for the named libraries. - * + * * @return a list of Glue library names.
**
* @param pollPeriod - * @param portNumber to be used for this single instance server socket. + * @param portNumber to be used for this single instance server socket. */ public static SingletonInstance createServerSocket(long poll_ms, int portNumber) { return new SingletonInstanceServerSocket(poll_ms, portNumber); } - + protected SingletonInstance(long poll_ms) { this.poll_ms = Math.max(10, poll_ms); } - + public final long getPollPeriod() { return poll_ms; } public abstract String getName(); @Override public final String toString() { return getName(); } - + @Override public synchronized void lock() throws RuntimeException { try { @@ -99,7 +99,7 @@ public abstract class SingletonInstance implements Lock { if( DEBUG ) { final long t2 = System.currentTimeMillis(); System.err.println(infoPrefix(t2)+" +++ "+getName()+" - Locked within "+(t2-t0)+" ms, "+(i+1)+" attempts"); - } + } return true; } if( DEBUG && 0==i ) { @@ -118,9 +118,9 @@ public abstract class SingletonInstance implements Lock { System.err.println(infoPrefix(t2)+" +++ EEE (2) "+getName()+" - couldn't get lock within "+(t2-t0)+" ms, "+i+" attempts"); } return false; - } + } protected abstract boolean tryLockImpl(); - + @Override public void unlock() throws RuntimeException { final long t0 = System.currentTimeMillis(); @@ -145,7 +145,7 @@ public abstract class SingletonInstance implements Lock { protected String infoPrefix() { return infoPrefix(System.currentTimeMillis()); } - + private final long poll_ms; private boolean locked = false; } diff --git a/src/java/com/jogamp/common/util/locks/ThreadLock.java b/src/java/com/jogamp/common/util/locks/ThreadLock.java index 65260bc..26e7475 100644 --- a/src/java/com/jogamp/common/util/locks/ThreadLock.java +++ b/src/java/com/jogamp/common/util/locks/ThreadLock.java @@ -33,27 +33,27 @@ package com.jogamp.common.util.locks; */ public interface ThreadLock extends Lock { - /** Query whether the lock is hold by the a thread other than the current thread. */ + /** Query whether the lock is hold by the a thread other than the current thread. */ boolean isLockedByOtherThread(); - /** Query whether the lock is hold by the given thread. */ + /** Query whether the lock is hold by the given thread. */ boolean isOwner(Thread thread); - + /** * @return the Thread owning this lock if locked, otherwise null */ Thread getOwner(); /** - * @throws RuntimeException if current thread does not hold the lock + * @throws RuntimeException if current thread does not hold the lock */ void validateLocked() throws RuntimeException; - + /** * Execute the {@link Runnable Runnable taskAfterUnlockBeforeNotify} while holding the exclusive lock. *- GL: [ "nativewindow_x11", "jogl_gl2es12", "jogl_desktop" ]
@@ -64,15 +64,15 @@ public interface DynamicLibraryBundleInfo { */ public ListgetGlueLibNames(); - /** + /** * May return the native libraries GetProcAddressFuncnames, the first found function is being used.
* This could be eg:glXGetProcAddressARB, glXGetProcAddressARB.
* If your Tool does not has this facility, just return null. * @see #toolGetProcAddress(long, String) */ - public ListgetToolGetProcAddressFuncNameList() ; + public List getToolGetProcAddressFuncNameList() ; - /** + /** * May implement the lookup function using the Tools facility.
* The actual function pointer is provided to allow proper bootstrapping of the ProcAddressTable, * using one of the provided function names by {@link #getToolGetProcAddressFuncNameList()}.
@@ -81,7 +81,7 @@ public interface DynamicLibraryBundleInfo { /** * @param funcName - * @return true if {@link #toolGetProcAddress(long, String)} shall be tried before + * @return true if {@link #toolGetProcAddress(long, String)} shall be tried before * the system loader for the given function lookup. Otherwise false. * Default is true. */ @@ -90,20 +90,20 @@ public interface DynamicLibraryBundleInfo { /** @return true if the native library symbols shall be made available for symbol resolution of subsequently loaded libraries. */ public boolean shallLinkGlobal(); - /** + /** * If method returnstrue
and if a {@link SecurityManager} is installed, user needs link permissions * for all libraries, i.e. fornew RuntimePermission("loadLibrary.*");
! - * - * @return true if the dynamic symbol lookup shall happen system wide, over all loaded libraries. - * Otherwise only the loaded native libraries are used for lookup, which shall be the default. + * + * @return true if the dynamic symbol lookup shall happen system wide, over all loaded libraries. + * Otherwise only the loaded native libraries are used for lookup, which shall be the default. */ public boolean shallLookupGlobal(); - + /** - * Returns a suitable {@link RunnableExecutor} implementation, which is being used + * Returns a suitable {@link RunnableExecutor} implementation, which is being used * to load thetool
andglue
native libraries. *- * This allows the generic {@link DynamicLibraryBundle} implementation to + * This allows the generic {@link DynamicLibraryBundle} implementation to * load the native libraries on a designated thread. *
*diff --git a/src/java/com/jogamp/common/os/DynamicLinker.java b/src/java/com/jogamp/common/os/DynamicLinker.java index ed52413..3b1ec3f 100644 --- a/src/java/com/jogamp/common/os/DynamicLinker.java +++ b/src/java/com/jogamp/common/os/DynamicLinker.java @@ -39,10 +39,10 @@ public interface DynamicLinker { *
* Opens the named library, allowing system wide access for other users. *
- * + * * @param pathname the full pathname for the library to open * @param debug set to true to enable debugging - * @return the library handle, maybe 0 if not found. + * @return the library handle, maybe 0 if not found. * @throws SecurityException if user is not granted access for the named library. */ public long openLibraryGlobal(String pathname, boolean debug) throws SecurityException; @@ -53,50 +53,50 @@ public interface DynamicLinker { ** Opens the named library, restricting access to this process. *
- * + * * @param pathname the full pathname for the library to open * @param debug set to true to enable debugging - * @return the library handle, maybe 0 if not found. + * @return the library handle, maybe 0 if not found. * @throws SecurityException if user is not granted access for the named library. */ public long openLibraryLocal(String pathname, boolean debug) throws SecurityException; - + /** * If a {@link SecurityManager} is installed, user needs link permissions * for all libraries, i.e. fornew RuntimePermission("loadLibrary.*");
! - * + * * @param symbolName global symbol name to lookup up system wide. - * @return the library handle, maybe 0 if not found. + * @return the library handle, maybe 0 if not found. * @throws SecurityException if user is not granted access for all libraries. */ public long lookupSymbolGlobal(String symbolName) throws SecurityException; - + /** - * Security checks are implicit by previous call of + * Security checks are implicit by previous call of * {@link #openLibraryLocal(String, boolean)} or {@link #openLibraryGlobal(String, boolean)} * retrieving thelibrarHandle
. - * + * * @param libraryHandle a library handle previously retrieved via {@link #openLibraryLocal(String, boolean)} or {@link #openLibraryGlobal(String, boolean)}. * @param symbolName global symbol name to lookup up system wide. - * @return the library handle, maybe 0 if not found. + * @return the library handle, maybe 0 if not found. * @throws IllegalArgumentException in case caselibraryHandle
is unknown. */ public long lookupSymbol(long libraryHandle, String symbolName) throws IllegalArgumentException; - + /** - * Security checks are implicit by previous call of + * Security checks are implicit by previous call of * {@link #openLibraryLocal(String, boolean)} or {@link #openLibraryGlobal(String, boolean)} * retrieving thelibrarHandle
. - * + * * @param libraryHandle a library handle previously retrieved via {@link #openLibraryLocal(String, boolean)} or {@link #openLibraryGlobal(String, boolean)}. * @throws IllegalArgumentException in case caselibraryHandle
is unknown. */ public void closeLibrary(long libraryHandle) throws IllegalArgumentException; - + /** - * Returns a string containing the last error. - * Maybe called for debuging purposed if any method fails. - * @return error string, maybe null. A null or non-null value has no semantics. + * Returns a string containing the last error. + * Maybe called for debuging purposed if any method fails. + * @return error string, maybe null. A null or non-null value has no semantics. */ public String getLastError(); } diff --git a/src/java/com/jogamp/common/os/DynamicLookupHelper.java b/src/java/com/jogamp/common/os/DynamicLookupHelper.java index 94a7e92..0f87351 100644 --- a/src/java/com/jogamp/common/os/DynamicLookupHelper.java +++ b/src/java/com/jogamp/common/os/DynamicLookupHelper.java @@ -1,21 +1,21 @@ /* * 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 @@ -28,11 +28,11 @@ * 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. */ @@ -41,7 +41,7 @@ package com.jogamp.common.os; import jogamp.common.Debug; -/** Interface callers may use ProcAddressHelper's +/** Interface callers may use ProcAddressHelper's * {@link com.jogamp.gluegen.runtime.ProcAddressTable#reset(com.jogamp.common.os.DynamicLookupHelper) reset} * helper method to install function pointers into a * ProcAddressTable. This must typically be written with native @@ -49,12 +49,12 @@ import jogamp.common.Debug; public interface DynamicLookupHelper { public static final boolean DEBUG = Debug.debug("NativeLibrary"); public static final boolean DEBUG_LOOKUP = Debug.debug("NativeLibrary.Lookup"); - + /** * Returns the function handle for function 'funcName'. */ public long dynamicLookupFunction(String funcName); - + /** * Queries whether function 'funcName' is available. */ diff --git a/src/java/com/jogamp/common/os/MachineDescription.java b/src/java/com/jogamp/common/os/MachineDescription.java index ab0885e..aea9de1 100644 --- a/src/java/com/jogamp/common/os/MachineDescription.java +++ b/src/java/com/jogamp/common/os/MachineDescription.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: - * + * * - Redistribution of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * - Redistribution in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * + * * Neither the name of Sun Microsystems, Inc. or the names of * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. - * + * * This software is provided "AS IS," without a warranty of any kind. ALL * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A @@ -29,11 +29,11 @@ * 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. */ @@ -61,14 +61,14 @@ public class MachineDescription { X86_64_WINDOWS(Platform.CPUType.X86_64), /** {@link Platform.CPUType#SPARC_32} Big Endian Solaris */ SPARC_32_SUNOS(Platform.CPUType.SPARC_32); - + public final Platform.CPUType cpu; ID(Platform.CPUType cpu){ this.cpu = cpu; } - } - + } + /* arch os int, long, float, doubl, ldoubl, ptr, page */ private final static int[] size_armeabi = { 4, 4, 4, 8, 8, 4, 4096 }; private final static int[] size_x86_32_unix = { 4, 4, 4, 8, 12, 4, 4096 }; @@ -78,7 +78,7 @@ public class MachineDescription { private final static int[] size_x86_64_windows = { 4, 4, 4, 8, 16, 8, 4096 }; private final static int[] size_sparc_32_sunos = { 4, 4, 4, 8, 16, 4, 8192 }; - /* arch os i8, i16, i32, i64, int, long, float, doubl, ldoubl, ptr */ + /* arch os i8, i16, i32, i64, int, long, float, doubl, ldoubl, ptr */ private final static int[] align_armeabi = { 1, 2, 4, 8, 4, 4, 4, 8, 8, 4 }; private final static int[] align_x86_32_unix = { 1, 2, 4, 4, 4, 4, 4, 4, 4, 4 }; private final static int[] align_x86_32_macos = { 1, 2, 4, 4, 4, 4, 4, 4, 16, 4 }; @@ -86,7 +86,7 @@ public class MachineDescription { private final static int[] align_x86_64_unix = { 1, 2, 4, 8, 4, 8, 4, 8, 16, 8 }; private final static int[] align_x86_64_windows = { 1, 2, 4, 8, 4, 4, 4, 8, 16, 8 }; private final static int[] align_sparc_32_sunos = { 1, 2, 4, 8, 4, 4, 4, 8, 8, 4 }; - + public enum StaticConfig { /** {@link MachineDescription.ID#ARMle_EABI } */ ARMle_EABI(ID.ARMle_EABI, true, size_armeabi, align_armeabi), @@ -102,10 +102,10 @@ public class MachineDescription { X86_64_WINDOWS(ID.X86_64_WINDOWS, true, size_x86_64_windows, align_x86_64_windows), /** {@link MachineDescription.ID#SPARC_32_SUNOS } */ SPARC_32_SUNOS(ID.SPARC_32_SUNOS, false, size_sparc_32_sunos, align_sparc_32_sunos); - - public final ID id; + + public final ID id; public final MachineDescription md; - + StaticConfig(ID id, boolean littleEndian, int[] sizes, int[] alignments) { this.id = id; int i=0, j=0; @@ -128,7 +128,7 @@ public class MachineDescription { alignments[j++], alignments[j++]); } - + public StringBuilder toString(StringBuilder sb) { if(null==sb) { sb = new StringBuilder(); @@ -137,23 +137,23 @@ public class MachineDescription { md.toString(sb); return sb; } - + @Override public String toString() { return toString(null).toString(); } } - + final private boolean runtimeValidated; - + final private boolean littleEndian; - + final private int int8SizeInBytes = 1; final private int int16SizeInBytes = 2; final private int int32SizeInBytes = 4; final private int int64SizeInBytes = 8; - + final private int intSizeInBytes; final private int longSizeInBytes; final private int floatSizeInBytes; @@ -162,7 +162,7 @@ public class MachineDescription { final private int pointerSizeInBytes; final private int pageSizeInBytes; final private boolean is32Bit; - + final private int int8AlignmentInBytes; final private int int16AlignmentInBytes; final private int int32AlignmentInBytes; @@ -176,7 +176,7 @@ public class MachineDescription { public MachineDescription(boolean runtimeValidated, boolean littleEndian, - + int intSizeInBytes, int longSizeInBytes, int floatSizeInBytes, @@ -184,7 +184,7 @@ public class MachineDescription { int ldoubleSizeInBytes, int pointerSizeInBytes, int pageSizeInBytes, - + int int8AlignmentInBytes, int int16AlignmentInBytes, int int32AlignmentInBytes, @@ -195,16 +195,16 @@ public class MachineDescription { int doubleAlignmentInBytes, int ldoubleAlignmentInBytes, int pointerAlignmentInBytes) { - this.runtimeValidated = runtimeValidated; + this.runtimeValidated = runtimeValidated; this.littleEndian = littleEndian; - + this.intSizeInBytes = intSizeInBytes; this.longSizeInBytes = longSizeInBytes; this.floatSizeInBytes = floatSizeInBytes; this.doubleSizeInBytes = doubleSizeInBytes; this.ldoubleSizeInBytes = ldoubleSizeInBytes; this.pointerSizeInBytes = pointerSizeInBytes; - this.pageSizeInBytes = pageSizeInBytes; + this.pageSizeInBytes = pageSizeInBytes; this.is32Bit = 4 == pointerSizeInBytes; this.int8AlignmentInBytes = int8AlignmentInBytes; @@ -218,14 +218,14 @@ public class MachineDescription { this.ldoubleAlignmentInBytes = ldoubleAlignmentInBytes; this.pointerAlignmentInBytes = pointerAlignmentInBytes; } - + /** * @return true if all values are validated at runtime, otherwise false (i.e. for static compilation w/ preset values) */ public final boolean isRuntimeValidated() { return runtimeValidated; } - + /** * Returns true only if this system uses little endian byte ordering. */ @@ -246,7 +246,7 @@ public class MachineDescription { public final boolean is64Bit() { return !is32Bit; } - + public final int intSizeInBytes() { return intSizeInBytes; } public final int longSizeInBytes() { return longSizeInBytes; } public final int int8SizeInBytes() { return int8SizeInBytes; } @@ -258,7 +258,7 @@ public class MachineDescription { public final int ldoubleSizeInBytes() { return ldoubleSizeInBytes; } public final int pointerSizeInBytes() { return pointerSizeInBytes; } public final int pageSizeInBytes() { return pageSizeInBytes; } - + public final int intAlignmentInBytes() { return intAlignmentInBytes; } public final int longAlignmentInBytes() { return longAlignmentInBytes; } public final int int8AlignmentInBytes() { return int8AlignmentInBytes; } @@ -269,20 +269,20 @@ public class MachineDescription { public final int doubleAlignmentInBytes() { return doubleAlignmentInBytes; } public final int ldoubleAlignmentInBytes() { return ldoubleAlignmentInBytes; } public final int pointerAlignmentInBytes() { return pointerAlignmentInBytes; } - + /** * @return number of pages required for size in bytes */ public int pageCount(int size) { return ( size + ( pageSizeInBytes - 1) ) / pageSizeInBytes ; // integer arithmetic } - + /** * @return page aligned size in bytes */ public int pageAlignedSize(int size) { return pageCount(size) * pageSizeInBytes; - } + } /** * Checks whether two size objects are equal. Two instances @@ -294,7 +294,7 @@ public class MachineDescription { public final boolean equals(Object obj) { if (this == obj) { return true; } if ( !(obj instanceof MachineDescription) ) { return false; } - final MachineDescription md = (MachineDescription) obj; + final MachineDescription md = (MachineDescription) obj; return pageSizeInBytes == md.pageSizeInBytes && compatible(md); @@ -309,7 +309,7 @@ public class MachineDescription { */ public final boolean compatible(MachineDescription md) { return littleEndian == md.littleEndian && - + intSizeInBytes == md.intSizeInBytes && longSizeInBytes == md.longSizeInBytes && floatSizeInBytes == md.floatSizeInBytes && @@ -317,7 +317,7 @@ public class MachineDescription { ldoubleSizeInBytes == md.ldoubleSizeInBytes && pointerSizeInBytes == md.pointerSizeInBytes && is32Bit == md.is32Bit && - + int8AlignmentInBytes == md.int8AlignmentInBytes && int16AlignmentInBytes == md.int16AlignmentInBytes && int32AlignmentInBytes == md.int32AlignmentInBytes && @@ -329,7 +329,7 @@ public class MachineDescription { ldoubleAlignmentInBytes == md.ldoubleAlignmentInBytes && pointerAlignmentInBytes == md.pointerAlignmentInBytes ; } - + public StringBuilder toString(StringBuilder sb) { if(null==sb) { sb = new StringBuilder(); @@ -345,13 +345,13 @@ public class MachineDescription { sb.append(", double ").append(doubleSizeInBytes) .append(" / ").append(doubleAlignmentInBytes); sb.append(", ldouble ").append(ldoubleSizeInBytes).append(" / ").append(ldoubleAlignmentInBytes).append(Platform.getNewline()); sb.append(" pointer ").append(pointerSizeInBytes).append(" / ").append(pointerAlignmentInBytes); - sb.append(", page ").append(pageSizeInBytes); + sb.append(", page ").append(pageSizeInBytes); return sb; } - + @Override public String toString() { return toString(null).toString(); } - + } diff --git a/src/java/com/jogamp/common/os/NativeLibrary.java b/src/java/com/jogamp/common/os/NativeLibrary.java index 3d81479..df59611 100644 --- a/src/java/com/jogamp/common/os/NativeLibrary.java +++ b/src/java/com/jogamp/common/os/NativeLibrary.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2011 JogAmp Community. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: - * + * * - Redistribution of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * - Redistribution in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * + * * Neither the name of Sun Microsystems, Inc. or the names of * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. - * + * * This software is provided "AS IS," without a warranty of any kind. ALL * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A @@ -29,11 +29,11 @@ * 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. */ @@ -72,7 +72,7 @@ import com.jogamp.common.util.cache.TempJarCache; ProcAddressTable glue code generation style without additional supporting code needed in the generated library. */ -public final class NativeLibrary implements DynamicLookupHelper { +public final class NativeLibrary implements DynamicLookupHelper { private static final DynamicLinker dynLink; private static final String[] prefixes; private static final String[] suffixes; @@ -85,7 +85,7 @@ public final class NativeLibrary implements DynamicLookupHelper { prefixes = new String[] { "" }; suffixes = new String[] { ".dll" }; break; - + case MACOS: dynLink = new MacOSXDynamicLinkerImpl(); prefixes = new String[] { "lib" }; @@ -97,12 +97,12 @@ public final class NativeLibrary implements DynamicLookupHelper { prefixes = new String[] { "lib" }; suffixes = new String[] { ".so" }; break; - + /* case FREEBSD: case SUNOS: - case HPUX: - case OPENKODE: + case HPUX: + case OPENKODE: case LINUX: */ default: dynLink = new PosixDynamicLinkerImpl(); @@ -119,7 +119,7 @@ public final class NativeLibrary implements DynamicLookupHelper { // May as well keep around the path to the library we opened private final String libraryPath; - + private final boolean global; // Private constructor to prevent arbitrary instances from floating around @@ -218,7 +218,7 @@ public final class NativeLibrary implements DynamicLookupHelper { if( null != t ) { t.printStackTrace(); } - } + } } if (DEBUG) { @@ -290,10 +290,10 @@ public final class NativeLibrary implements DynamicLookupHelper { /** * Comparison of prefix and suffix of the given libName's basename * is performed case insensitive
- * - * @param libName the full path library name with prefix and suffix + * + * @param libName the full path library name with prefix and suffix * @param isLowerCaseAlready indicates if libName is already lower-case - * + * * @return basename of libName w/o path, ie. /usr/lib/libDrinkBeer.so -> DrinkBeer on Unix systems, but null on Windows. */ public static final String isValidNativeLibraryName(String libName, boolean isLowerCaseAlready) { @@ -305,7 +305,7 @@ public final class NativeLibrary implements DynamicLookupHelper { } final String libBaseNameLC = isLowerCaseAlready ? libBaseName : libBaseName.toLowerCase(); int prefixIdx = -1; - for(int i=0; iprefixIdx; i++) { + for(int i=0; i prefixIdx; i++) { if (libBaseNameLC.startsWith(prefixes[i])) { prefixIdx = i; } @@ -319,9 +319,9 @@ public final class NativeLibrary implements DynamicLookupHelper { } } } - return null; + return null; } - + /** 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. */ @@ -377,7 +377,7 @@ public final class NativeLibrary implements DynamicLookupHelper { if (searchSystemPathFirst) { if(null != sysPath) { res[i++] = sysPath; - } + } } if(null != usrPath) { res[i++] = usrPath; @@ -385,7 +385,7 @@ public final class NativeLibrary implements DynamicLookupHelper { if (!searchSystemPathFirst) { if(null != sysPath) { res[i++] = sysPath; - } + } } return res; } @@ -422,7 +422,7 @@ public final class NativeLibrary implements DynamicLookupHelper { // Add current location addPaths("/System/Library/Frameworks/" + libName + ".Framework", baseNames, paths); } - + return paths; } @@ -433,7 +433,7 @@ public final class NativeLibrary implements DynamicLookupHelper { switch (PlatformPropsImpl.OS_TYPE) { case WINDOWS: return windowsLibName; - + case MACOS: return macOSXLibName; @@ -441,8 +441,8 @@ public final class NativeLibrary implements DynamicLookupHelper { case FREEBSD: case DALVIK: case SUNOS: - case HPUX: - case OPENKODE: + case HPUX: + case OPENKODE: case LINUX: */ default: return unixLibName; @@ -459,9 +459,9 @@ public final class NativeLibrary implements DynamicLookupHelper { } catch (URISyntaxException uriEx) { throw new IllegalArgumentException(uriEx); } - + int prefixIdx = -1; - for(int i=0; i prefixIdx; i++) { + for(int i=0; i prefixIdx; i++) { if (libBaseNameLC.startsWith(prefixes[i])) { prefixIdx = i; } @@ -494,7 +494,7 @@ public final class NativeLibrary implements DynamicLookupHelper { } } - String[] res = new String[prefixes.length * suffixes.length + + String[] res = new String[prefixes.length * suffixes.length + ( PlatformPropsImpl.OS_TYPE == Platform.OSType.MACOS ? 1 : 0 )]; int idx = 0; for (int i = 0; i < prefixes.length; i++) { diff --git a/src/java/com/jogamp/common/os/Platform.java b/src/java/com/jogamp/common/os/Platform.java index a01a4b4..896ea56 100644 --- a/src/java/com/jogamp/common/os/Platform.java +++ b/src/java/com/jogamp/common/os/Platform.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.common.os; import java.net.URI; @@ -48,7 +48,7 @@ import jogamp.common.os.PlatformPropsImpl; * Utility class for querying platform specific properties. * * Some field declarations and it's static initialization has been delegated - * to it's super class {@link PlatformPropsImpl} to solve + * to it's super class {@link PlatformPropsImpl} to solve * static initialization interdependencies w/ the GlueGen native library loading * and it's derived information {@link #getMachineDescription()}, {@link #is32Bit()}, ..
*/ public class Platform extends PlatformPropsImpl { - + public enum OSType { - LINUX(0), FREEBSD(1), ANDROID(2), MACOS(3), SUNOS(4), HPUX(5), WINDOWS(6), OPENKODE(7); - + LINUX(0), FREEBSD(1), ANDROID(2), MACOS(3), SUNOS(4), HPUX(5), WINDOWS(6), OPENKODE(7); + public final int id; OSType(int id){ this.id = id; } } - + public enum CPUFamily { /** AMD/Intel */ - X86( 0x00000000), + X86( 0x00000000), /** ARM */ ARM( 0x00010000), /** Power PC */ @@ -79,17 +79,17 @@ public class Platform extends PlatformPropsImpl { /** PA RISC */ PA_RISC(0xFFFF0000), /** Itanium */ - IA64( 0xFFFF1000); - + IA64( 0xFFFF1000); + public final int id; CPUFamily(int id){ this.id = id; } } - + public enum CPUType { - /** X86 32bit */ + /** X86 32bit */ X86_32( CPUFamily.X86, 0x0001), /** X86 64bit */ X86_64( CPUFamily.X86, 0x0002), @@ -111,72 +111,72 @@ public class Platform extends PlatformPropsImpl { IA64( CPUFamily.IA64, 0x0000), /** PA_RISC2_0 */ PA_RISC2_0(CPUFamily.PA_RISC, 0x0001); - + public final int id; public final CPUFamily family; - + CPUType(CPUFamily type, int id){ this.family = type; this.id = id; } - + public CPUFamily getFamily() { return family; } - } - + } + public enum ABIType { - GENERIC_ABI ( 0x0000 ), - /** ARM GNU-EABI ARMEL -mfloat-abi=softfp */ + GENERIC_ABI ( 0x0000 ), + /** ARM GNU-EABI ARMEL -mfloat-abi=softfp */ EABI_GNU_ARMEL ( 0x0001 ), - /** ARM GNU-EABI ARMHF -mfloat-abi=hard */ + /** ARM GNU-EABI ARMHF -mfloat-abi=hard */ EABI_GNU_ARMHF ( 0x0002 ); - + public final int id; - + ABIType(int id){ this.id = id; - } + } } - + private static final String useTempJarCachePropName = "jogamp.gluegen.UseTempJarCache"; - + /** fixed basename of JAR file and native library */ - private static final String libBaseName = "gluegen-rt"; - + private static final String libBaseName = "gluegen-rt"; + // // static initialization order: // - + /** - * System property: 'jogamp.gluegen.UseTempJarCache', + * System property: 'jogamp.gluegen.UseTempJarCache', * defaults to true if {@link #OS_TYPE} is not {@link OSType#ANDROID}. */ public static final boolean USE_TEMP_JAR_CACHE; - + // // post loading native lib: // - + private static final MachineDescription machineDescription; - + private static final boolean is32Bit; - + /**
* This mechanism is preferred in this case to avoid synchronization and locking @@ -56,20 +56,20 @@ import jogamp.common.os.PlatformPropsImpl; *true
if AWT is available and not in headless mode, otherwisefalse
. */ public static final boolean AWT_AVAILABLE; - + private static final boolean isRunningFromJarURL; - + static { final boolean[] _isRunningFromJarURL = new boolean[] { false }; final boolean[] _USE_TEMP_JAR_CACHE = new boolean[] { false }; final boolean[] _AWT_AVAILABLE = new boolean[] { false }; - - AccessController.doPrivileged(new PrivilegedAction* Then release the lock. - *
+ * */ - void unlock(Runnable taskAfterUnlockBeforeNotify); + void unlock(Runnable taskAfterUnlockBeforeNotify); } -- cgit v1.2.3