Commit 40c23042 by Per Bothner Committed by Per Bothner

ByteBuffer.java (shiftDown): New helper method.

	* java/nio/ByteBuffer.java (shiftDown):  New helper method.
	* java/nio/natDirectByteBufferImpl.cc (shiftDown):  New implementation.
	* java/nio/ByteBufferImpl.java (compact):  Use new shiftDown method.
	* sava/nio/ByteBufferHelper.java:  Remove redundant 'final' specifiers.
	Pass ByteOrder parameter to most methods, since the underlying
	ByteBuffer's order isn't always what we should use.
	* java/nio/ByteBufferImpl.java:  Pass byte-order various places.
	* java/nio/DirectByteBufferImpl.java:  Likewise.
	Use ByteBufferHelper methods.
	* java/nio/MappedByteBufferImpl.java:  Likewise.
	(compact):  Use shiftDown.
	* java/nio/CharViewBufferImpl.java (<init>):  Pass byte-order.
	(get, put):  Use ByteBufferHelper.
	(compact):  Use new shiftDown method.
	(duplicate(boolean)):  New helper method.
	(duplicate, asReadOnlyBuffer):  Use it.
	(order):  Return endian field.
	* java/nio/DoubleViewBufferImpl.java:  Likewise.
	* java/nio/FloatViewBufferImpl.java:  Likewise.
	* java/nio/IntViewBufferImpl.java:  Likewise.
	* java/nio/LongViewBufferImpl.java:  Likewise.
	* java/nio/ShortViewBufferImpl.java:  Likewise.
	* java/nio/CharViewBufferImpl.java (subsequence):  Redundant test.
	* java/nio/DirectByteBufferImpl.java (shiftDown):  New native method.
	(compact):  Re-implement using shiftDown.

