diff options
author | Michael Bien <[email protected]> | 2011-04-26 22:20:46 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2011-04-26 22:20:46 +0200 |
commit | a07892f07f15c96ca248fc12133748be7058241f (patch) | |
tree | cf5747dd3df05ffcc75cda349d8fa38fc4b5958c /src/java/com/jogamp/common/nio | |
parent | 245bd152c3f328e5df69d60da975697431fa923b (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/com/jogamp/common/nio')
-rwxr-xr-x | src/java/com/jogamp/common/nio/Buffers.java | 17 | ||||
-rw-r--r-- | src/java/com/jogamp/common/nio/Int64Buffer.java | 71 | ||||
-rwxr-xr-x | src/java/com/jogamp/common/nio/Int64BufferSE.java | 70 |
3 files changed, 2 insertions, 156 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; - } -} |