aboutsummaryrefslogtreecommitdiffstats
path: root/src/java
diff options
context:
space:
mode:
authorMichael Bien <[email protected]>2011-04-26 22:20:46 +0200
committerSven Gothel <[email protected]>2011-04-26 22:20:46 +0200
commita07892f07f15c96ca248fc12133748be7058241f (patch)
treecf5747dd3df05ffcc75cda349d8fa38fc4b5958c /src/java
parent245bd152c3f328e5df69d60da975697431fa923b (diff)
refactoring in common.nio public api - removed Int64Buffer
- removed Int64Buffer since it is no longer needed for LongBuffer emulation Signed-off-by: Sven Gothel <[email protected]>
Diffstat (limited to 'src/java')
-rwxr-xr-xsrc/java/com/jogamp/common/nio/Buffers.java17
-rw-r--r--src/java/com/jogamp/common/nio/Int64Buffer.java71
-rwxr-xr-xsrc/java/com/jogamp/common/nio/Int64BufferSE.java70
-rw-r--r--src/java/com/jogamp/gluegen/JavaEmitter.java4
-rw-r--r--src/java/com/jogamp/gluegen/JavaMethodBindingEmitter.java26
-rw-r--r--src/java/com/jogamp/gluegen/JavaType.java16
6 files changed, 20 insertions, 184 deletions
diff --git a/src/java/com/jogamp/common/nio/Buffers.java b/src/java/com/jogamp/common/nio/Buffers.java
index abf6692..ed9323e 100755
--- a/src/java/com/jogamp/common/nio/Buffers.java
+++ b/src/java/com/jogamp/common/nio/Buffers.java
@@ -297,8 +297,6 @@ public class Buffers {
}
if (buf instanceof Buffer) {
return ((Buffer) buf).isDirect();
- } else if (buf instanceof Int64Buffer) {
- return ((Int64Buffer) buf).isDirect();
} else if (buf instanceof PointerBuffer) {
return ((PointerBuffer) buf).isDirect();
}
@@ -324,16 +322,13 @@ public class Buffers {
return pos * SIZEOF_INT;
} else if (buf instanceof ShortBuffer) {
return pos * SIZEOF_SHORT;
- }else if (buf instanceof DoubleBuffer) {
+ } else if (buf instanceof DoubleBuffer) {
return pos * SIZEOF_DOUBLE;
} else if (buf instanceof LongBuffer) {
return pos * SIZEOF_LONG;
} else if (buf instanceof CharBuffer) {
return pos * SIZEOF_CHAR;
}
- } else if (buf instanceof Int64Buffer) {
- Int64Buffer int64Buffer = (Int64Buffer) buf;
- return int64Buffer.position() * Int64Buffer.elementSize();
} else if (buf instanceof PointerBuffer) {
PointerBuffer pointerBuffer = (PointerBuffer) buf;
return pointerBuffer.position() * PointerBuffer.elementSize();
@@ -352,8 +347,6 @@ public class Buffers {
}
if (buf instanceof Buffer) {
return ((Buffer) buf).array();
- } else if (buf instanceof Int64Buffer) {
- return ((Int64Buffer) buf).array();
} else if (buf instanceof PointerBuffer) {
return ((PointerBuffer) buf).array();
}
@@ -381,16 +374,13 @@ public class Buffers {
return (SIZEOF_INT * (((IntBuffer) buf).arrayOffset() + pos));
} else if (buf instanceof ShortBuffer) {
return (SIZEOF_SHORT * (((ShortBuffer) buf).arrayOffset() + pos));
- }else if (buf instanceof DoubleBuffer) {
+ } else if (buf instanceof DoubleBuffer) {
return (SIZEOF_DOUBLE * (((DoubleBuffer) buf).arrayOffset() + pos));
} else if (buf instanceof LongBuffer) {
return (SIZEOF_LONG * (((LongBuffer) buf).arrayOffset() + pos));
} else if (buf instanceof CharBuffer) {
return (SIZEOF_CHAR * (((CharBuffer) buf).arrayOffset() + pos));
}
- } else if (buf instanceof Int64Buffer) {
- Int64Buffer int64Buffer = (Int64Buffer) buf;
- return Int64Buffer.elementSize() * (int64Buffer.arrayOffset() + int64Buffer.position());
} else if (buf instanceof PointerBuffer) {
PointerBuffer pointerBuffer = (PointerBuffer) buf;
return PointerBuffer.elementSize() * (pointerBuffer.arrayOffset() + pointerBuffer.position());
@@ -782,9 +772,6 @@ public class Buffers {
} else if (buffer instanceof CharBuffer) {
bytesRemaining = elementsRemaining * SIZEOF_CHAR;
}
- } else if (buffer instanceof Int64Buffer) {
- Int64Buffer int64Buffer = (Int64Buffer) buffer;
- bytesRemaining = int64Buffer.remaining() * Int64Buffer.elementSize();
} else if (buffer instanceof PointerBuffer) {
PointerBuffer pointerBuffer = (PointerBuffer) buffer;
bytesRemaining = pointerBuffer.remaining() * PointerBuffer.elementSize();
diff --git a/src/java/com/jogamp/common/nio/Int64Buffer.java b/src/java/com/jogamp/common/nio/Int64Buffer.java
deleted file mode 100644
index 968e48d..0000000
--- a/src/java/com/jogamp/common/nio/Int64Buffer.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/**
- * Copyright 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:
- *
- * 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
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * 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.nio;
-
-import java.nio.ByteBuffer;
-
-/**
- * Hardware independent container for native int64_t arrays.
- *
- * The native values (NIO direct ByteBuffer) are always 64bit wide.
- *
- * @author Michael Bien
- * @author Sven Gothel
- */
-public abstract class Int64Buffer extends AbstractLongBuffer<Int64Buffer> {
-
- protected Int64Buffer(ByteBuffer bb) {
- super(bb, elementSize());
- }
-
- public static Int64Buffer allocate(int size) {
- return new Int64BufferSE(ByteBuffer.wrap(new byte[elementSize() * size]));
- }
-
- public static Int64Buffer allocateDirect(int size) {
- return new Int64BufferSE(Buffers.newDirectByteBuffer(elementSize() * size));
- }
-
- public static Int64Buffer wrap(ByteBuffer src) {
- Int64Buffer res = new Int64BufferSE(src);
- res.updateBackup();
- return res;
-
- }
-
- public static int elementSize() {
- return Buffers.SIZEOF_LONG;
- }
-
- @Override
- public String toString() {
- return "Int64Buffer:"+super.toString();
- }
-
-}
diff --git a/src/java/com/jogamp/common/nio/Int64BufferSE.java b/src/java/com/jogamp/common/nio/Int64BufferSE.java
deleted file mode 100755
index 4c410b4..0000000
--- a/src/java/com/jogamp/common/nio/Int64BufferSE.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * 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
- * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
- * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
- * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
- * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
- * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
- * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
- * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
- * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
- * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- *
- * You acknowledge that this software is not designed or intended for use
- * in the design, construction, operation or maintenance of any nuclear
- * facility.
- */
-package com.jogamp.common.nio;
-
-import java.nio.*;
-
-/**
- * @author Sven Gothel
- * @author Michael Bien
- */
-final class Int64BufferSE extends Int64Buffer {
-
- private LongBuffer pb;
-
- Int64BufferSE(ByteBuffer bb) {
- super(bb);
-
- this.pb = bb.asLongBuffer();
- }
-
- public final long get(int idx) {
- if (0 > idx || idx >= capacity) {
- throw new IndexOutOfBoundsException();
- }
- return pb.get(idx);
- }
-
- public final Int64BufferSE put(int idx, long v) {
- if (0 > idx || idx >= capacity) {
- throw new IndexOutOfBoundsException();
- }
- backup[idx] = v;
- pb.put(idx, v);
- return this;
- }
-}
diff --git a/src/java/com/jogamp/gluegen/JavaEmitter.java b/src/java/com/jogamp/gluegen/JavaEmitter.java
index 250da79..745176a 100644
--- a/src/java/com/jogamp/gluegen/JavaEmitter.java
+++ b/src/java/com/jogamp/gluegen/JavaEmitter.java
@@ -1844,7 +1844,7 @@ public class JavaEmitter implements GlueEmitter {
if (convertToArrays) {
result = result.replaceJavaArgumentType(i, javaType(ArrayTypes.longArrayClass));
} else {
- result = result.replaceJavaArgumentType(i, JavaType.forNIOInt64BufferClass());
+ result = result.replaceJavaArgumentType(i, JavaType.forNIOLongBufferClass());
}
} else if (t.isCFloatPointerType()) {
arrayPossible = true;
@@ -1880,7 +1880,7 @@ public class JavaEmitter implements GlueEmitter {
} else if (t.isCInt32PointerType()) {
result = result.replaceJavaArgumentType(-1, JavaType.forNIOIntBufferClass());
} else if (t.isCInt64PointerType()) {
- result = result.replaceJavaArgumentType(-1, JavaType.forNIOInt64BufferClass());
+ result = result.replaceJavaArgumentType(-1, JavaType.forNIOLongBufferClass());
} else if (t.isCFloatPointerType()) {
result = result.replaceJavaArgumentType(-1, JavaType.forNIOFloatBufferClass());
} else if (t.isCDoublePointerType()) {
diff --git a/src/java/com/jogamp/gluegen/JavaMethodBindingEmitter.java b/src/java/com/jogamp/gluegen/JavaMethodBindingEmitter.java
index 3bf3dc1..ce1acc2 100644
--- a/src/java/com/jogamp/gluegen/JavaMethodBindingEmitter.java
+++ b/src/java/com/jogamp/gluegen/JavaMethodBindingEmitter.java
@@ -39,12 +39,15 @@
package com.jogamp.gluegen;
-import java.io.*;
-import java.util.*;
+import com.jogamp.gluegen.cgram.HeaderParser;
+import com.jogamp.gluegen.cgram.types.ArrayType;
+import com.jogamp.gluegen.cgram.types.CompoundType;
+import com.jogamp.gluegen.cgram.types.EnumType;
+import com.jogamp.gluegen.cgram.types.PointerType;
+import com.jogamp.gluegen.cgram.types.Type;
+import java.io.PrintWriter;
import java.text.MessageFormat;
-
-import com.jogamp.gluegen.cgram.types.*;
-import com.jogamp.gluegen.cgram.*;
+import java.util.List;
/**
* An emitter that emits only the interface for a Java<->C JNI binding.
@@ -592,7 +595,7 @@ public class JavaMethodBindingEmitter extends FunctionEmitter {
}
if (type.isNIOBuffer()) {
- if(type.isNIOInt64Buffer() || type.isNIOPointerBuffer()) {
+ if(type.isNIOPointerBuffer()) {
if (directNIOOnly) {
writer.print( getArgumentName(i)+ " != null ? " + getArgumentName(i) + ".getBuffer() : null");
} else {
@@ -735,15 +738,14 @@ public class JavaMethodBindingEmitter extends FunctionEmitter {
if (getBinding().getCReturnType().pointerDepth() >= 2) {
if (returnType.isNIOPointerBuffer()) {
writer.println(" return PointerBuffer.wrap(_res);");
- } else if (returnType.isNIOInt64Buffer()) {
- writer.println(" return Int64Buffer.wrap(_res);");
+ } else if (returnType.isNIOLongBuffer()) {
+ writer.println(" return _res.asLongBuffer();");
} else {
throw new RuntimeException("While emitting glue code for " + getName() +
- ": can not legally make pointers opaque to anything but PointerBuffer or Int64Buffer/long");
+ ": can not legally make pointers opaque to anything but PointerBuffer or LongBuffer/long");
}
- } else if (getBinding().getCReturnType().pointerDepth() == 1 &&
- returnType.isNIOInt64Buffer()) {
- writer.println(" return Int64Buffer.wrap(_res);");
+ } else if (getBinding().getCReturnType().pointerDepth() == 1 && returnType.isNIOLongBuffer()) {
+ writer.println(" return _res.asLongBuffer();");
} else {
String returnTypeName = returnType.getName().substring("java.nio.".length());
writer.println(" return _res.as" + returnTypeName + "();");
diff --git a/src/java/com/jogamp/gluegen/JavaType.java b/src/java/com/jogamp/gluegen/JavaType.java
index 9a89203..04d14de 100644
--- a/src/java/com/jogamp/gluegen/JavaType.java
+++ b/src/java/com/jogamp/gluegen/JavaType.java
@@ -70,7 +70,6 @@ public class JavaType {
private static JavaType nioIntBufferType;
private static JavaType nioLongBufferType;
private static JavaType nioPointerBufferType;
- private static JavaType nioInt64BufferType;
private static JavaType nioFloatBufferType;
private static JavaType nioDoubleBufferType;
private static JavaType nioByteBufferArrayType;
@@ -194,12 +193,6 @@ public class JavaType {
return nioLongBufferType;
}
- public static JavaType forNIOInt64BufferClass() {
- if(nioInt64BufferType == null)
- nioInt64BufferType = createForClass(com.jogamp.common.nio.Int64Buffer.class);
- return nioInt64BufferType;
- }
-
public static JavaType forNIOPointerBufferClass() {
if(nioPointerBufferType == null)
nioPointerBufferType = createForClass(com.jogamp.common.nio.PointerBuffer.class);
@@ -338,9 +331,8 @@ public class JavaType {
}
public boolean isNIOBuffer() {
- return clazz != null && ( (java.nio.Buffer.class).isAssignableFrom(clazz) ||
- (com.jogamp.common.nio.PointerBuffer.class).isAssignableFrom(clazz) ||
- (com.jogamp.common.nio.Int64Buffer.class).isAssignableFrom(clazz) ) ;
+ return clazz != null && ( java.nio.Buffer.class.isAssignableFrom(clazz) ||
+ com.jogamp.common.nio.NativeBuffer.class.isAssignableFrom(clazz)) ;
}
public boolean isNIOByteBuffer() {
@@ -359,10 +351,6 @@ public class JavaType {
return (clazz == java.nio.LongBuffer.class);
}
- public boolean isNIOInt64Buffer() {
- return (clazz == com.jogamp.common.nio.Int64Buffer.class);
- }
-
public boolean isNIOPointerBuffer() {
return (clazz == com.jogamp.common.nio.PointerBuffer.class);
}