From-SVN: r77501
parent b46b8fb4
2004-02-08 Per Bothner <per@bothner.com>
* java/nio/ByteBuffer.java (shiftDown): New helper method.
* java/nio/natDirectByteBufferImpl.cc (shiftDown): New implementation.
* java/nio/ByteBufferImpl.java (compact): Use new shiftDown method.
* sava/nio/ByteBufferHelper.java: Remove redundant 'final' specifiers.
Pass ByteOrder parameter to most methods, since the underlying
ByteBuffer's order isn't always what we should use.
* java/nio/ByteBufferImpl.java: Pass byte-order various places.
* java/nio/DirectByteBufferImpl.java: Likewise.
Use ByteBufferHelper methods.
* java/nio/MappedByteBufferImpl.java: Likewise.
(compact): Use shiftDown.
* java/nio/CharViewBufferImpl.java (<init>): Pass byte-order.
(get, put): Use ByteBufferHelper.
(compact): Use new shiftDown method.
(duplicate(boolean)): New helper method.
(duplicate, asReadOnlyBuffer): Use it.
(order): Return endian field.
* java/nio/DoubleViewBufferImpl.java: Likewise.
* java/nio/FloatViewBufferImpl.java: Likewise.
* java/nio/IntViewBufferImpl.java: Likewise.
* java/nio/LongViewBufferImpl.java: Likewise.
* java/nio/ShortViewBufferImpl.java: Likewise.
* java/nio/CharViewBufferImpl.java (subsequence): Redundant test.
* java/nio/DirectByteBufferImpl.java (shiftDown): New native method.
(compact): Re-implement using shiftDown.
2004-02-08 Andreas Jaeger <aj@suse.de>
* include/x86_64-signal.h: Fix typo.
......
/* ByteBuffer.java --
Copyright (C) 2002, 2003 Free Software Foundation, Inc.
Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
......@@ -382,8 +382,14 @@ public abstract class ByteBuffer extends Buffer
*/
public abstract ByteBuffer compact ();
void shiftDown (int dst_offset, int src_offset, int count)
{
for (int i = 0; i < count; i++)
put(dst_offset + i, get(src_offset + i));
}
/**
* Tells wether or not this buffer is direct.
* Tells whether or not this buffer is direct.
*/
public abstract boolean isDirect ();
......
/* ByteBufferImpl.java --
Copyright (C) 2002, 2003 Free Software Foundation, Inc.
Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
......@@ -58,32 +58,32 @@ final class ByteBufferImpl extends ByteBuffer
public CharBuffer asCharBuffer ()
{
return new CharViewBufferImpl (this, position (), remaining(), remaining (), 0, -1, isReadOnly ());
return new CharViewBufferImpl (this, position (), remaining(), remaining (), 0, -1, isReadOnly (), order());
}
public ShortBuffer asShortBuffer ()
{
return new ShortViewBufferImpl (this, position (), remaining(), remaining (), 0, -1, isReadOnly ());
return new ShortViewBufferImpl (this, position (), remaining(), remaining (), 0, -1, isReadOnly (), order());
}
public IntBuffer asIntBuffer ()
{
return new IntViewBufferImpl (this, position (), remaining(), remaining (), 0, -1, isReadOnly ());
return new IntViewBufferImpl (this, position (), remaining(), remaining (), 0, -1, isReadOnly (), order());
}
public LongBuffer asLongBuffer ()
{
return new LongViewBufferImpl (this, position (), remaining(), remaining (), 0, -1, isReadOnly ());
return new LongViewBufferImpl (this, position (), remaining(), remaining (), 0, -1, isReadOnly (), order());
}
public FloatBuffer asFloatBuffer ()
{
return new FloatViewBufferImpl (this, position (), remaining(), remaining (), 0, -1, isReadOnly ());
return new FloatViewBufferImpl (this, position (), remaining(), remaining (), 0, -1, isReadOnly (), order());
}
public DoubleBuffer asDoubleBuffer ()
{
return new DoubleViewBufferImpl (this, position (), remaining(), remaining (), 0, -1, isReadOnly ());
return new DoubleViewBufferImpl (this, position (), remaining(), remaining (), 0, -1, isReadOnly (), order());
}
public boolean isReadOnly ()
......@@ -108,15 +108,14 @@ final class ByteBufferImpl extends ByteBuffer
public ByteBuffer compact ()
{
int copied = 0;
while (remaining () > 0)
int pos = position();
if (pos > 0)
{
put (copied, get ());
copied++;
int count = remaining();
shiftDown(0, pos, count);
position(count);
limit(capacity());
}
position (copied);
return this;
}
......@@ -182,121 +181,133 @@ final class ByteBufferImpl extends ByteBuffer
final public char getChar ()
{
return ByteBufferHelper.getChar (this);
return ByteBufferHelper.getChar(this, order());
}
final public ByteBuffer putChar (char value)
{
return ByteBufferHelper.putChar (this, value);
ByteBufferHelper.putChar(this, value, order());
return this;
}
final public char getChar (int index)
{
return ByteBufferHelper.getChar (this, index);
return ByteBufferHelper.getChar(this, index, order());
}
final public ByteBuffer putChar (int index, char value)
{
return ByteBufferHelper.putChar (this, index, value);
ByteBufferHelper.putChar(this, index, value, order());
return this;
}
final public short getShort ()
{
return ByteBufferHelper.getShort (this);
return ByteBufferHelper.getShort(this, order());
}
final public ByteBuffer putShort (short value)
{
return ByteBufferHelper.putShort (this, value);
ByteBufferHelper.putShort(this, value, order());
return this;
}
final public short getShort (int index)
{
return ByteBufferHelper.getShort (this, index);
return ByteBufferHelper.getShort(this, index, order());
}
final public ByteBuffer putShort (int index, short value)
{
return ByteBufferHelper.putShort (this, index, value);
ByteBufferHelper.putShort(this, index, value, order());
return this;
}
final public int getInt ()
{
return ByteBufferHelper.getInt (this);
return ByteBufferHelper.getInt(this, order());
}
final public ByteBuffer putInt (int value)
{
return ByteBufferHelper.putInt (this, value);
ByteBufferHelper.putInt(this, value, order());
return this;
}
final public int getInt (int index)
{
return ByteBufferHelper.getInt (this, index);
return ByteBufferHelper.getInt(this, index, order());
}
final public ByteBuffer putInt (int index, int value)
{
return ByteBufferHelper.putInt (this, index, value);
ByteBufferHelper.putInt(this, index, value, order());
return this;
}
final public long getLong ()
{
return ByteBufferHelper.getLong (this);
return ByteBufferHelper.getLong(this, order());
}
final public ByteBuffer putLong (long value)
{
return ByteBufferHelper.putLong (this, value);
ByteBufferHelper.putLong (this, value, order());
return this;
}
final public long getLong (int index)
{
return ByteBufferHelper.getLong (this, index);
return ByteBufferHelper.getLong (this, index, order());
}
final public ByteBuffer putLong (int index, long value)
{
return ByteBufferHelper.putLong (this, index, value);
ByteBufferHelper.putLong (this, index, value, order());
return this;
}
final public float getFloat ()
{
return ByteBufferHelper.getFloat (this);
return ByteBufferHelper.getFloat (this, order());
}
final public ByteBuffer putFloat (float value)
{
return ByteBufferHelper.putFloat (this, value);
ByteBufferHelper.putFloat (this, value, order());
return this;
}
final public float getFloat (int index)
public final float getFloat (int index)
{
return ByteBufferHelper.getFloat (this, index);
return ByteBufferHelper.getFloat (this, index, order());
}
public final ByteBuffer putFloat (int index, float value)
final public ByteBuffer putFloat (int index, float value)
{
return ByteBufferHelper.putFloat (this, index, value);
ByteBufferHelper.putFloat (this, index, value, order());
return this;
}
final public double getDouble ()
{
return ByteBufferHelper.getDouble (this);
return ByteBufferHelper.getDouble (this, order());
}
final public ByteBuffer putDouble (double value)
{
return ByteBufferHelper.putDouble (this, value);
ByteBufferHelper.putDouble (this, value, order());
return this;
}
final public double getDouble (int index)
{
return ByteBufferHelper.getDouble (this, index);
return ByteBufferHelper.getDouble (this, index, order());
}
final public ByteBuffer putDouble (int index, double value)
{
return ByteBufferHelper.putDouble (this, index, value);
ByteBufferHelper.putDouble (this, index, value, order());
return this;
}
}
/* CharViewBufferImpl.java --
Copyright (C) 2003 Free Software Foundation, Inc.
Copyright (C) 2003, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
......@@ -40,54 +40,47 @@ package java.nio;
class CharViewBufferImpl extends CharBuffer
{
private boolean readOnly;
/** Position in bb (i.e. a byte offset) where this buffer starts. */
private int offset;
private ByteBuffer bb;
private boolean readOnly;
private ByteOrder endian;
public CharViewBufferImpl (ByteBuffer bb, boolean readOnly)
{
super (bb.remaining () >> 1, bb.remaining () >> 1, bb.position (), 0);
this.bb = bb;
this.readOnly = readOnly;
// FIXME: What if this is called from CharByteBufferImpl and ByteBuffer has changed its endianess ?
this.endian = bb.order ();
}
public CharViewBufferImpl (ByteBuffer bb, int offset, int capacity,
int limit, int position, int mark,
boolean readOnly)
int limit, int position, int mark,
boolean readOnly, ByteOrder endian)
{
super (limit >> 1, limit >> 1, position >> 1, mark >> 1);
this.bb = bb;
this.offset = offset;
this.readOnly = readOnly;
// FIXME: What if this is called from CharViewBufferImpl and ByteBuffer has changed its endianess ?
this.endian = bb.order ();
this.endian = endian;
}
public char get ()
{
char result = bb.getChar ((position () << 1) + offset);
position (position () + 1);
int p = position();
char result = ByteBufferHelper.getChar(bb, (p << 1) + offset, endian);
position(p + 1);
return result;
}
public char get (int index)
{
return bb.getChar ((index << 1) + offset);
return ByteBufferHelper.getChar(bb, (index << 1) + offset, endian);
}
public CharBuffer put (char value)
{
bb.putChar ((position () << 1) + offset, value);
position (position () + 1);
int p = position();
ByteBufferHelper.putChar(bb, (p << 1) + offset, value, endian);
position(p + 1);
return this;
}
public CharBuffer put (int index, char value)
{
bb.putChar ((index << 1) + offset, value);
ByteBufferHelper.putChar(bb, (index << 1) + offset, value, endian);
return this;
}
......@@ -95,59 +88,54 @@ class CharViewBufferImpl extends CharBuffer
{
if (position () > 0)
{
// Copy all data from position() to limit() to the beginning of the
// buffer, set position to end of data and limit to capacity
// XXX: This can surely be optimized, for direct and non-direct buffers
int count = limit () - position ();
for (int i = 0; i < count; i++)
{
bb.putChar ((i >> 1) + offset,
bb.getChar (((i + position ()) >> 1) + offset));
}
bb.shiftDown(offset, offset + 2 * position(), 2 * count);
position (count);
limit (capacity ());
}
return this;
}
public CharBuffer duplicate ()
{
// Create a copy of this object that shares its content
// FIXME: mark is not correct
return new CharViewBufferImpl (bb, offset, capacity (), limit (),
position (), -1, isReadOnly ());
}
public CharBuffer slice ()
{
// Create a sliced copy of this object that shares its content.
return new CharViewBufferImpl (bb, (position () >> 1) + offset,
remaining (), remaining (), 0, -1,
isReadOnly ());
remaining (), remaining (), 0, -1,
isReadOnly (), endian);
}
CharBuffer duplicate (boolean readOnly)
{
int pos = position();
reset();
int mark = position();
position(pos);
return new CharViewBufferImpl (bb, offset, capacity(), limit(),
pos, mark, readOnly, endian);
}
public CharBuffer duplicate ()
{
return duplicate(readOnly);
}
public CharBuffer asReadOnlyBuffer ()
{
return duplicate(true);
}
public CharSequence subSequence (int start, int end)
{
if (start < 0
|| start > length ()
|| end < start
|| end > length ())
throw new IndexOutOfBoundsException ();
return new CharViewBufferImpl (bb, array_offset, capacity (), position () + end, position () + start, -1, isReadOnly ());
return new CharViewBufferImpl (bb, array_offset, capacity (),
position () + end, position () + start,
-1, isReadOnly (), endian);
}
public CharBuffer asReadOnlyBuffer ()
{
// Create a copy of this object that shares its content and is read-only
return new CharViewBufferImpl (bb, (position () >> 1) + offset,
remaining (), remaining (), 0, -1, true);
}
public boolean isReadOnly ()
{
return readOnly;
......@@ -160,6 +148,6 @@ class CharViewBufferImpl extends CharBuffer
public ByteOrder order ()
{
return ByteOrder.LITTLE_ENDIAN;
return endian;
}
}
/* DirectByteBufferImpl.java --
Copyright (C) 2003 Free Software Foundation, Inc.
Copyright (C) 2003, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
......@@ -117,18 +117,18 @@ class DirectByteBufferImpl extends ByteBuffer
return this;
}
native void shiftDown (int dst_offset, int src_offset, int count);
public ByteBuffer compact ()
{
// FIXME this can sure be optimized using memcpy()
int copied = 0;
while (remaining () > 0)
int pos = position();
if (pos > 0)
{
put (copied, get ());
copied++;
int count = remaining();
shiftDown(0, pos, count);
position(count);
limit(capacity());
}
position (copied);
return this;
}
......@@ -161,197 +161,163 @@ class DirectByteBufferImpl extends ByteBuffer
public CharBuffer asCharBuffer ()
{
return new CharViewBufferImpl (this, position () + offset, remaining (), remaining (), 0, -1, isReadOnly ());
return new CharViewBufferImpl (this, position (), remaining (), remaining (), 0, -1, isReadOnly (), order());
}
public DoubleBuffer asDoubleBuffer ()
{
return new DoubleViewBufferImpl (this, position () + offset, remaining (), remaining (), 0, -1, isReadOnly ());
return new DoubleViewBufferImpl (this, position (), remaining (), remaining (), 0, -1, isReadOnly (), order());
}
public FloatBuffer asFloatBuffer ()
{
return new FloatViewBufferImpl (this, position () + offset, remaining (), remaining (), 0, -1, isReadOnly ());
return new FloatViewBufferImpl (this, position (), remaining (), remaining (), 0, -1, isReadOnly (), order());
}
public IntBuffer asIntBuffer ()
{
return new IntViewBufferImpl (this, position () + offset, remaining (), remaining (), 0, -1, isReadOnly ());
return new IntViewBufferImpl (this, position (), remaining (), remaining (), 0, -1, isReadOnly (), order());
}
public LongBuffer asLongBuffer ()
{
return new LongViewBufferImpl (this, position () + offset, remaining (), remaining (), 0, -1, isReadOnly ());
return new LongViewBufferImpl (this, position (), remaining (), remaining (), 0, -1, isReadOnly (), order());
}
public ShortBuffer asShortBuffer ()
{
return new ShortViewBufferImpl (this, position () + offset, remaining (), remaining (), 0, -1, isReadOnly ());
return new ShortViewBufferImpl (this, position (), remaining (), remaining (), 0, -1, isReadOnly (), order());
}
final public char getChar ()
{
// FIXME: this handles little endian only
return (char) (((get () & 0xff) << 8)
+ (get () & 0xff));
return ByteBufferHelper.getChar(this, order());
}
final public ByteBuffer putChar (char value)
{
// FIXME: this handles little endian only
put ((byte) ((((int) value) & 0xff00) >> 8));
put ((byte) (((int) value) & 0x00ff));
ByteBufferHelper.putChar(this, value, order());
return this;
}
final public char getChar (int index)
{
// FIXME: this handles little endian only
return (char) (((get (index) & 0xff) << 8)
+ (get (index + 1) & 0xff));
return ByteBufferHelper.getChar(this, index, order());
}
final public ByteBuffer putChar (int index, char value)
{
// FIXME: this handles little endian only
put (index, (byte) ((((int) value) & 0xff00) >> 8));
put (index + 1, (byte) (((int) value) & 0x00ff));
ByteBufferHelper.putChar(this, index, value, order());
return this;
}
final public short getShort ()
{
// FIXME: this handles little endian only
return (short) (((get () & 0xff) << 8)
+ (get () & 0xff));
return ByteBufferHelper.getShort(this, order());
}
final public ByteBuffer putShort (short value)
{
// FIXME: this handles little endian only
put ((byte) ((((int) value) & 0xff00) >> 8));
put ((byte) (((int) value) & 0x00ff));
ByteBufferHelper.putShort(this, value, order());
return this;
}
final public short getShort (int index)
{
// FIXME: this handles little endian only
return (short) (((get (index) & 0xff) << 8)
+ (get (index + 1) & 0xff));
return ByteBufferHelper.getShort(this, index, order());
}
final public ByteBuffer putShort (int index, short value)
{
// FIXME: this handles little endian only
put (index, (byte) ((((int) value) & 0xff00) >> 8));
put (index + 1, (byte) (((int) value) & 0x00ff));
ByteBufferHelper.putShort(this, index, value, order());
return this;
}
final public int getInt ()
{
// FIXME: this handles little endian only
return (int) (((get () & 0xff) << 24)
+ ((get () & 0xff) << 16)
+ ((get () & 0xff) << 8)
+ (get () & 0xff));
return ByteBufferHelper.getInt(this, order());
}
final public ByteBuffer putInt (int value)
{
// FIXME: this handles little endian only
put ((byte) ((((int) value) & 0xff000000) >> 24));
put ((byte) ((((int) value) & 0x00ff0000) >> 16));
put ((byte) ((((int) value) & 0x0000ff00) >> 8));
put ((byte) (((int) value) & 0x000000ff));
ByteBufferHelper.putInt(this, value, order());
return this;
}
final public int getInt (int index)
{
// FIXME: this handles little endian only
return (int) (((get (index) & 0xff) << 24)
+ ((get (index + 1) & 0xff) << 16)
+ ((get (index + 2) & 0xff) << 8)
+ (get (index + 3) & 0xff));
return ByteBufferHelper.getInt(this, index, order());
}
final public ByteBuffer putInt (int index, int value)
{
// FIXME: this handles little endian only
put (index, (byte) ((((int) value) & 0xff000000) >> 24));
put (index + 1, (byte) ((((int) value) & 0x00ff0000) >> 16));
put (index + 2, (byte) ((((int) value) & 0x0000ff00) >> 8));
put (index + 3, (byte) (((int) value) & 0x000000ff));
ByteBufferHelper.putInt(this, index, value, order());
return this;
}
final public long getLong ()
{
// FIXME: this handles little endian only
return (long) (((get () & 0xff) << 56)
+ ((get () & 0xff) << 48)
+ ((get () & 0xff) << 40)
+ ((get () & 0xff) << 32)
+ ((get () & 0xff) << 24)
+ ((get () & 0xff) << 16)
+ ((get () & 0xff) << 8)
+ (get () & 0xff));
return ByteBufferHelper.getLong(this, order());
}
final public ByteBuffer putLong (long value)
{
return ByteBufferHelper.putLong (this, value);
ByteBufferHelper.putLong (this, value, order());
return this;
}
final public long getLong (int index)
{
return ByteBufferHelper.getLong (this, index);
return ByteBufferHelper.getLong (this, index, order());
}
final public ByteBuffer putLong (int index, long value)
{
return ByteBufferHelper.putLong (this, index, value);
ByteBufferHelper.putLong (this, index, value, order());
return this;
}
final public float getFloat ()
{
return ByteBufferHelper.getFloat (this);
return ByteBufferHelper.getFloat (this, order());
}
final public ByteBuffer putFloat (float value)
{
return ByteBufferHelper.putFloat (this, value);
ByteBufferHelper.putFloat (this, value, order());
return this;
}
public final float getFloat (int index)
{
return ByteBufferHelper.getFloat (this, index);
return ByteBufferHelper.getFloat (this, index, order());
}
final public ByteBuffer putFloat (int index, float value)
{
return ByteBufferHelper.putFloat (this, index, value);
ByteBufferHelper.putFloat (this, index, value, order());
return this;
}
final public double getDouble ()
{
return ByteBufferHelper.getDouble (this);
return ByteBufferHelper.getDouble (this, order());
}
final public ByteBuffer putDouble (double value)
{
return ByteBufferHelper.putDouble (this, value);
ByteBufferHelper.putDouble (this, value, order());
return this;
}
final public double getDouble (int index)
{
return ByteBufferHelper.getDouble (this, index);
return ByteBufferHelper.getDouble (this, index, order());
}
final public ByteBuffer putDouble (int index, double value)
{
return ByteBufferHelper.putDouble (this, index, value);
ByteBufferHelper.putDouble (this, index, value, order());
return this;
}
}
/* DoubleViewBufferImpl.java --
Copyright (C) 2003 Free Software Foundation, Inc.
Copyright (C) 2003, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
......@@ -40,54 +40,47 @@ package java.nio;
class DoubleViewBufferImpl extends DoubleBuffer
{
private boolean readOnly;
/** Position in bb (i.e. a byte offset) where this buffer starts. */
private int offset;
private ByteBuffer bb;
private boolean readOnly;
private ByteOrder endian;
public DoubleViewBufferImpl (ByteBuffer bb, boolean readOnly)
{
super (bb.remaining () >> 3, bb.remaining () >> 3, bb.position (), 0);
this.bb = bb;
this.readOnly = readOnly;
// FIXME: What if this is called from DoubleByteBufferImpl and ByteBuffer has changed its endianess ?
this.endian = bb.order ();
}
public DoubleViewBufferImpl (ByteBuffer bb, int offset, int capacity,
int limit, int position, int mark,
boolean readOnly)
boolean readOnly, ByteOrder endian)
{
super (limit >> 3, limit >> 3, position >> 3, mark >> 3);
this.bb = bb;
this.offset = offset;
this.readOnly = readOnly;
// FIXME: What if this is called from DoubleViewBufferImpl and ByteBuffer has changed its endianess ?
this.endian = bb.order ();
this.endian = endian;
}
public double get ()
{
double result = bb.getDouble ((position () << 3) + offset);
position (position () + 1);
int p = position();
double result = ByteBufferHelper.getDouble(bb, (p << 3) + offset, endian);
position(p + 1);
return result;
}
public double get (int index)
{
return bb.getDouble ((index << 3) + offset);
return ByteBufferHelper.getDouble(bb, (index << 3) + offset, endian);
}
public DoubleBuffer put (double value)
{
bb.putDouble ((position () << 3) + offset, value);
position (position () + 1);
int p = position();
ByteBufferHelper.putDouble(bb, (p << 3) + offset, value, endian);
position(p + 1);
return this;
}
public DoubleBuffer put (int index, double value)
{
bb.putDouble ((index << 3) + offset, value);
ByteBufferHelper.putDouble(bb, (index << 3) + offset, value, endian);
return this;
}
......@@ -95,48 +88,41 @@ class DoubleViewBufferImpl extends DoubleBuffer
{
if (position () > 0)
{
// Copy all data from position() to limit() to the beginning of the
// buffer, set position to end of data and limit to capacity
// XXX: This can surely be optimized, for direct and non-direct buffers
int count = limit () - position ();
for (int i = 0; i < count; i++)
{
bb.putDouble ((i >> 3) + offset,
bb.getDouble (((i + position ()) >> 3) + offset));
}
bb.shiftDown(offset, offset + 8 * position(), 8 * count);
position (count);
limit (capacity ());
}
return this;
}
public DoubleBuffer duplicate ()
public DoubleBuffer slice ()
{
// Create a copy of this object that shares its content
// FIXME: mark is not correct
return new DoubleViewBufferImpl (bb, offset, capacity (), limit (),
position (), -1, isReadOnly ());
return new DoubleViewBufferImpl (bb, (position () >> 3) + offset,
remaining(), remaining(), 0, -1,
readOnly, endian);
}
public DoubleBuffer slice ()
DoubleBuffer duplicate (boolean readOnly)
{
// Create a sliced copy of this object that shares its content.
return new DoubleViewBufferImpl (bb, (position () >> 3) + offset,
remaining (), remaining (), 0, -1,
isReadOnly ());
int pos = position();
reset();
int mark = position();
position(pos);
return new DoubleViewBufferImpl (bb, offset, capacity(), limit(),
pos, mark, readOnly, endian);
}
public DoubleBuffer duplicate ()
{
return duplicate(readOnly);
}
public DoubleBuffer asReadOnlyBuffer ()
{
// Create a copy of this object that shares its content and is read-only
return new DoubleViewBufferImpl (bb, (position () >> 3) + offset,
remaining (), remaining (), 0, -1, true);
return duplicate(true);
}
public boolean isReadOnly ()
{
return readOnly;
......@@ -149,6 +135,6 @@ class DoubleViewBufferImpl extends DoubleBuffer
public ByteOrder order ()
{
return ByteOrder.LITTLE_ENDIAN;
return endian;
}
}
/* FloatViewBufferImpl.java --
Copyright (C) 2003 Free Software Foundation, Inc.
Copyright (C) 2003, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
......@@ -40,54 +40,47 @@ package java.nio;
class FloatViewBufferImpl extends FloatBuffer
{
private boolean readOnly;
/** Position in bb (i.e. a byte offset) where this buffer starts. */
private int offset;
private ByteBuffer bb;
private boolean readOnly;
private ByteOrder endian;
public FloatViewBufferImpl (ByteBuffer bb, boolean readOnly)
{
super (bb.remaining () >> 2, bb.remaining () >> 2, bb.position (), 0);
this.bb = bb;
this.readOnly = readOnly;
// FIXME: What if this is called from FloatByteBufferImpl and ByteBuffer has changed its endianess ?
this.endian = bb.order ();
}
public FloatViewBufferImpl (ByteBuffer bb, int offset, int capacity,
int limit, int position, int mark,
boolean readOnly)
int limit, int position, int mark,
boolean readOnly, ByteOrder endian)
{
super (limit >> 2, limit >> 2, position >> 2, mark >> 2);
this.bb = bb;
this.offset = offset;
this.readOnly = readOnly;
// FIXME: What if this is called from FloatViewBufferImpl and ByteBuffer has changed its endianess ?
this.endian = bb.order ();
this.endian = endian;
}
public float get ()
{
float result = bb.getFloat ((position () << 2) + offset);
position (position () + 1);
int p = position();
float result = ByteBufferHelper.getFloat(bb, (p << 2) + offset, endian);
position(p + 1);
return result;
}
public float get (int index)
{
return bb.getFloat ((index << 2) + offset);
return ByteBufferHelper.getFloat(bb, (index << 2) + offset, endian);
}
public FloatBuffer put (float value)
{
bb.putFloat ((position () << 2) + offset, value);
position (position () + 1);
int p = position();
ByteBufferHelper.putFloat(bb, (p << 2) + offset, value, endian);
position(p + 1);
return this;
}
public FloatBuffer put (int index, float value)
{
bb.putFloat ((index << 2) + offset, value);
ByteBufferHelper.putFloat(bb, (index << 2) + offset, value, endian);
return this;
}
......@@ -95,48 +88,42 @@ class FloatViewBufferImpl extends FloatBuffer
{
if (position () > 0)
{
// Copy all data from position() to limit() to the beginning of the
// buffer, set position to end of data and limit to capacity
// XXX: This can surely be optimized, for direct and non-direct buffers
int count = limit () - position ();
for (int i = 0; i < count; i++)
{
bb.putFloat ((i >> 2) + offset,
bb.getFloat (((i + position ()) >> 2) + offset));
}
bb.shiftDown(offset, offset + 4 * position(), 4 * count);
position (count);
limit (capacity ());
}
return this;
}
public FloatBuffer duplicate ()
{
// Create a copy of this object that shares its content
// FIXME: mark is not correct
return new FloatViewBufferImpl (bb, offset, capacity (), limit (),
position (), -1, isReadOnly ());
}
public FloatBuffer slice ()
{
// Create a sliced copy of this object that shares its content.
return new FloatViewBufferImpl (bb, (position () >> 2) + offset,
remaining (), remaining (), 0, -1,
isReadOnly ());
remaining(), remaining(), 0, -1,
readOnly, endian);
}
public FloatBuffer asReadOnlyBuffer ()
FloatBuffer duplicate (boolean readOnly)
{
// Create a copy of this object that shares its content and is read-only
return new FloatViewBufferImpl (bb, (position () >> 2) + offset,
remaining (), remaining (), 0, -1, true);
int pos = position();
reset();
int mark = position();
position(pos);
return new FloatViewBufferImpl (bb, offset, capacity(), limit(),
pos, mark, readOnly, endian);
}
public FloatBuffer duplicate ()
{
return duplicate(readOnly);
}
public FloatBuffer asReadOnlyBuffer ()
{
return duplicate(true);
}
public boolean isReadOnly ()
{
return readOnly;
......@@ -149,6 +136,6 @@ class FloatViewBufferImpl extends FloatBuffer
public ByteOrder order ()
{
return ByteOrder.LITTLE_ENDIAN;
return endian;
}
}
/* IntViewBufferImpl.java --
Copyright (C) 2003 Free Software Foundation, Inc.
Copyright (C) 2003, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
......@@ -40,54 +40,47 @@ package java.nio;
class IntViewBufferImpl extends IntBuffer
{
private boolean readOnly;
/** Position in bb (i.e. a byte offset) where this buffer starts. */
private int offset;
private ByteBuffer bb;
private boolean readOnly;
private ByteOrder endian;
public IntViewBufferImpl (ByteBuffer bb, boolean readOnly)
{
super (bb.remaining () >> 2, bb.remaining () >> 2, bb.position (), 0);
this.bb = bb;
this.readOnly = readOnly;
// FIXME: What if this is called from IntByteBufferImpl and ByteBuffer has changed its endianess ?
this.endian = bb.order ();
}
public IntViewBufferImpl (ByteBuffer bb, int offset, int capacity,
int limit, int position, int mark,
boolean readOnly)
int limit, int position, int mark,
boolean readOnly, ByteOrder endian)
{
super (limit >> 2, limit >> 2, position >> 2, mark >> 2);
this.bb = bb;
this.offset = offset;
this.readOnly = readOnly;
// FIXME: What if this is called from IntViewBufferImpl and ByteBuffer has changed its endianess ?
this.endian = bb.order ();
this.endian = endian;
}
public int get ()
{
int result = bb.getInt ((position () << 2) + offset);
position (position () + 1);
int p = position();
int result = ByteBufferHelper.getInt(bb, (p << 2) + offset, endian);
position(p + 1);
return result;
}
public int get (int index)
{
return bb.getInt ((index << 2) + offset);
return ByteBufferHelper.getInt(bb, (index << 2) + offset, endian);
}
public IntBuffer put (int value)
{
bb.putInt ((position () << 2) + offset, value);
position (position () + 1);
int p = position();
ByteBufferHelper.putInt(bb, (p << 2) + offset, value, endian);
position(p + 1);
return this;
}
public IntBuffer put (int index, int value)
{
bb.putInt ((index << 2) + offset, value);
ByteBufferHelper.putInt(bb, (index << 2) + offset, value, endian);
return this;
}
......@@ -95,48 +88,42 @@ class IntViewBufferImpl extends IntBuffer
{
if (position () > 0)
{
// Copy all data from position() to limit() to the beginning of the
// buffer, set position to end of data and limit to capacity
// XXX: This can surely be optimized, for direct and non-direct buffers
int count = limit () - position ();
for (int i = 0; i < count; i++)
{
bb.putInt ((i >> 2) + offset,
bb.getInt (((i + position ()) >> 2) + offset));
}
bb.shiftDown(offset, offset + 4 * position(), 4 * count);
position (count);
limit (capacity ());
}
return this;
}
public IntBuffer duplicate ()
{
// Create a copy of this object that shares its content
// FIXME: mark is not correct
return new IntViewBufferImpl (bb, offset, capacity (), limit (),
position (), -1, isReadOnly ());
}
public IntBuffer slice ()
{
// Create a sliced copy of this object that shares its content.
return new IntViewBufferImpl (bb, (position () >> 2) + offset,
remaining (), remaining (), 0, -1,
isReadOnly ());
remaining(), remaining(), 0, -1,
readOnly, endian);
}
public IntBuffer asReadOnlyBuffer ()
IntBuffer duplicate (boolean readOnly)
{
// Create a copy of this object that shares its content and is read-only
return new IntViewBufferImpl (bb, (position () >> 2) + offset,
remaining (), remaining (), 0, -1, true);
int pos = position();
reset();
int mark = position();
position(pos);
return new IntViewBufferImpl (bb, offset, capacity(), limit(),
pos, mark, readOnly, endian);
}
public IntBuffer duplicate ()
{
return duplicate(readOnly);
}
public IntBuffer asReadOnlyBuffer ()
{
return duplicate(true);
}
public boolean isReadOnly ()
{
return readOnly;
......@@ -149,6 +136,6 @@ class IntViewBufferImpl extends IntBuffer
public ByteOrder order ()
{
return ByteOrder.LITTLE_ENDIAN;
return endian;
}
}
/* LongViewBufferImpl.java --
Copyright (C) 2003 Free Software Foundation, Inc.
Copyright (C) 2003, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
......@@ -40,54 +40,47 @@ package java.nio;
class LongViewBufferImpl extends LongBuffer
{
private boolean readOnly;
/** Position in bb (i.e. a byte offset) where this buffer starts. */
private int offset;
private ByteBuffer bb;
private boolean readOnly;
private ByteOrder endian;
public LongViewBufferImpl (ByteBuffer bb, boolean readOnly)
{
super (bb.remaining () >> 3, bb.remaining () >> 3, bb.position (), 0);
this.bb = bb;
this.readOnly = readOnly;
// FIXME: What if this is called from LongByteBufferImpl and ByteBuffer has changed its endianess ?
this.endian = bb.order ();
}
public LongViewBufferImpl (ByteBuffer bb, int offset, int capacity,
int limit, int position, int mark,
boolean readOnly)
int limit, int position, int mark,
boolean readOnly, ByteOrder endian)
{
super (limit >> 3, limit >> 3, position >> 3, mark >> 3);
this.bb = bb;
this.offset = offset;
this.readOnly = readOnly;
// FIXME: What if this is called from LongViewBufferImpl and ByteBuffer has changed its endianess ?
this.endian = bb.order ();
this.endian = endian;
}
public long get ()
{
long result = bb.getLong ((position () << 3) + offset);
position (position () + 1);
int p = position();
long result = ByteBufferHelper.getLong(bb, (p << 3) + offset, endian);
position(p + 1);
return result;
}
public long get (int index)
{
return bb.getLong ((index << 3) + offset);
return ByteBufferHelper.getLong(bb, (index << 3) + offset, endian);
}
public LongBuffer put (long value)
{
bb.putLong ((position () << 3) + offset, value);
position (position () + 1);
int p = position();
ByteBufferHelper.putLong(bb, (p << 3) + offset, value, endian);
position(p + 1);
return this;
}
public LongBuffer put (int index, long value)
{
bb.putLong ((index << 3) + offset, value);
ByteBufferHelper.putLong(bb, (index << 3) + offset, value, endian);
return this;
}
......@@ -95,48 +88,42 @@ class LongViewBufferImpl extends LongBuffer
{
if (position () > 0)
{
// Copy all data from position() to limit() to the beginning of the
// buffer, set position to end of data and limit to capacity
// XXX: This can surely be optimized, for direct and non-direct buffers
int count = limit () - position ();
for (int i = 0; i < count; i++)
{
bb.putLong ((i >> 3) + offset,
bb.getLong (((i + position ()) >> 3) + offset));
}
bb.shiftDown(offset, offset + 8 * position(), 8 * count);
position (count);
limit (capacity ());
}
return this;
}
public LongBuffer duplicate ()
{
// Create a copy of this object that shares its content
// FIXME: mark is not correct
return new LongViewBufferImpl (bb, offset, capacity (), limit (),
position (), -1, isReadOnly ());
}
public LongBuffer slice ()
{
// Create a sliced copy of this object that shares its content.
return new LongViewBufferImpl (bb, (position () >> 3) + offset,
remaining (), remaining (), 0, -1,
isReadOnly ());
remaining(), remaining(), 0, -1,
readOnly, endian);
}
public LongBuffer asReadOnlyBuffer ()
LongBuffer duplicate (boolean readOnly)
{
// Create a copy of this object that shares its content and is read-only
return new LongViewBufferImpl (bb, (position () >> 3) + offset,
remaining (), remaining (), 0, -1, true);
int pos = position();
reset();
int mark = position();
position(pos);
return new LongViewBufferImpl (bb, offset, capacity(), limit(),
pos, mark, readOnly, endian);
}
public LongBuffer duplicate ()
{
return duplicate(readOnly);
}
public LongBuffer asReadOnlyBuffer ()
{
return duplicate(true);
}
public boolean isReadOnly ()
{
return readOnly;
......@@ -149,6 +136,6 @@ class LongViewBufferImpl extends LongBuffer
public ByteOrder order ()
{
return ByteOrder.LITTLE_ENDIAN;
return endian;
}
}
/* MappedByteBufferImpl.java --
Copyright (C) 2002, 2003 Free Software Foundation, Inc.
Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
......@@ -111,15 +111,14 @@ public class MappedByteBufferImpl extends MappedByteBuffer
public ByteBuffer compact ()
{
int copied = 0;
while (remaining () > 0)
int pos = position();
if (pos > 0)
{
put (copied, get ());
copied++;
int count = remaining();
shiftDown(0, pos, count);
position(count);
limit(capacity());
}
position (copied);
return this;
}
......@@ -145,151 +144,163 @@ public class MappedByteBufferImpl extends MappedByteBuffer
public CharBuffer asCharBuffer ()
{
return new CharViewBufferImpl (this, position (), remaining(), remaining (), 0, -1, isReadOnly ());
return new CharViewBufferImpl (this, position (), remaining(), remaining (), 0, -1, isReadOnly (), order());
}
public ShortBuffer asShortBuffer ()
{
return new ShortViewBufferImpl (this, position (), remaining(), remaining (), 0, -1, isReadOnly ());
return new ShortViewBufferImpl (this, position (), remaining(), remaining (), 0, -1, isReadOnly (), order());
}
public IntBuffer asIntBuffer ()
{
return new IntViewBufferImpl (this, position (), remaining(), remaining (), 0, -1, isReadOnly ());
return new IntViewBufferImpl (this, position (), remaining(), remaining (), 0, -1, isReadOnly (), order());
}
public LongBuffer asLongBuffer ()
{
return new LongViewBufferImpl (this, position (), remaining(), remaining (), 0, -1, isReadOnly ());
return new LongViewBufferImpl (this, position (), remaining(), remaining (), 0, -1, isReadOnly (), order());
}
public FloatBuffer asFloatBuffer ()
{
return new FloatViewBufferImpl (this, position (), remaining(), remaining (), 0, -1, isReadOnly ());
return new FloatViewBufferImpl (this, position (), remaining(), remaining (), 0, -1, isReadOnly (), order());
}
public DoubleBuffer asDoubleBuffer ()
{
return new DoubleViewBufferImpl (this, position (), remaining(), remaining (), 0, -1, isReadOnly ());
return new DoubleViewBufferImpl (this, position (), remaining(), remaining (), 0, -1, isReadOnly (), order());
}
public final char getChar()
final public char getChar ()
{
return ByteBufferHelper.getChar (this);
return ByteBufferHelper.getChar(this, order());
}
public final ByteBuffer putChar (char value)
final public ByteBuffer putChar (char value)
{
return ByteBufferHelper.putChar (this, value);
ByteBufferHelper.putChar(this, value, order());
return this;
}
public final char getChar (int index)
final public char getChar (int index)
{
return ByteBufferHelper.getChar (this, index);
return ByteBufferHelper.getChar(this, index, order());
}
public final ByteBuffer putChar (int index, char value)
final public ByteBuffer putChar (int index, char value)
{
return ByteBufferHelper.putChar (this, index, value);
ByteBufferHelper.putChar(this, index, value, order());
return this;
}
public final short getShort()
final public short getShort ()
{
return ByteBufferHelper.getShort (this);
return ByteBufferHelper.getShort(this, order());
}
public final ByteBuffer putShort (short value)
final public ByteBuffer putShort (short value)
{
return ByteBufferHelper.putShort (this, value);
ByteBufferHelper.putShort(this, value, order());
return this;
}
public final short getShort (int index)
final public short getShort (int index)
{
return ByteBufferHelper.getShort (this, index);
return ByteBufferHelper.getShort(this, index, order());
}
public final ByteBuffer putShort (int index, short value)
final public ByteBuffer putShort (int index, short value)
{
return ByteBufferHelper.putShort (this, index, value);
ByteBufferHelper.putShort(this, index, value, order());
return this;
}
public final int getInt()
final public int getInt ()
{
return ByteBufferHelper.getInt (this);
return ByteBufferHelper.getInt(this, order());
}
public final ByteBuffer putInt (int value)
final public ByteBuffer putInt (int value)
{
return ByteBufferHelper.putInt (this, value);
ByteBufferHelper.putInt(this, value, order());
return this;
}
public final int getInt (int index)
final public int getInt (int index)
{
return ByteBufferHelper.getInt (this, index);
return ByteBufferHelper.getInt(this, index, order());
}
public final ByteBuffer putInt (int index, int value)
final public ByteBuffer putInt (int index, int value)
{
return ByteBufferHelper.putInt (this, index, value);
ByteBufferHelper.putInt(this, index, value, order());
return this;
}
public final long getLong()
final public long getLong ()
{
return ByteBufferHelper.getLong (this);
return ByteBufferHelper.getLong(this, order());
}
public final ByteBuffer putLong (long value)
final public ByteBuffer putLong (long value)
{
return ByteBufferHelper.putLong (this, value);
ByteBufferHelper.putLong (this, value, order());
return this;
}
public final long getLong (int index)
final public long getLong (int index)
{
return ByteBufferHelper.getLong (this, index);
return ByteBufferHelper.getLong (this, index, order());
}
public final ByteBuffer putLong (int index, long value)
final public ByteBuffer putLong (int index, long value)
{
return ByteBufferHelper.putLong (this, index, value);
ByteBufferHelper.putLong (this, index, value, order());
return this;
}
public final float getFloat()
final public float getFloat ()
{
return ByteBufferHelper.getFloat (this);
return ByteBufferHelper.getFloat (this, order());
}
public final ByteBuffer putFloat (float value)
final public ByteBuffer putFloat (float value)
{
return ByteBufferHelper.putFloat (this, value);
ByteBufferHelper.putFloat (this, value, order());
return this;
}
public final float getFloat (int index)
{
return ByteBufferHelper.getFloat (this, index);
return ByteBufferHelper.getFloat (this, index, order());
}
public final ByteBuffer putFloat (int index, float value)
final public ByteBuffer putFloat (int index, float value)
{
return ByteBufferHelper.putFloat (this, index, value);
ByteBufferHelper.putFloat (this, index, value, order());
return this;
}
public final double getDouble()
final public double getDouble ()
{
return ByteBufferHelper.getDouble (this);
return ByteBufferHelper.getDouble (this, order());
}
public final ByteBuffer putDouble (double value)
final public ByteBuffer putDouble (double value)
{
return ByteBufferHelper.putDouble (this, value);
ByteBufferHelper.putDouble (this, value, order());
return this;
}
public final double getDouble (int index)
final public double getDouble (int index)
{
return ByteBufferHelper.getDouble (this, index);
return ByteBufferHelper.getDouble (this, index, order());
}
public final ByteBuffer putDouble (int index, double value)
final public ByteBuffer putDouble (int index, double value)
{
return ByteBufferHelper.putDouble (this, index, value);
ByteBufferHelper.putDouble (this, index, value, order());
return this;
}
}
/* ShortViewBufferImpl.java --
Copyright (C) 2003 Free Software Foundation, Inc.
Copyright (C) 2003, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
......@@ -40,54 +40,47 @@ package java.nio;
class ShortViewBufferImpl extends ShortBuffer
{
private boolean readOnly;
/** Position in bb (i.e. a byte offset) where this buffer starts. */
private int offset;
private ByteBuffer bb;
private boolean readOnly;
private ByteOrder endian;
public ShortViewBufferImpl (ByteBuffer bb, boolean readOnly)
{
super (bb.remaining () >> 1, bb.remaining () >> 1, bb.position (), 0);
this.bb = bb;
this.readOnly = readOnly;
// FIXME: What if this is called from ShortByteBufferImpl and ByteBuffer has changed its endianess ?
this.endian = bb.order ();
}
public ShortViewBufferImpl (ByteBuffer bb, int offset, int capacity,
int limit, int position, int mark,
boolean readOnly)
int limit, int position, int mark,
boolean readOnly, ByteOrder endian)
{
super (limit >> 1, limit >> 1, position >> 1, mark >> 1);
this.bb = bb;
this.offset = offset;
this.readOnly = readOnly;
// FIXME: What if this is called from ShortViewBufferImpl and ByteBuffer has changed its endianess ?
this.endian = bb.order ();
this.endian = endian;
}
public short get ()
{
short result = bb.getShort ((position () << 1) + offset);
position (position () + 1);
int p = position();
short result = ByteBufferHelper.getShort(bb, (p << 1) + offset, endian);
position(p + 1);
return result;
}
public short get (int index)
{
return bb.getShort ((index << 1) + offset);
return ByteBufferHelper.getShort(bb, (index << 1) + offset, endian);
}
public ShortBuffer put (short value)
{
bb.putShort ((position () << 1) + offset, value);
position (position () + 1);
int p = position();
ByteBufferHelper.putShort(bb, (p << 1) + offset, value, endian);
position(p + 1);
return this;
}
public ShortBuffer put (int index, short value)
{
bb.putShort ((index << 1) + offset, value);
ByteBufferHelper.putShort(bb, (index << 1) + offset, value, endian);
return this;
}
......@@ -95,48 +88,42 @@ class ShortViewBufferImpl extends ShortBuffer
{
if (position () > 0)
{
// Copy all data from position() to limit() to the beginning of the
// buffer, set position to end of data and limit to capacity
// XXX: This can surely be optimized, for direct and non-direct buffers
int count = limit () - position ();
for (int i = 0; i < count; i++)
{
bb.putShort ((i >> 1) + offset,
bb.getShort (((i + position ()) >> 1) + offset));
}
bb.shiftDown(offset, offset + 2 * position(), 2 * count);
position (count);
limit (capacity ());
}
return this;
}
public ShortBuffer duplicate ()
{
// Create a copy of this object that shares its content
// FIXME: mark is not correct
return new ShortViewBufferImpl (bb, offset, capacity (), limit (),
position (), -1, isReadOnly ());
}
public ShortBuffer slice ()
{
// Create a sliced copy of this object that shares its content.
return new ShortViewBufferImpl (bb, (position () >> 1) + offset,
remaining (), remaining (), 0, -1,
isReadOnly ());
remaining(), remaining(), 0, -1,
readOnly, endian);
}
public ShortBuffer asReadOnlyBuffer ()
ShortBuffer duplicate (boolean readOnly)
{
// Create a copy of this object that shares its content and is read-only
return new ShortViewBufferImpl (bb, (position () >> 1) + offset,
remaining (), remaining (), 0, -1, true);
int pos = position();
reset();
int mark = position();
position(pos);
return new ShortViewBufferImpl (bb, offset, capacity(), limit(),
pos, mark, readOnly, endian);
}
public ShortBuffer duplicate ()
{
return duplicate(readOnly);
}
public ShortBuffer asReadOnlyBuffer ()
{
return duplicate(true);
}
public boolean isReadOnly ()
{
return readOnly;
......@@ -149,6 +136,6 @@ class ShortViewBufferImpl extends ShortBuffer
public ByteOrder order ()
{
return ByteOrder.LITTLE_ENDIAN;
return endian;
}
}
......@@ -43,3 +43,12 @@ java::nio::DirectByteBufferImpl::putImpl (jint index, jbyte value)
jbyte* pointer = reinterpret_cast<jbyte*> (address) + offset + index;
*pointer = value;
}
void
java::nio::DirectByteBufferImpl::shiftDown
(jint dst_offset, jint src_offset, jint count)
{
jbyte* dst = reinterpret_cast<jbyte*> (address) + offset + dst_offset;
jbyte* src = reinterpret_cast<jbyte*> (address) + offset + src_offset;
::memmove(dst, src, count);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment