diff options
author | Brian Jones <cbj@gnu.org> | 2002-03-13 13:05:22 +0000 |
---|---|---|
committer | Brian Jones <cbj@gnu.org> | 2002-03-13 13:05:22 +0000 |
commit | 62f93952c1fbfa02bd9a204a85cf5df41adace86 (patch) | |
tree | a15ab8ee6538dfaf926b4901698842e50c0fd6ac | |
parent | f0a25669f4c9be51680ffefe5967c0c47fbc7704 (diff) | |
download | classpath-62f93952c1fbfa02bd9a204a85cf5df41adace86.tar.gz |
* lib/gen_nio.sh.in: new file is renamed gen_nio.sh plus fixes
to make it work when building outside of the classpath directory
* lib/gen_nio.sh: removed file
* lib/.cvsignore: ignore gen_nio.sh
* configure.in: generate gen_nio.sh and nio related Makefiles
in OUTPUT. Revert comment out of check for libart_lgpl
* lib/Makefile.am: give gen_nio.sh some idea of the top_builddir
and make it a separate target, gennio, that must be manually
executed; the generated files will be part of CVS since they change
only when the source .cpp changes rather than due to a configuration
change
* java/nio/Makefile.am: new file
* java/nio/.cvsignore: new file
* java/nio/charset/Makefile.am: new file
* java/nio/charset/.cvsignore: new file
* java/nio/channels/Makefile.am: new file
* java/nio/channels/.cvsignore: new file
* java/nio/channels/spi/Makefile.am: new file
* java/nio/channels/spi/.cvsignore: new file
* gnu/java/nio/Makefile.am: new file
* gnu/java/nio/.cvsignore: new file
* java/nio/ShortBuffer.java: generated file
* java/nio/ByteBuffer.java: generated file
* java/nio/LongBuffer.java: generated file
* java/nio/IntBuffer.java: generated file
* java/nio/FloatBuffer.java: generated file
* java/nio/DoubleBuffer.java: generated file
* java/nio/CharBuffer.java: generated file
* gnu/java/nio/ShortBufferImpl.java: generated file
* gnu/java/nio/MappedShortFileBuffer.java: generated file
* gnu/java/nio/MappedLongFileBuffer.java: generated file
* gnu/java/nio/MappedIntFileBuffer.java: generated file
* gnu/java/nio/MappedFloatFileBuffer.java: generated file
* gnu/java/nio/MappedDoubleFileBuffer.java: generated file
* gnu/java/nio/MappedCharFileBuffer.java: generated file
* gnu/java/nio/MappedByteFileBuffer.java: generated file
* gnu/java/nio/LongBufferImpl.java: generated file
* gnu/java/nio/IntBufferImpl.java: generated file
* gnu/java/nio/FloatBufferImpl.java: generated file
* gnu/java/nio/DoubleBufferImpl.java: generated file
* gnu/java/nio/CharBufferImpl.java: generated file
* gnu/java/nio/ByteBufferImpl.java: generated file
29 files changed, 2597 insertions, 142 deletions
@@ -1,3 +1,47 @@ +2002-03-12 C. Brian Jones <cbj@gnu.org> + + * lib/gen_nio.sh.in: new file is renamed gen_nio.sh plus fixes + to make it work when building outside of the classpath directory + * lib/gen_nio.sh: removed file + * lib/.cvsignore: ignore gen_nio.sh + * configure.in: generate gen_nio.sh and nio related Makefiles + in OUTPUT. Revert comment out of check for libart_lgpl + * lib/Makefile.am: give gen_nio.sh some idea of the top_builddir + and make it a separate target, gennio, that must be manually + executed; the generated files will be part of CVS since they change + only when the source .cpp changes rather than due to a configuration + change + * java/nio/Makefile.am: new file + * java/nio/.cvsignore: new file + * java/nio/charset/Makefile.am: new file + * java/nio/charset/.cvsignore: new file + * java/nio/channels/Makefile.am: new file + * java/nio/channels/.cvsignore: new file + * java/nio/channels/spi/Makefile.am: new file + * java/nio/channels/spi/.cvsignore: new file + * gnu/java/nio/Makefile.am: new file + * gnu/java/nio/.cvsignore: new file + * java/nio/ShortBuffer.java: generated file + * java/nio/ByteBuffer.java: generated file + * java/nio/LongBuffer.java: generated file + * java/nio/IntBuffer.java: generated file + * java/nio/FloatBuffer.java: generated file + * java/nio/DoubleBuffer.java: generated file + * java/nio/CharBuffer.java: generated file + * gnu/java/nio/ShortBufferImpl.java: generated file + * gnu/java/nio/MappedShortFileBuffer.java: generated file + * gnu/java/nio/MappedLongFileBuffer.java: generated file + * gnu/java/nio/MappedIntFileBuffer.java: generated file + * gnu/java/nio/MappedFloatFileBuffer.java: generated file + * gnu/java/nio/MappedDoubleFileBuffer.java: generated file + * gnu/java/nio/MappedCharFileBuffer.java: generated file + * gnu/java/nio/MappedByteFileBuffer.java: generated file + * gnu/java/nio/LongBufferImpl.java: generated file + * gnu/java/nio/IntBufferImpl.java: generated file + * gnu/java/nio/FloatBufferImpl.java: generated file + * gnu/java/nio/DoubleBufferImpl.java: generated file + * gnu/java/nio/CharBufferImpl.java: generated file + * gnu/java/nio/ByteBufferImpl.java: generated file 2002-03-12 Ronald Veldema <rveldema@cs.vu.nl> diff --git a/configure.in b/configure.in index 6d9aca8c0..44253a089 100644 --- a/configure.in +++ b/configure.in @@ -113,7 +113,7 @@ if test "${COMPILE_JNI}" = "yes"; then dnl XXX Fix me when libart.m4 has the compile test fixed! enable_libarttest=no -dnl AM_PATH_LIBART(2.1.0,,exit 1) + AM_PATH_LIBART(2.1.0,,exit 1) CLASSPATH_WITH_JAVAH @@ -251,6 +251,7 @@ gnu/java/lang/reflect/Makefile gnu/java/locale/Makefile gnu/java/net/Makefile gnu/java/net/content/Makefile +gnu/java/nio/Makefile gnu/java/net/content/text/Makefile gnu/java/net/protocol/Makefile gnu/java/net/protocol/file/Makefile @@ -288,6 +289,10 @@ java/lang/ref/Makefile java/lang/reflect/Makefile java/math/Makefile java/net/Makefile +java/nio/Makefile +java/nio/channels/Makefile +java/nio/channels/spi/Makefile +java/nio/charset/Makefile java/rmi/Makefile java/rmi/activation/Makefile java/rmi/dgc/Makefile @@ -336,7 +341,8 @@ vm/reference/java/Makefile vm/reference/java/lang/Makefile vm/reference/java/lang/reflect/Makefile lib/Makefile -lib/gen-classlist.sh, +lib/gen-classlist.sh +lib/gen_nio.sh, [ chmod 755 lib/gen-classlist.sh ]) diff --git a/gnu/java/Makefile.am b/gnu/java/Makefile.am index 8de4d29f7..8bd7f11dc 100644 --- a/gnu/java/Makefile.am +++ b/gnu/java/Makefile.am @@ -1,3 +1,3 @@ ## Input file for automake to generate the Makefile.in used by configure -SUBDIRS = awt beans io lang locale math net rmi security text util +SUBDIRS = awt beans io lang locale math net nio rmi security text util diff --git a/gnu/java/nio/ByteBufferImpl.java b/gnu/java/nio/ByteBufferImpl.java new file mode 100644 index 000000000..00a8d2bc0 --- /dev/null +++ b/gnu/java/nio/ByteBufferImpl.java @@ -0,0 +1,102 @@ +package gnu.java.nio; +import java.nio.*; +public final class ByteBufferImpl extends java.nio. ByteBuffer +{ + private int array_offset; + byte [] backing_buffer; + private boolean ro; + public ByteBufferImpl(int cap, int off, int lim) + { + this.backing_buffer = new byte[cap]; + this.capacity(cap); + this.position(off); + this.limit(lim); + } + public ByteBufferImpl(byte[] array, int off, int lim) + { + this.backing_buffer = array; + this.capacity(array.length); + this.position(off); + this.limit(lim); + } + public ByteBufferImpl(ByteBufferImpl copy) + { + backing_buffer = copy.backing_buffer; + ro = copy.ro; + position(copy.position()); + limit(copy.limit()); + } + void inc_pos(int a) + { + position(position() + a); + } + private static native byte[] nio_cast(byte[]copy); + private static native byte[] nio_cast(char[]copy); + private static native byte[] nio_cast(short[]copy); + private static native byte[] nio_cast(long[]copy); + private static native byte[] nio_cast(int[]copy); + private static native byte[] nio_cast(float[]copy); + private static native byte[] nio_cast(double[]copy); + ByteBufferImpl(byte[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native byte nio_get_Byte(ByteBufferImpl b, int index); private static native void nio_put_Byte(ByteBufferImpl b, int index, byte value); public java.nio. ByteBuffer asByteBuffer() { return new gnu.java.nio. ByteBufferImpl(backing_buffer); } + ByteBufferImpl(char[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native char nio_get_Char(ByteBufferImpl b, int index); private static native void nio_put_Char(ByteBufferImpl b, int index, char value); public java.nio. CharBuffer asCharBuffer() { return new gnu.java.nio. CharBufferImpl(backing_buffer); } + ByteBufferImpl(short[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native short nio_get_Short(ByteBufferImpl b, int index); private static native void nio_put_Short(ByteBufferImpl b, int index, short value); public java.nio. ShortBuffer asShortBuffer() { return new gnu.java.nio. ShortBufferImpl(backing_buffer); } + ByteBufferImpl(int[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native int nio_get_Int(ByteBufferImpl b, int index); private static native void nio_put_Int(ByteBufferImpl b, int index, int value); public java.nio. IntBuffer asIntBuffer() { return new gnu.java.nio. IntBufferImpl(backing_buffer); } + ByteBufferImpl(long[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native long nio_get_Long(ByteBufferImpl b, int index); private static native void nio_put_Long(ByteBufferImpl b, int index, long value); public java.nio. LongBuffer asLongBuffer() { return new gnu.java.nio. LongBufferImpl(backing_buffer); } + ByteBufferImpl(float[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native float nio_get_Float(ByteBufferImpl b, int index); private static native void nio_put_Float(ByteBufferImpl b, int index, float value); public java.nio. FloatBuffer asFloatBuffer() { return new gnu.java.nio. FloatBufferImpl(backing_buffer); } + ByteBufferImpl(double[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native double nio_get_Double(ByteBufferImpl b, int index); private static native void nio_put_Double(ByteBufferImpl b, int index, double value); public java.nio. DoubleBuffer asDoubleBuffer() { return new gnu.java.nio. DoubleBufferImpl(backing_buffer); } + public boolean isReadOnly() + { + return ro; + } + public java.nio. ByteBuffer slice() + { + ByteBufferImpl A = new ByteBufferImpl(this); + A.array_offset = position(); + return A; + } + public java.nio. ByteBuffer duplicate() + { + return new ByteBufferImpl(this); + } + public java.nio. ByteBuffer asReadOnlyBuffer() + { + ByteBufferImpl a = new ByteBufferImpl(this); + a.ro = true; + return a; + } + public java.nio. ByteBuffer compact() + { + return this; + } + public boolean isDirect() + { + return backing_buffer != null; + } + final public byte get() + { + byte e = backing_buffer[position()]; + position(position()+1); + return e; + } + final public java.nio. ByteBuffer put(byte b) + { + backing_buffer[position()] = b; + position(position()+1); + return this; + } + final public byte get(int index) + { + return backing_buffer[index]; + } + final public java.nio. ByteBuffer put(int index, byte b) + { + backing_buffer[index] = b; + return this; + } + final public char getChar() { char a = nio_get_Char(this, position()); inc_pos(2); return a; } final public java.nio. ByteBuffer putChar(char value) { nio_put_Char(this, position(), value); inc_pos(2); return this; } final public char getChar(int index) { char a = nio_get_Char(this, index); return a; } final public java.nio. ByteBuffer putChar(int index, char value) { nio_put_Char(this, index, value); return this; }; + final public short getShort() { short a = nio_get_Short(this, position()); inc_pos(2); return a; } final public java.nio. ByteBuffer putShort(short value) { nio_put_Short(this, position(), value); inc_pos(2); return this; } final public short getShort(int index) { short a = nio_get_Short(this, index); return a; } final public java.nio. ByteBuffer putShort(int index, short value) { nio_put_Short(this, index, value); return this; }; + final public int getInt() { int a = nio_get_Int(this, position()); inc_pos(4); return a; } final public java.nio. ByteBuffer putInt(int value) { nio_put_Int(this, position(), value); inc_pos(4); return this; } final public int getInt(int index) { int a = nio_get_Int(this, index); return a; } final public java.nio. ByteBuffer putInt(int index, int value) { nio_put_Int(this, index, value); return this; }; + final public long getLong() { long a = nio_get_Long(this, position()); inc_pos(8); return a; } final public java.nio. ByteBuffer putLong(long value) { nio_put_Long(this, position(), value); inc_pos(8); return this; } final public long getLong(int index) { long a = nio_get_Long(this, index); return a; } final public java.nio. ByteBuffer putLong(int index, long value) { nio_put_Long(this, index, value); return this; }; + final public float getFloat() { float a = nio_get_Float(this, position()); inc_pos(4); return a; } final public java.nio. ByteBuffer putFloat(float value) { nio_put_Float(this, position(), value); inc_pos(4); return this; } final public float getFloat(int index) { float a = nio_get_Float(this, index); return a; } final public java.nio. ByteBuffer putFloat(int index, float value) { nio_put_Float(this, index, value); return this; }; + final public double getDouble() { double a = nio_get_Double(this, position()); inc_pos(8); return a; } final public java.nio. ByteBuffer putDouble(double value) { nio_put_Double(this, position(), value); inc_pos(8); return this; } final public double getDouble(int index) { double a = nio_get_Double(this, index); return a; } final public java.nio. ByteBuffer putDouble(int index, double value) { nio_put_Double(this, index, value); return this; }; +} diff --git a/gnu/java/nio/CharBufferImpl.java b/gnu/java/nio/CharBufferImpl.java new file mode 100644 index 000000000..62060467a --- /dev/null +++ b/gnu/java/nio/CharBufferImpl.java @@ -0,0 +1,110 @@ +package gnu.java.nio; +import java.nio.*; +public final class CharBufferImpl extends java.nio. CharBuffer +{ + private int array_offset; + char [] backing_buffer; + private boolean ro; + public CharBufferImpl(int cap, int off, int lim) + { + this.backing_buffer = new char[cap]; + this.capacity(cap); + this.position(off); + this.limit(lim); + } + public CharBufferImpl(char[] array, int off, int lim) + { + this.backing_buffer = array; + this.capacity(array.length); + this.position(off); + this.limit(lim); + } + public CharBufferImpl(CharBufferImpl copy) + { + backing_buffer = copy.backing_buffer; + ro = copy.ro; + position(copy.position()); + limit(copy.limit()); + } + void inc_pos(int a) + { + position(position() + a); + } + private static native char[] nio_cast(byte[]copy); + private static native char[] nio_cast(char[]copy); + private static native char[] nio_cast(short[]copy); + private static native char[] nio_cast(long[]copy); + private static native char[] nio_cast(int[]copy); + private static native char[] nio_cast(float[]copy); + private static native char[] nio_cast(double[]copy); + CharBufferImpl(byte[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native byte nio_get_Byte(CharBufferImpl b, int index); private static native void nio_put_Byte(CharBufferImpl b, int index, byte value); public java.nio. ByteBuffer asByteBuffer() { return new gnu.java.nio. ByteBufferImpl(backing_buffer); } + CharBufferImpl(char[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native char nio_get_Char(CharBufferImpl b, int index); private static native void nio_put_Char(CharBufferImpl b, int index, char value); public java.nio. CharBuffer asCharBuffer() { return new gnu.java.nio. CharBufferImpl(backing_buffer); } + CharBufferImpl(short[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native short nio_get_Short(CharBufferImpl b, int index); private static native void nio_put_Short(CharBufferImpl b, int index, short value); public java.nio. ShortBuffer asShortBuffer() { return new gnu.java.nio. ShortBufferImpl(backing_buffer); } + CharBufferImpl(int[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native int nio_get_Int(CharBufferImpl b, int index); private static native void nio_put_Int(CharBufferImpl b, int index, int value); public java.nio. IntBuffer asIntBuffer() { return new gnu.java.nio. IntBufferImpl(backing_buffer); } + CharBufferImpl(long[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native long nio_get_Long(CharBufferImpl b, int index); private static native void nio_put_Long(CharBufferImpl b, int index, long value); public java.nio. LongBuffer asLongBuffer() { return new gnu.java.nio. LongBufferImpl(backing_buffer); } + CharBufferImpl(float[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native float nio_get_Float(CharBufferImpl b, int index); private static native void nio_put_Float(CharBufferImpl b, int index, float value); public java.nio. FloatBuffer asFloatBuffer() { return new gnu.java.nio. FloatBufferImpl(backing_buffer); } + CharBufferImpl(double[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native double nio_get_Double(CharBufferImpl b, int index); private static native void nio_put_Double(CharBufferImpl b, int index, double value); public java.nio. DoubleBuffer asDoubleBuffer() { return new gnu.java.nio. DoubleBufferImpl(backing_buffer); } + public boolean isReadOnly() + { + return ro; + } + public java.nio. CharBuffer slice() + { + CharBufferImpl A = new CharBufferImpl(this); + A.array_offset = position(); + return A; + } + public java.nio. CharBuffer duplicate() + { + return new CharBufferImpl(this); + } + public java.nio. CharBuffer asReadOnlyBuffer() + { + CharBufferImpl a = new CharBufferImpl(this); + a.ro = true; + return a; + } + public java.nio. CharBuffer compact() + { + return this; + } + public boolean isDirect() + { + return backing_buffer != null; + } + final public char get() + { + char e = backing_buffer[position()]; + position(position()+1); + return e; + } + final public java.nio. CharBuffer put(char b) + { + backing_buffer[position()] = b; + position(position()+1); + return this; + } + final public char get(int index) + { + return backing_buffer[index]; + } + final public java.nio. CharBuffer put(int index, char b) + { + backing_buffer[index] = b; + return this; + } + final public char getChar() { return get(); } final public java.nio. CharBuffer putChar(char value) { return put(value); } final public char getChar(int index) { return get(index); } final public java.nio. CharBuffer putChar(int index, char value) { return put(index, value); }; + final public short getShort() { short a = nio_get_Short(this, position()); inc_pos(2); return a; } final public java.nio. CharBuffer putShort(short value) { nio_put_Short(this, position(), value); inc_pos(2); return this; } final public short getShort(int index) { short a = nio_get_Short(this, index); return a; } final public java.nio. CharBuffer putShort(int index, short value) { nio_put_Short(this, index, value); return this; }; + final public int getInt() { int a = nio_get_Int(this, position()); inc_pos(4); return a; } final public java.nio. CharBuffer putInt(int value) { nio_put_Int(this, position(), value); inc_pos(4); return this; } final public int getInt(int index) { int a = nio_get_Int(this, index); return a; } final public java.nio. CharBuffer putInt(int index, int value) { nio_put_Int(this, index, value); return this; }; + final public long getLong() { long a = nio_get_Long(this, position()); inc_pos(8); return a; } final public java.nio. CharBuffer putLong(long value) { nio_put_Long(this, position(), value); inc_pos(8); return this; } final public long getLong(int index) { long a = nio_get_Long(this, index); return a; } final public java.nio. CharBuffer putLong(int index, long value) { nio_put_Long(this, index, value); return this; }; + final public float getFloat() { float a = nio_get_Float(this, position()); inc_pos(4); return a; } final public java.nio. CharBuffer putFloat(float value) { nio_put_Float(this, position(), value); inc_pos(4); return this; } final public float getFloat(int index) { float a = nio_get_Float(this, index); return a; } final public java.nio. CharBuffer putFloat(int index, float value) { nio_put_Float(this, index, value); return this; }; + final public double getDouble() { double a = nio_get_Double(this, position()); inc_pos(8); return a; } final public java.nio. CharBuffer putDouble(double value) { nio_put_Double(this, position(), value); inc_pos(8); return this; } final public double getDouble(int index) { double a = nio_get_Double(this, index); return a; } final public java.nio. CharBuffer putDouble(int index, double value) { nio_put_Double(this, index, value); return this; }; + public String toString() + { + if (backing_buffer != null) + { + return new String(backing_buffer, position(), limit()); + } + return super.toString(); + } +} diff --git a/gnu/java/nio/DoubleBufferImpl.java b/gnu/java/nio/DoubleBufferImpl.java new file mode 100644 index 000000000..4aabd4cb3 --- /dev/null +++ b/gnu/java/nio/DoubleBufferImpl.java @@ -0,0 +1,102 @@ +package gnu.java.nio; +import java.nio.*; +public final class DoubleBufferImpl extends java.nio. DoubleBuffer +{ + private int array_offset; + double [] backing_buffer; + private boolean ro; + public DoubleBufferImpl(int cap, int off, int lim) + { + this.backing_buffer = new double[cap]; + this.capacity(cap); + this.position(off); + this.limit(lim); + } + public DoubleBufferImpl(double[] array, int off, int lim) + { + this.backing_buffer = array; + this.capacity(array.length); + this.position(off); + this.limit(lim); + } + public DoubleBufferImpl(DoubleBufferImpl copy) + { + backing_buffer = copy.backing_buffer; + ro = copy.ro; + position(copy.position()); + limit(copy.limit()); + } + void inc_pos(int a) + { + position(position() + a); + } + private static native double[] nio_cast(byte[]copy); + private static native double[] nio_cast(char[]copy); + private static native double[] nio_cast(short[]copy); + private static native double[] nio_cast(long[]copy); + private static native double[] nio_cast(int[]copy); + private static native double[] nio_cast(float[]copy); + private static native double[] nio_cast(double[]copy); + DoubleBufferImpl(byte[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native byte nio_get_Byte(DoubleBufferImpl b, int index); private static native void nio_put_Byte(DoubleBufferImpl b, int index, byte value); public java.nio. ByteBuffer asByteBuffer() { return new gnu.java.nio. ByteBufferImpl(backing_buffer); } + DoubleBufferImpl(char[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native char nio_get_Char(DoubleBufferImpl b, int index); private static native void nio_put_Char(DoubleBufferImpl b, int index, char value); public java.nio. CharBuffer asCharBuffer() { return new gnu.java.nio. CharBufferImpl(backing_buffer); } + DoubleBufferImpl(short[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native short nio_get_Short(DoubleBufferImpl b, int index); private static native void nio_put_Short(DoubleBufferImpl b, int index, short value); public java.nio. ShortBuffer asShortBuffer() { return new gnu.java.nio. ShortBufferImpl(backing_buffer); } + DoubleBufferImpl(int[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native int nio_get_Int(DoubleBufferImpl b, int index); private static native void nio_put_Int(DoubleBufferImpl b, int index, int value); public java.nio. IntBuffer asIntBuffer() { return new gnu.java.nio. IntBufferImpl(backing_buffer); } + DoubleBufferImpl(long[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native long nio_get_Long(DoubleBufferImpl b, int index); private static native void nio_put_Long(DoubleBufferImpl b, int index, long value); public java.nio. LongBuffer asLongBuffer() { return new gnu.java.nio. LongBufferImpl(backing_buffer); } + DoubleBufferImpl(float[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native float nio_get_Float(DoubleBufferImpl b, int index); private static native void nio_put_Float(DoubleBufferImpl b, int index, float value); public java.nio. FloatBuffer asFloatBuffer() { return new gnu.java.nio. FloatBufferImpl(backing_buffer); } + DoubleBufferImpl(double[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native double nio_get_Double(DoubleBufferImpl b, int index); private static native void nio_put_Double(DoubleBufferImpl b, int index, double value); public java.nio. DoubleBuffer asDoubleBuffer() { return new gnu.java.nio. DoubleBufferImpl(backing_buffer); } + public boolean isReadOnly() + { + return ro; + } + public java.nio. DoubleBuffer slice() + { + DoubleBufferImpl A = new DoubleBufferImpl(this); + A.array_offset = position(); + return A; + } + public java.nio. DoubleBuffer duplicate() + { + return new DoubleBufferImpl(this); + } + public java.nio. DoubleBuffer asReadOnlyBuffer() + { + DoubleBufferImpl a = new DoubleBufferImpl(this); + a.ro = true; + return a; + } + public java.nio. DoubleBuffer compact() + { + return this; + } + public boolean isDirect() + { + return backing_buffer != null; + } + final public double get() + { + double e = backing_buffer[position()]; + position(position()+1); + return e; + } + final public java.nio. DoubleBuffer put(double b) + { + backing_buffer[position()] = b; + position(position()+1); + return this; + } + final public double get(int index) + { + return backing_buffer[index]; + } + final public java.nio. DoubleBuffer put(int index, double b) + { + backing_buffer[index] = b; + return this; + } + final public char getChar() { char a = nio_get_Char(this, position()); inc_pos(2); return a; } final public java.nio. DoubleBuffer putChar(char value) { nio_put_Char(this, position(), value); inc_pos(2); return this; } final public char getChar(int index) { char a = nio_get_Char(this, index); return a; } final public java.nio. DoubleBuffer putChar(int index, char value) { nio_put_Char(this, index, value); return this; }; + final public short getShort() { short a = nio_get_Short(this, position()); inc_pos(2); return a; } final public java.nio. DoubleBuffer putShort(short value) { nio_put_Short(this, position(), value); inc_pos(2); return this; } final public short getShort(int index) { short a = nio_get_Short(this, index); return a; } final public java.nio. DoubleBuffer putShort(int index, short value) { nio_put_Short(this, index, value); return this; }; + final public int getInt() { int a = nio_get_Int(this, position()); inc_pos(4); return a; } final public java.nio. DoubleBuffer putInt(int value) { nio_put_Int(this, position(), value); inc_pos(4); return this; } final public int getInt(int index) { int a = nio_get_Int(this, index); return a; } final public java.nio. DoubleBuffer putInt(int index, int value) { nio_put_Int(this, index, value); return this; }; + final public long getLong() { long a = nio_get_Long(this, position()); inc_pos(8); return a; } final public java.nio. DoubleBuffer putLong(long value) { nio_put_Long(this, position(), value); inc_pos(8); return this; } final public long getLong(int index) { long a = nio_get_Long(this, index); return a; } final public java.nio. DoubleBuffer putLong(int index, long value) { nio_put_Long(this, index, value); return this; }; + final public float getFloat() { float a = nio_get_Float(this, position()); inc_pos(4); return a; } final public java.nio. DoubleBuffer putFloat(float value) { nio_put_Float(this, position(), value); inc_pos(4); return this; } final public float getFloat(int index) { float a = nio_get_Float(this, index); return a; } final public java.nio. DoubleBuffer putFloat(int index, float value) { nio_put_Float(this, index, value); return this; }; + final public double getDouble() { return get(); } final public java.nio. DoubleBuffer putDouble(double value) { return put(value); } final public double getDouble(int index) { return get(index); } final public java.nio. DoubleBuffer putDouble(int index, double value) { return put(index, value); }; +} diff --git a/gnu/java/nio/FloatBufferImpl.java b/gnu/java/nio/FloatBufferImpl.java new file mode 100644 index 000000000..2b1a155ab --- /dev/null +++ b/gnu/java/nio/FloatBufferImpl.java @@ -0,0 +1,102 @@ +package gnu.java.nio; +import java.nio.*; +public final class FloatBufferImpl extends java.nio. FloatBuffer +{ + private int array_offset; + float [] backing_buffer; + private boolean ro; + public FloatBufferImpl(int cap, int off, int lim) + { + this.backing_buffer = new float[cap]; + this.capacity(cap); + this.position(off); + this.limit(lim); + } + public FloatBufferImpl(float[] array, int off, int lim) + { + this.backing_buffer = array; + this.capacity(array.length); + this.position(off); + this.limit(lim); + } + public FloatBufferImpl(FloatBufferImpl copy) + { + backing_buffer = copy.backing_buffer; + ro = copy.ro; + position(copy.position()); + limit(copy.limit()); + } + void inc_pos(int a) + { + position(position() + a); + } + private static native float[] nio_cast(byte[]copy); + private static native float[] nio_cast(char[]copy); + private static native float[] nio_cast(short[]copy); + private static native float[] nio_cast(long[]copy); + private static native float[] nio_cast(int[]copy); + private static native float[] nio_cast(float[]copy); + private static native float[] nio_cast(double[]copy); + FloatBufferImpl(byte[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native byte nio_get_Byte(FloatBufferImpl b, int index); private static native void nio_put_Byte(FloatBufferImpl b, int index, byte value); public java.nio. ByteBuffer asByteBuffer() { return new gnu.java.nio. ByteBufferImpl(backing_buffer); } + FloatBufferImpl(char[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native char nio_get_Char(FloatBufferImpl b, int index); private static native void nio_put_Char(FloatBufferImpl b, int index, char value); public java.nio. CharBuffer asCharBuffer() { return new gnu.java.nio. CharBufferImpl(backing_buffer); } + FloatBufferImpl(short[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native short nio_get_Short(FloatBufferImpl b, int index); private static native void nio_put_Short(FloatBufferImpl b, int index, short value); public java.nio. ShortBuffer asShortBuffer() { return new gnu.java.nio. ShortBufferImpl(backing_buffer); } + FloatBufferImpl(int[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native int nio_get_Int(FloatBufferImpl b, int index); private static native void nio_put_Int(FloatBufferImpl b, int index, int value); public java.nio. IntBuffer asIntBuffer() { return new gnu.java.nio. IntBufferImpl(backing_buffer); } + FloatBufferImpl(long[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native long nio_get_Long(FloatBufferImpl b, int index); private static native void nio_put_Long(FloatBufferImpl b, int index, long value); public java.nio. LongBuffer asLongBuffer() { return new gnu.java.nio. LongBufferImpl(backing_buffer); } + FloatBufferImpl(float[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native float nio_get_Float(FloatBufferImpl b, int index); private static native void nio_put_Float(FloatBufferImpl b, int index, float value); public java.nio. FloatBuffer asFloatBuffer() { return new gnu.java.nio. FloatBufferImpl(backing_buffer); } + FloatBufferImpl(double[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native double nio_get_Double(FloatBufferImpl b, int index); private static native void nio_put_Double(FloatBufferImpl b, int index, double value); public java.nio. DoubleBuffer asDoubleBuffer() { return new gnu.java.nio. DoubleBufferImpl(backing_buffer); } + public boolean isReadOnly() + { + return ro; + } + public java.nio. FloatBuffer slice() + { + FloatBufferImpl A = new FloatBufferImpl(this); + A.array_offset = position(); + return A; + } + public java.nio. FloatBuffer duplicate() + { + return new FloatBufferImpl(this); + } + public java.nio. FloatBuffer asReadOnlyBuffer() + { + FloatBufferImpl a = new FloatBufferImpl(this); + a.ro = true; + return a; + } + public java.nio. FloatBuffer compact() + { + return this; + } + public boolean isDirect() + { + return backing_buffer != null; + } + final public float get() + { + float e = backing_buffer[position()]; + position(position()+1); + return e; + } + final public java.nio. FloatBuffer put(float b) + { + backing_buffer[position()] = b; + position(position()+1); + return this; + } + final public float get(int index) + { + return backing_buffer[index]; + } + final public java.nio. FloatBuffer put(int index, float b) + { + backing_buffer[index] = b; + return this; + } + final public char getChar() { char a = nio_get_Char(this, position()); inc_pos(2); return a; } final public java.nio. FloatBuffer putChar(char value) { nio_put_Char(this, position(), value); inc_pos(2); return this; } final public char getChar(int index) { char a = nio_get_Char(this, index); return a; } final public java.nio. FloatBuffer putChar(int index, char value) { nio_put_Char(this, index, value); return this; }; + final public short getShort() { short a = nio_get_Short(this, position()); inc_pos(2); return a; } final public java.nio. FloatBuffer putShort(short value) { nio_put_Short(this, position(), value); inc_pos(2); return this; } final public short getShort(int index) { short a = nio_get_Short(this, index); return a; } final public java.nio. FloatBuffer putShort(int index, short value) { nio_put_Short(this, index, value); return this; }; + final public int getInt() { int a = nio_get_Int(this, position()); inc_pos(4); return a; } final public java.nio. FloatBuffer putInt(int value) { nio_put_Int(this, position(), value); inc_pos(4); return this; } final public int getInt(int index) { int a = nio_get_Int(this, index); return a; } final public java.nio. FloatBuffer putInt(int index, int value) { nio_put_Int(this, index, value); return this; }; + final public long getLong() { long a = nio_get_Long(this, position()); inc_pos(8); return a; } final public java.nio. FloatBuffer putLong(long value) { nio_put_Long(this, position(), value); inc_pos(8); return this; } final public long getLong(int index) { long a = nio_get_Long(this, index); return a; } final public java.nio. FloatBuffer putLong(int index, long value) { nio_put_Long(this, index, value); return this; }; + final public float getFloat() { return get(); } final public java.nio. FloatBuffer putFloat(float value) { return put(value); } final public float getFloat(int index) { return get(index); } final public java.nio. FloatBuffer putFloat(int index, float value) { return put(index, value); }; + final public double getDouble() { double a = nio_get_Double(this, position()); inc_pos(8); return a; } final public java.nio. FloatBuffer putDouble(double value) { nio_put_Double(this, position(), value); inc_pos(8); return this; } final public double getDouble(int index) { double a = nio_get_Double(this, index); return a; } final public java.nio. FloatBuffer putDouble(int index, double value) { nio_put_Double(this, index, value); return this; }; +} diff --git a/gnu/java/nio/IntBufferImpl.java b/gnu/java/nio/IntBufferImpl.java new file mode 100644 index 000000000..5453f8d01 --- /dev/null +++ b/gnu/java/nio/IntBufferImpl.java @@ -0,0 +1,102 @@ +package gnu.java.nio; +import java.nio.*; +public final class IntBufferImpl extends java.nio. IntBuffer +{ + private int array_offset; + int [] backing_buffer; + private boolean ro; + public IntBufferImpl(int cap, int off, int lim) + { + this.backing_buffer = new int[cap]; + this.capacity(cap); + this.position(off); + this.limit(lim); + } + public IntBufferImpl(int[] array, int off, int lim) + { + this.backing_buffer = array; + this.capacity(array.length); + this.position(off); + this.limit(lim); + } + public IntBufferImpl(IntBufferImpl copy) + { + backing_buffer = copy.backing_buffer; + ro = copy.ro; + position(copy.position()); + limit(copy.limit()); + } + void inc_pos(int a) + { + position(position() + a); + } + private static native int[] nio_cast(byte[]copy); + private static native int[] nio_cast(char[]copy); + private static native int[] nio_cast(short[]copy); + private static native int[] nio_cast(long[]copy); + private static native int[] nio_cast(int[]copy); + private static native int[] nio_cast(float[]copy); + private static native int[] nio_cast(double[]copy); + IntBufferImpl(byte[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native byte nio_get_Byte(IntBufferImpl b, int index); private static native void nio_put_Byte(IntBufferImpl b, int index, byte value); public java.nio. ByteBuffer asByteBuffer() { return new gnu.java.nio. ByteBufferImpl(backing_buffer); } + IntBufferImpl(char[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native char nio_get_Char(IntBufferImpl b, int index); private static native void nio_put_Char(IntBufferImpl b, int index, char value); public java.nio. CharBuffer asCharBuffer() { return new gnu.java.nio. CharBufferImpl(backing_buffer); } + IntBufferImpl(short[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native short nio_get_Short(IntBufferImpl b, int index); private static native void nio_put_Short(IntBufferImpl b, int index, short value); public java.nio. ShortBuffer asShortBuffer() { return new gnu.java.nio. ShortBufferImpl(backing_buffer); } + IntBufferImpl(int[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native int nio_get_Int(IntBufferImpl b, int index); private static native void nio_put_Int(IntBufferImpl b, int index, int value); public java.nio. IntBuffer asIntBuffer() { return new gnu.java.nio. IntBufferImpl(backing_buffer); } + IntBufferImpl(long[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native long nio_get_Long(IntBufferImpl b, int index); private static native void nio_put_Long(IntBufferImpl b, int index, long value); public java.nio. LongBuffer asLongBuffer() { return new gnu.java.nio. LongBufferImpl(backing_buffer); } + IntBufferImpl(float[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native float nio_get_Float(IntBufferImpl b, int index); private static native void nio_put_Float(IntBufferImpl b, int index, float value); public java.nio. FloatBuffer asFloatBuffer() { return new gnu.java.nio. FloatBufferImpl(backing_buffer); } + IntBufferImpl(double[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native double nio_get_Double(IntBufferImpl b, int index); private static native void nio_put_Double(IntBufferImpl b, int index, double value); public java.nio. DoubleBuffer asDoubleBuffer() { return new gnu.java.nio. DoubleBufferImpl(backing_buffer); } + public boolean isReadOnly() + { + return ro; + } + public java.nio. IntBuffer slice() + { + IntBufferImpl A = new IntBufferImpl(this); + A.array_offset = position(); + return A; + } + public java.nio. IntBuffer duplicate() + { + return new IntBufferImpl(this); + } + public java.nio. IntBuffer asReadOnlyBuffer() + { + IntBufferImpl a = new IntBufferImpl(this); + a.ro = true; + return a; + } + public java.nio. IntBuffer compact() + { + return this; + } + public boolean isDirect() + { + return backing_buffer != null; + } + final public int get() + { + int e = backing_buffer[position()]; + position(position()+1); + return e; + } + final public java.nio. IntBuffer put(int b) + { + backing_buffer[position()] = b; + position(position()+1); + return this; + } + final public int get(int index) + { + return backing_buffer[index]; + } + final public java.nio. IntBuffer put(int index, int b) + { + backing_buffer[index] = b; + return this; + } + final public char getChar() { char a = nio_get_Char(this, position()); inc_pos(2); return a; } final public java.nio. IntBuffer putChar(char value) { nio_put_Char(this, position(), value); inc_pos(2); return this; } final public char getChar(int index) { char a = nio_get_Char(this, index); return a; } final public java.nio. IntBuffer putChar(int index, char value) { nio_put_Char(this, index, value); return this; }; + final public short getShort() { short a = nio_get_Short(this, position()); inc_pos(2); return a; } final public java.nio. IntBuffer putShort(short value) { nio_put_Short(this, position(), value); inc_pos(2); return this; } final public short getShort(int index) { short a = nio_get_Short(this, index); return a; } final public java.nio. IntBuffer putShort(int index, short value) { nio_put_Short(this, index, value); return this; }; + final public int getInt() { return get(); } final public java.nio. IntBuffer putInt(int value) { return put(value); } final public int getInt(int index) { return get(index); } final public java.nio. IntBuffer putInt(int index, int value) { return put(index, value); }; + final public long getLong() { long a = nio_get_Long(this, position()); inc_pos(8); return a; } final public java.nio. IntBuffer putLong(long value) { nio_put_Long(this, position(), value); inc_pos(8); return this; } final public long getLong(int index) { long a = nio_get_Long(this, index); return a; } final public java.nio. IntBuffer putLong(int index, long value) { nio_put_Long(this, index, value); return this; }; + final public float getFloat() { float a = nio_get_Float(this, position()); inc_pos(4); return a; } final public java.nio. IntBuffer putFloat(float value) { nio_put_Float(this, position(), value); inc_pos(4); return this; } final public float getFloat(int index) { float a = nio_get_Float(this, index); return a; } final public java.nio. IntBuffer putFloat(int index, float value) { nio_put_Float(this, index, value); return this; }; + final public double getDouble() { double a = nio_get_Double(this, position()); inc_pos(8); return a; } final public java.nio. IntBuffer putDouble(double value) { nio_put_Double(this, position(), value); inc_pos(8); return this; } final public double getDouble(int index) { double a = nio_get_Double(this, index); return a; } final public java.nio. IntBuffer putDouble(int index, double value) { nio_put_Double(this, index, value); return this; }; +} diff --git a/gnu/java/nio/LongBufferImpl.java b/gnu/java/nio/LongBufferImpl.java new file mode 100644 index 000000000..67a15f702 --- /dev/null +++ b/gnu/java/nio/LongBufferImpl.java @@ -0,0 +1,102 @@ +package gnu.java.nio; +import java.nio.*; +public final class LongBufferImpl extends java.nio. LongBuffer +{ + private int array_offset; + long [] backing_buffer; + private boolean ro; + public LongBufferImpl(int cap, int off, int lim) + { + this.backing_buffer = new long[cap]; + this.capacity(cap); + this.position(off); + this.limit(lim); + } + public LongBufferImpl(long[] array, int off, int lim) + { + this.backing_buffer = array; + this.capacity(array.length); + this.position(off); + this.limit(lim); + } + public LongBufferImpl(LongBufferImpl copy) + { + backing_buffer = copy.backing_buffer; + ro = copy.ro; + position(copy.position()); + limit(copy.limit()); + } + void inc_pos(int a) + { + position(position() + a); + } + private static native long[] nio_cast(byte[]copy); + private static native long[] nio_cast(char[]copy); + private static native long[] nio_cast(short[]copy); + private static native long[] nio_cast(long[]copy); + private static native long[] nio_cast(int[]copy); + private static native long[] nio_cast(float[]copy); + private static native long[] nio_cast(double[]copy); + LongBufferImpl(byte[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native byte nio_get_Byte(LongBufferImpl b, int index); private static native void nio_put_Byte(LongBufferImpl b, int index, byte value); public java.nio. ByteBuffer asByteBuffer() { return new gnu.java.nio. ByteBufferImpl(backing_buffer); } + LongBufferImpl(char[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native char nio_get_Char(LongBufferImpl b, int index); private static native void nio_put_Char(LongBufferImpl b, int index, char value); public java.nio. CharBuffer asCharBuffer() { return new gnu.java.nio. CharBufferImpl(backing_buffer); } + LongBufferImpl(short[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native short nio_get_Short(LongBufferImpl b, int index); private static native void nio_put_Short(LongBufferImpl b, int index, short value); public java.nio. ShortBuffer asShortBuffer() { return new gnu.java.nio. ShortBufferImpl(backing_buffer); } + LongBufferImpl(int[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native int nio_get_Int(LongBufferImpl b, int index); private static native void nio_put_Int(LongBufferImpl b, int index, int value); public java.nio. IntBuffer asIntBuffer() { return new gnu.java.nio. IntBufferImpl(backing_buffer); } + LongBufferImpl(long[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native long nio_get_Long(LongBufferImpl b, int index); private static native void nio_put_Long(LongBufferImpl b, int index, long value); public java.nio. LongBuffer asLongBuffer() { return new gnu.java.nio. LongBufferImpl(backing_buffer); } + LongBufferImpl(float[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native float nio_get_Float(LongBufferImpl b, int index); private static native void nio_put_Float(LongBufferImpl b, int index, float value); public java.nio. FloatBuffer asFloatBuffer() { return new gnu.java.nio. FloatBufferImpl(backing_buffer); } + LongBufferImpl(double[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native double nio_get_Double(LongBufferImpl b, int index); private static native void nio_put_Double(LongBufferImpl b, int index, double value); public java.nio. DoubleBuffer asDoubleBuffer() { return new gnu.java.nio. DoubleBufferImpl(backing_buffer); } + public boolean isReadOnly() + { + return ro; + } + public java.nio. LongBuffer slice() + { + LongBufferImpl A = new LongBufferImpl(this); + A.array_offset = position(); + return A; + } + public java.nio. LongBuffer duplicate() + { + return new LongBufferImpl(this); + } + public java.nio. LongBuffer asReadOnlyBuffer() + { + LongBufferImpl a = new LongBufferImpl(this); + a.ro = true; + return a; + } + public java.nio. LongBuffer compact() + { + return this; + } + public boolean isDirect() + { + return backing_buffer != null; + } + final public long get() + { + long e = backing_buffer[position()]; + position(position()+1); + return e; + } + final public java.nio. LongBuffer put(long b) + { + backing_buffer[position()] = b; + position(position()+1); + return this; + } + final public long get(int index) + { + return backing_buffer[index]; + } + final public java.nio. LongBuffer put(int index, long b) + { + backing_buffer[index] = b; + return this; + } + final public char getChar() { char a = nio_get_Char(this, position()); inc_pos(2); return a; } final public java.nio. LongBuffer putChar(char value) { nio_put_Char(this, position(), value); inc_pos(2); return this; } final public char getChar(int index) { char a = nio_get_Char(this, index); return a; } final public java.nio. LongBuffer putChar(int index, char value) { nio_put_Char(this, index, value); return this; }; + final public short getShort() { short a = nio_get_Short(this, position()); inc_pos(2); return a; } final public java.nio. LongBuffer putShort(short value) { nio_put_Short(this, position(), value); inc_pos(2); return this; } final public short getShort(int index) { short a = nio_get_Short(this, index); return a; } final public java.nio. LongBuffer putShort(int index, short value) { nio_put_Short(this, index, value); return this; }; + final public int getInt() { int a = nio_get_Int(this, position()); inc_pos(4); return a; } final public java.nio. LongBuffer putInt(int value) { nio_put_Int(this, position(), value); inc_pos(4); return this; } final public int getInt(int index) { int a = nio_get_Int(this, index); return a; } final public java.nio. LongBuffer putInt(int index, int value) { nio_put_Int(this, index, value); return this; }; + final public long getLong() { return get(); } final public java.nio. LongBuffer putLong(long value) { return put(value); } final public long getLong(int index) { return get(index); } final public java.nio. LongBuffer putLong(int index, long value) { return put(index, value); }; + final public float getFloat() { float a = nio_get_Float(this, position()); inc_pos(4); return a; } final public java.nio. LongBuffer putFloat(float value) { nio_put_Float(this, position(), value); inc_pos(4); return this; } final public float getFloat(int index) { float a = nio_get_Float(this, index); return a; } final public java.nio. LongBuffer putFloat(int index, float value) { nio_put_Float(this, index, value); return this; }; + final public double getDouble() { double a = nio_get_Double(this, position()); inc_pos(8); return a; } final public java.nio. LongBuffer putDouble(double value) { nio_put_Double(this, position(), value); inc_pos(8); return this; } final public double getDouble(int index) { double a = nio_get_Double(this, index); return a; } final public java.nio. LongBuffer putDouble(int index, double value) { nio_put_Double(this, index, value); return this; }; +} diff --git a/gnu/java/nio/MappedByteFileBuffer.java b/gnu/java/nio/MappedByteFileBuffer.java new file mode 100644 index 000000000..0988fffb1 --- /dev/null +++ b/gnu/java/nio/MappedByteFileBuffer.java @@ -0,0 +1,84 @@ +package gnu.java.nio; +import java.nio.*; +final public class MappedByteFileBuffer + extends MappedByteBuffer +{ + public long address; + boolean ro; + boolean direct; + public FileChannelImpl ch; + public MappedByteFileBuffer(FileChannelImpl ch) + { + this.ch = ch; + address = ch.address; + } + public MappedByteFileBuffer(MappedByteFileBuffer b) + { + this.ro = b.ro; + this.ch = b.ch; + address = b.address; + } + public boolean isReadOnly() + { + return ro; + } + public static native byte nio_read_Byte_file_channel(FileChannelImpl ch, int index); public static native void nio_write_Byte_file_channel(FileChannelImpl ch, int index, byte value); + public static native short nio_read_Short_file_channel(FileChannelImpl ch, int index); public static native void nio_write_Short_file_channel(FileChannelImpl ch, int index, short value); + public static native char nio_read_Char_file_channel(FileChannelImpl ch, int index); public static native void nio_write_Char_file_channel(FileChannelImpl ch, int index, char value); + public static native int nio_read_Int_file_channel(FileChannelImpl ch, int index); public static native void nio_write_Int_file_channel(FileChannelImpl ch, int index, int value); + public static native long nio_read_Long_file_channel(FileChannelImpl ch, int index); public static native void nio_write_Long_file_channel(FileChannelImpl ch, int index, long value); + public static native float nio_read_Float_file_channel(FileChannelImpl ch, int index); public static native void nio_write_Float_file_channel(FileChannelImpl ch, int index, float value); + public static native double nio_read_Double_file_channel(FileChannelImpl ch, int index); public static native void nio_write_Double_file_channel(FileChannelImpl ch, int index, double value); +final public byte get() + { + byte a = MappedByteFileBuffer.nio_read_Byte_file_channel(ch, position()); + position(position() + 1); + return a; + } +final public ByteBuffer put(byte b) + { + MappedByteFileBuffer.nio_write_Byte_file_channel(ch, position(), b); + position(position() + 1); + return this; + } +final public byte get(int index) + { + byte a = MappedByteFileBuffer.nio_read_Byte_file_channel(ch, index); + return a; + } +final public ByteBuffer put(int index, byte b) + { + MappedByteFileBuffer.nio_write_Byte_file_channel(ch, index, b); + return this; + } +final public ByteBuffer compact() + { + return this; + } +final public boolean isDirect() + { + return direct; + } +final public ByteBuffer slice() + { + MappedByteFileBuffer A = new MappedByteFileBuffer(this); + return A; + } +public ByteBuffer duplicate() + { + return new MappedByteFileBuffer(this); + } +public ByteBuffer asReadOnlyBuffer() + { + MappedByteFileBuffer b = new MappedByteFileBuffer(this); + b.ro = true; + return b; + } + final public ByteBuffer asByteBuffer() { return new MappedByteFileBuffer(ch); } final public byte getByte() { byte a = MappedByteFileBuffer.nio_read_Byte_file_channel(ch, position()); position(position() + 1); return a; } final public ByteBuffer putByte(byte value) { MappedByteFileBuffer.nio_write_Byte_file_channel(ch, position(), value); position(position() + 1); return this; } final public byte getByte(int index) { byte a = MappedByteFileBuffer.nio_read_Byte_file_channel(ch, index); return a; } final public ByteBuffer putByte(int index, byte value) { MappedByteFileBuffer.nio_write_Byte_file_channel(ch, index, value); return this; }; + final public CharBuffer asCharBuffer() { return new MappedCharFileBuffer(ch); } final public char getChar() { char a = MappedByteFileBuffer.nio_read_Char_file_channel(ch, position()); position(position() + 1); return a; } final public ByteBuffer putChar(char value) { MappedByteFileBuffer.nio_write_Char_file_channel(ch, position(), value); position(position() + 1); return this; } final public char getChar(int index) { char a = MappedByteFileBuffer.nio_read_Char_file_channel(ch, index); return a; } final public ByteBuffer putChar(int index, char value) { MappedByteFileBuffer.nio_write_Char_file_channel(ch, index, value); return this; }; + final public ShortBuffer asShortBuffer() { return new MappedShortFileBuffer(ch); } final public short getShort() { short a = MappedByteFileBuffer.nio_read_Short_file_channel(ch, position()); position(position() + 1); return a; } final public ByteBuffer putShort(short value) { MappedByteFileBuffer.nio_write_Short_file_channel(ch, position(), value); position(position() + 1); return this; } final public short getShort(int index) { short a = MappedByteFileBuffer.nio_read_Short_file_channel(ch, index); return a; } final public ByteBuffer putShort(int index, short value) { MappedByteFileBuffer.nio_write_Short_file_channel(ch, index, value); return this; }; + final public IntBuffer asIntBuffer() { return new MappedIntFileBuffer(ch); } final public int getInt() { int a = MappedByteFileBuffer.nio_read_Int_file_channel(ch, position()); position(position() + 1); return a; } final public ByteBuffer putInt(int value) { MappedByteFileBuffer.nio_write_Int_file_channel(ch, position(), value); position(position() + 1); return this; } final public int getInt(int index) { int a = MappedByteFileBuffer.nio_read_Int_file_channel(ch, index); return a; } final public ByteBuffer putInt(int index, int value) { MappedByteFileBuffer.nio_write_Int_file_channel(ch, index, value); return this; }; + final public LongBuffer asLongBuffer() { return new MappedLongFileBuffer(ch); } final public long getLong() { long a = MappedByteFileBuffer.nio_read_Long_file_channel(ch, position()); position(position() + 1); return a; } final public ByteBuffer putLong(long value) { MappedByteFileBuffer.nio_write_Long_file_channel(ch, position(), value); position(position() + 1); return this; } final public long getLong(int index) { long a = MappedByteFileBuffer.nio_read_Long_file_channel(ch, index); return a; } final public ByteBuffer putLong(int index, long value) { MappedByteFileBuffer.nio_write_Long_file_channel(ch, index, value); return this; }; + final public FloatBuffer asFloatBuffer() { return new MappedFloatFileBuffer(ch); } final public float getFloat() { float a = MappedByteFileBuffer.nio_read_Float_file_channel(ch, position()); position(position() + 1); return a; } final public ByteBuffer putFloat(float value) { MappedByteFileBuffer.nio_write_Float_file_channel(ch, position(), value); position(position() + 1); return this; } final public float getFloat(int index) { float a = MappedByteFileBuffer.nio_read_Float_file_channel(ch, index); return a; } final public ByteBuffer putFloat(int index, float value) { MappedByteFileBuffer.nio_write_Float_file_channel(ch, index, value); return this; }; + final public DoubleBuffer asDoubleBuffer() { return new MappedDoubleFileBuffer(ch); } final public double getDouble() { double a = MappedByteFileBuffer.nio_read_Double_file_channel(ch, position()); position(position() + 1); return a; } final public ByteBuffer putDouble(double value) { MappedByteFileBuffer.nio_write_Double_file_channel(ch, position(), value); position(position() + 1); return this; } final public double getDouble(int index) { double a = MappedByteFileBuffer.nio_read_Double_file_channel(ch, index); return a; } final public ByteBuffer putDouble(int index, double value) { MappedByteFileBuffer.nio_write_Double_file_channel(ch, index, value); return this; }; +} diff --git a/gnu/java/nio/MappedCharFileBuffer.java b/gnu/java/nio/MappedCharFileBuffer.java new file mode 100644 index 000000000..6b46c077a --- /dev/null +++ b/gnu/java/nio/MappedCharFileBuffer.java @@ -0,0 +1,77 @@ +package gnu.java.nio; +import java.nio.*; +final public class MappedCharFileBuffer + extends CharBuffer +{ + public long address; + boolean ro; + boolean direct; + public FileChannelImpl ch; + public MappedCharFileBuffer(FileChannelImpl ch) + { + this.ch = ch; + address = ch.address; + } + public MappedCharFileBuffer(MappedCharFileBuffer b) + { + this.ro = b.ro; + this.ch = b.ch; + address = b.address; + } + public boolean isReadOnly() + { + return ro; + } +final public char get() + { + char a = MappedByteFileBuffer.nio_read_Char_file_channel(ch, position()); + position(position() + 2); + return a; + } +final public CharBuffer put(char b) + { + MappedByteFileBuffer.nio_write_Char_file_channel(ch, position(), b); + position(position() + 2); + return this; + } +final public char get(int index) + { + char a = MappedByteFileBuffer.nio_read_Char_file_channel(ch, index); + return a; + } +final public CharBuffer put(int index, char b) + { + MappedByteFileBuffer.nio_write_Char_file_channel(ch, index, b); + return this; + } +final public CharBuffer compact() + { + return this; + } +final public boolean isDirect() + { + return direct; + } +final public CharBuffer slice() + { + MappedCharFileBuffer A = new MappedCharFileBuffer(this); + return A; + } +public CharBuffer duplicate() + { + return new MappedCharFileBuffer(this); + } +public CharBuffer asReadOnlyBuffer() + { + MappedCharFileBuffer b = new MappedCharFileBuffer(this); + b.ro = true; + return b; + } + final public ByteBuffer asByteBuffer() { return new MappedByteFileBuffer(ch); } final public byte getByte() { byte a = MappedByteFileBuffer.nio_read_Byte_file_channel(ch, position()); position(position() + 2); return a; } final public CharBuffer putByte(byte value) { MappedByteFileBuffer.nio_write_Byte_file_channel(ch, position(), value); position(position() + 2); return this; } final public byte getByte(int index) { byte a = MappedByteFileBuffer.nio_read_Byte_file_channel(ch, index); return a; } final public CharBuffer putByte(int index, byte value) { MappedByteFileBuffer.nio_write_Byte_file_channel(ch, index, value); return this; }; + final public CharBuffer asCharBuffer() { return new MappedCharFileBuffer(ch); } final public char getChar() { char a = MappedByteFileBuffer.nio_read_Char_file_channel(ch, position()); position(position() + 2); return a; } final public CharBuffer putChar(char value) { MappedByteFileBuffer.nio_write_Char_file_channel(ch, position(), value); position(position() + 2); return this; } final public char getChar(int index) { char a = MappedByteFileBuffer.nio_read_Char_file_channel(ch, index); return a; } final public CharBuffer putChar(int index, char value) { MappedByteFileBuffer.nio_write_Char_file_channel(ch, index, value); return this; }; + final public ShortBuffer asShortBuffer() { return new MappedShortFileBuffer(ch); } final public short getShort() { short a = MappedByteFileBuffer.nio_read_Short_file_channel(ch, position()); position(position() + 2); return a; } final public CharBuffer putShort(short value) { MappedByteFileBuffer.nio_write_Short_file_channel(ch, position(), value); position(position() + 2); return this; } final public short getShort(int index) { short a = MappedByteFileBuffer.nio_read_Short_file_channel(ch, index); return a; } final public CharBuffer putShort(int index, short value) { MappedByteFileBuffer.nio_write_Short_file_channel(ch, index, value); return this; }; + final public IntBuffer asIntBuffer() { return new MappedIntFileBuffer(ch); } final public int getInt() { int a = MappedByteFileBuffer.nio_read_Int_file_channel(ch, position()); position(position() + 2); return a; } final public CharBuffer putInt(int value) { MappedByteFileBuffer.nio_write_Int_file_channel(ch, position(), value); position(position() + 2); return this; } final public int getInt(int index) { int a = MappedByteFileBuffer.nio_read_Int_file_channel(ch, index); return a; } final public CharBuffer putInt(int index, int value) { MappedByteFileBuffer.nio_write_Int_file_channel(ch, index, value); return this; }; + final public LongBuffer asLongBuffer() { return new MappedLongFileBuffer(ch); } final public long getLong() { long a = MappedByteFileBuffer.nio_read_Long_file_channel(ch, position()); position(position() + 2); return a; } final public CharBuffer putLong(long value) { MappedByteFileBuffer.nio_write_Long_file_channel(ch, position(), value); position(position() + 2); return this; } final public long getLong(int index) { long a = MappedByteFileBuffer.nio_read_Long_file_channel(ch, index); return a; } final public CharBuffer putLong(int index, long value) { MappedByteFileBuffer.nio_write_Long_file_channel(ch, index, value); return this; }; + final public FloatBuffer asFloatBuffer() { return new MappedFloatFileBuffer(ch); } final public float getFloat() { float a = MappedByteFileBuffer.nio_read_Float_file_channel(ch, position()); position(position() + 2); return a; } final public CharBuffer putFloat(float value) { MappedByteFileBuffer.nio_write_Float_file_channel(ch, position(), value); position(position() + 2); return this; } final public float getFloat(int index) { float a = MappedByteFileBuffer.nio_read_Float_file_channel(ch, index); return a; } final public CharBuffer putFloat(int index, float value) { MappedByteFileBuffer.nio_write_Float_file_channel(ch, index, value); return this; }; + final public DoubleBuffer asDoubleBuffer() { return new MappedDoubleFileBuffer(ch); } final public double getDouble() { double a = MappedByteFileBuffer.nio_read_Double_file_channel(ch, position()); position(position() + 2); return a; } final public CharBuffer putDouble(double value) { MappedByteFileBuffer.nio_write_Double_file_channel(ch, position(), value); position(position() + 2); return this; } final public double getDouble(int index) { double a = MappedByteFileBuffer.nio_read_Double_file_channel(ch, index); return a; } final public CharBuffer putDouble(int index, double value) { MappedByteFileBuffer.nio_write_Double_file_channel(ch, index, value); return this; }; +} diff --git a/gnu/java/nio/MappedDoubleFileBuffer.java b/gnu/java/nio/MappedDoubleFileBuffer.java new file mode 100644 index 000000000..4a8cd8b00 --- /dev/null +++ b/gnu/java/nio/MappedDoubleFileBuffer.java @@ -0,0 +1,77 @@ +package gnu.java.nio; +import java.nio.*; +final public class MappedDoubleFileBuffer + extends DoubleBuffer +{ + public long address; + boolean ro; + boolean direct; + public FileChannelImpl ch; + public MappedDoubleFileBuffer(FileChannelImpl ch) + { + this.ch = ch; + address = ch.address; + } + public MappedDoubleFileBuffer(MappedDoubleFileBuffer b) + { + this.ro = b.ro; + this.ch = b.ch; + address = b.address; + } + public boolean isReadOnly() + { + return ro; + } +final public double get() + { + double a = MappedByteFileBuffer.nio_read_Double_file_channel(ch, position()); + position(position() + 8); + return a; + } +final public DoubleBuffer put(double b) + { + MappedByteFileBuffer.nio_write_Double_file_channel(ch, position(), b); + position(position() + 8); + return this; + } +final public double get(int index) + { + double a = MappedByteFileBuffer.nio_read_Double_file_channel(ch, index); + return a; + } +final public DoubleBuffer put(int index, double b) + { + MappedByteFileBuffer.nio_write_Double_file_channel(ch, index, b); + return this; + } +final public DoubleBuffer compact() + { + return this; + } +final public boolean isDirect() + { + return direct; + } +final public DoubleBuffer slice() + { + MappedDoubleFileBuffer A = new MappedDoubleFileBuffer(this); + return A; + } +public DoubleBuffer duplicate() + { + return new MappedDoubleFileBuffer(this); + } +public DoubleBuffer asReadOnlyBuffer() + { + MappedDoubleFileBuffer b = new MappedDoubleFileBuffer(this); + b.ro = true; + return b; + } + final public ByteBuffer asByteBuffer() { return new MappedByteFileBuffer(ch); } final public byte getByte() { byte a = MappedByteFileBuffer.nio_read_Byte_file_channel(ch, position()); position(position() + 8); return a; } final public DoubleBuffer putByte(byte value) { MappedByteFileBuffer.nio_write_Byte_file_channel(ch, position(), value); position(position() + 8); return this; } final public byte getByte(int index) { byte a = MappedByteFileBuffer.nio_read_Byte_file_channel(ch, index); return a; } final public DoubleBuffer putByte(int index, byte value) { MappedByteFileBuffer.nio_write_Byte_file_channel(ch, index, value); return this; }; + final public CharBuffer asCharBuffer() { return new MappedCharFileBuffer(ch); } final public char getChar() { char a = MappedByteFileBuffer.nio_read_Char_file_channel(ch, position()); position(position() + 8); return a; } final public DoubleBuffer putChar(char value) { MappedByteFileBuffer.nio_write_Char_file_channel(ch, position(), value); position(position() + 8); return this; } final public char getChar(int index) { char a = MappedByteFileBuffer.nio_read_Char_file_channel(ch, index); return a; } final public DoubleBuffer putChar(int index, char value) { MappedByteFileBuffer.nio_write_Char_file_channel(ch, index, value); return this; }; + final public ShortBuffer asShortBuffer() { return new MappedShortFileBuffer(ch); } final public short getShort() { short a = MappedByteFileBuffer.nio_read_Short_file_channel(ch, position()); position(position() + 8); return a; } final public DoubleBuffer putShort(short value) { MappedByteFileBuffer.nio_write_Short_file_channel(ch, position(), value); position(position() + 8); return this; } final public short getShort(int index) { short a = MappedByteFileBuffer.nio_read_Short_file_channel(ch, index); return a; } final public DoubleBuffer putShort(int index, short value) { MappedByteFileBuffer.nio_write_Short_file_channel(ch, index, value); return this; }; + final public IntBuffer asIntBuffer() { return new MappedIntFileBuffer(ch); } final public int getInt() { int a = MappedByteFileBuffer.nio_read_Int_file_channel(ch, position()); position(position() + 8); return a; } final public DoubleBuffer putInt(int value) { MappedByteFileBuffer.nio_write_Int_file_channel(ch, position(), value); position(position() + 8); return this; } final public int getInt(int index) { int a = MappedByteFileBuffer.nio_read_Int_file_channel(ch, index); return a; } final public DoubleBuffer putInt(int index, int value) { MappedByteFileBuffer.nio_write_Int_file_channel(ch, index, value); return this; }; + final public LongBuffer asLongBuffer() { return new MappedLongFileBuffer(ch); } final public long getLong() { long a = MappedByteFileBuffer.nio_read_Long_file_channel(ch, position()); position(position() + 8); return a; } final public DoubleBuffer putLong(long value) { MappedByteFileBuffer.nio_write_Long_file_channel(ch, position(), value); position(position() + 8); return this; } final public long getLong(int index) { long a = MappedByteFileBuffer.nio_read_Long_file_channel(ch, index); return a; } final public DoubleBuffer putLong(int index, long value) { MappedByteFileBuffer.nio_write_Long_file_channel(ch, index, value); return this; }; + final public FloatBuffer asFloatBuffer() { return new MappedFloatFileBuffer(ch); } final public float getFloat() { float a = MappedByteFileBuffer.nio_read_Float_file_channel(ch, position()); position(position() + 8); return a; } final public DoubleBuffer putFloat(float value) { MappedByteFileBuffer.nio_write_Float_file_channel(ch, position(), value); position(position() + 8); return this; } final public float getFloat(int index) { float a = MappedByteFileBuffer.nio_read_Float_file_channel(ch, index); return a; } final public DoubleBuffer putFloat(int index, float value) { MappedByteFileBuffer.nio_write_Float_file_channel(ch, index, value); return this; }; + final public DoubleBuffer asDoubleBuffer() { return new MappedDoubleFileBuffer(ch); } final public double getDouble() { double a = MappedByteFileBuffer.nio_read_Double_file_channel(ch, position()); position(position() + 8); return a; } final public DoubleBuffer putDouble(double value) { MappedByteFileBuffer.nio_write_Double_file_channel(ch, position(), value); position(position() + 8); return this; } final public double getDouble(int index) { double a = MappedByteFileBuffer.nio_read_Double_file_channel(ch, index); return a; } final public DoubleBuffer putDouble(int index, double value) { MappedByteFileBuffer.nio_write_Double_file_channel(ch, index, value); return this; }; +} diff --git a/gnu/java/nio/MappedFloatFileBuffer.java b/gnu/java/nio/MappedFloatFileBuffer.java new file mode 100644 index 000000000..35cf872ee --- /dev/null +++ b/gnu/java/nio/MappedFloatFileBuffer.java @@ -0,0 +1,77 @@ +package gnu.java.nio; +import java.nio.*; +final public class MappedFloatFileBuffer + extends FloatBuffer +{ + public long address; + boolean ro; + boolean direct; + public FileChannelImpl ch; + public MappedFloatFileBuffer(FileChannelImpl ch) + { + this.ch = ch; + address = ch.address; + } + public MappedFloatFileBuffer(MappedFloatFileBuffer b) + { + this.ro = b.ro; + this.ch = b.ch; + address = b.address; + } + public boolean isReadOnly() + { + return ro; + } +final public float get() + { + float a = MappedByteFileBuffer.nio_read_Float_file_channel(ch, position()); + position(position() + 4); + return a; + } +final public FloatBuffer put(float b) + { + MappedByteFileBuffer.nio_write_Float_file_channel(ch, position(), b); + position(position() + 4); + return this; + } +final public float get(int index) + { + float a = MappedByteFileBuffer.nio_read_Float_file_channel(ch, index); + return a; + } +final public FloatBuffer put(int index, float b) + { + MappedByteFileBuffer.nio_write_Float_file_channel(ch, index, b); + return this; + } +final public FloatBuffer compact() + { + return this; + } +final public boolean isDirect() + { + return direct; + } +final public FloatBuffer slice() + { + MappedFloatFileBuffer A = new MappedFloatFileBuffer(this); + return A; + } +public FloatBuffer duplicate() + { + return new MappedFloatFileBuffer(this); + } +public FloatBuffer asReadOnlyBuffer() + { + MappedFloatFileBuffer b = new MappedFloatFileBuffer(this); + b.ro = true; + return b; + } + final public ByteBuffer asByteBuffer() { return new MappedByteFileBuffer(ch); } final public byte getByte() { byte a = MappedByteFileBuffer.nio_read_Byte_file_channel(ch, position()); position(position() + 4); return a; } final public FloatBuffer putByte(byte value) { MappedByteFileBuffer.nio_write_Byte_file_channel(ch, position(), value); position(position() + 4); return this; } final public byte getByte(int index) { byte a = MappedByteFileBuffer.nio_read_Byte_file_channel(ch, index); return a; } final public FloatBuffer putByte(int index, byte value) { MappedByteFileBuffer.nio_write_Byte_file_channel(ch, index, value); return this; }; + final public CharBuffer asCharBuffer() { return new MappedCharFileBuffer(ch); } final public char getChar() { char a = MappedByteFileBuffer.nio_read_Char_file_channel(ch, position()); position(position() + 4); return a; } final public FloatBuffer putChar(char value) { MappedByteFileBuffer.nio_write_Char_file_channel(ch, position(), value); position(position() + 4); return this; } final public char getChar(int index) { char a = MappedByteFileBuffer.nio_read_Char_file_channel(ch, index); return a; } final public FloatBuffer putChar(int index, char value) { MappedByteFileBuffer.nio_write_Char_file_channel(ch, index, value); return this; }; + final public ShortBuffer asShortBuffer() { return new MappedShortFileBuffer(ch); } final public short getShort() { short a = MappedByteFileBuffer.nio_read_Short_file_channel(ch, position()); position(position() + 4); return a; } final public FloatBuffer putShort(short value) { MappedByteFileBuffer.nio_write_Short_file_channel(ch, position(), value); position(position() + 4); return this; } final public short getShort(int index) { short a = MappedByteFileBuffer.nio_read_Short_file_channel(ch, index); return a; } final public FloatBuffer putShort(int index, short value) { MappedByteFileBuffer.nio_write_Short_file_channel(ch, index, value); return this; }; + final public IntBuffer asIntBuffer() { return new MappedIntFileBuffer(ch); } final public int getInt() { int a = MappedByteFileBuffer.nio_read_Int_file_channel(ch, position()); position(position() + 4); return a; } final public FloatBuffer putInt(int value) { MappedByteFileBuffer.nio_write_Int_file_channel(ch, position(), value); position(position() + 4); return this; } final public int getInt(int index) { int a = MappedByteFileBuffer.nio_read_Int_file_channel(ch, index); return a; } final public FloatBuffer putInt(int index, int value) { MappedByteFileBuffer.nio_write_Int_file_channel(ch, index, value); return this; }; + final public LongBuffer asLongBuffer() { return new MappedLongFileBuffer(ch); } final public long getLong() { long a = MappedByteFileBuffer.nio_read_Long_file_channel(ch, position()); position(position() + 4); return a; } final public FloatBuffer putLong(long value) { MappedByteFileBuffer.nio_write_Long_file_channel(ch, position(), value); position(position() + 4); return this; } final public long getLong(int index) { long a = MappedByteFileBuffer.nio_read_Long_file_channel(ch, index); return a; } final public FloatBuffer putLong(int index, long value) { MappedByteFileBuffer.nio_write_Long_file_channel(ch, index, value); return this; }; + final public FloatBuffer asFloatBuffer() { return new MappedFloatFileBuffer(ch); } final public float getFloat() { float a = MappedByteFileBuffer.nio_read_Float_file_channel(ch, position()); position(position() + 4); return a; } final public FloatBuffer putFloat(float value) { MappedByteFileBuffer.nio_write_Float_file_channel(ch, position(), value); position(position() + 4); return this; } final public float getFloat(int index) { float a = MappedByteFileBuffer.nio_read_Float_file_channel(ch, index); return a; } final public FloatBuffer putFloat(int index, float value) { MappedByteFileBuffer.nio_write_Float_file_channel(ch, index, value); return this; }; + final public DoubleBuffer asDoubleBuffer() { return new MappedDoubleFileBuffer(ch); } final public double getDouble() { double a = MappedByteFileBuffer.nio_read_Double_file_channel(ch, position()); position(position() + 4); return a; } final public FloatBuffer putDouble(double value) { MappedByteFileBuffer.nio_write_Double_file_channel(ch, position(), value); position(position() + 4); return this; } final public double getDouble(int index) { double a = MappedByteFileBuffer.nio_read_Double_file_channel(ch, index); return a; } final public FloatBuffer putDouble(int index, double value) { MappedByteFileBuffer.nio_write_Double_file_channel(ch, index, value); return this; }; +} diff --git a/gnu/java/nio/MappedIntFileBuffer.java b/gnu/java/nio/MappedIntFileBuffer.java new file mode 100644 index 000000000..033f0c7c3 --- /dev/null +++ b/gnu/java/nio/MappedIntFileBuffer.java @@ -0,0 +1,77 @@ +package gnu.java.nio; +import java.nio.*; +final public class MappedIntFileBuffer + extends IntBuffer +{ + public long address; + boolean ro; + boolean direct; + public FileChannelImpl ch; + public MappedIntFileBuffer(FileChannelImpl ch) + { + this.ch = ch; + address = ch.address; + } + public MappedIntFileBuffer(MappedIntFileBuffer b) + { + this.ro = b.ro; + this.ch = b.ch; + address = b.address; + } + public boolean isReadOnly() + { + return ro; + } +final public int get() + { + int a = MappedByteFileBuffer.nio_read_Int_file_channel(ch, position()); + position(position() + 4); + return a; + } +final public IntBuffer put(int b) + { + MappedByteFileBuffer.nio_write_Int_file_channel(ch, position(), b); + position(position() + 4); + return this; + } +final public int get(int index) + { + int a = MappedByteFileBuffer.nio_read_Int_file_channel(ch, index); + return a; + } +final public IntBuffer put(int index, int b) + { + MappedByteFileBuffer.nio_write_Int_file_channel(ch, index, b); + return this; + } +final public IntBuffer compact() + { + return this; + } +final public boolean isDirect() + { + return direct; + } +final public IntBuffer slice() + { + MappedIntFileBuffer A = new MappedIntFileBuffer(this); + return A; + } +public IntBuffer duplicate() + { + return new MappedIntFileBuffer(this); + } +public IntBuffer asReadOnlyBuffer() + { + MappedIntFileBuffer b = new MappedIntFileBuffer(this); + b.ro = true; + return b; + } + final public ByteBuffer asByteBuffer() { return new MappedByteFileBuffer(ch); } final public byte getByte() { byte a = MappedByteFileBuffer.nio_read_Byte_file_channel(ch, position()); position(position() + 4); return a; } final public IntBuffer putByte(byte value) { MappedByteFileBuffer.nio_write_Byte_file_channel(ch, position(), value); position(position() + 4); return this; } final public byte getByte(int index) { byte a = MappedByteFileBuffer.nio_read_Byte_file_channel(ch, index); return a; } final public IntBuffer putByte(int index, byte value) { MappedByteFileBuffer.nio_write_Byte_file_channel(ch, index, value); return this; }; + final public CharBuffer asCharBuffer() { return new MappedCharFileBuffer(ch); } final public char getChar() { char a = MappedByteFileBuffer.nio_read_Char_file_channel(ch, position()); position(position() + 4); return a; } final public IntBuffer putChar(char value) { MappedByteFileBuffer.nio_write_Char_file_channel(ch, position(), value); position(position() + 4); return this; } final public char getChar(int index) { char a = MappedByteFileBuffer.nio_read_Char_file_channel(ch, index); return a; } final public IntBuffer putChar(int index, char value) { MappedByteFileBuffer.nio_write_Char_file_channel(ch, index, value); return this; }; + final public ShortBuffer asShortBuffer() { return new MappedShortFileBuffer(ch); } final public short getShort() { short a = MappedByteFileBuffer.nio_read_Short_file_channel(ch, position()); position(position() + 4); return a; } final public IntBuffer putShort(short value) { MappedByteFileBuffer.nio_write_Short_file_channel(ch, position(), value); position(position() + 4); return this; } final public short getShort(int index) { short a = MappedByteFileBuffer.nio_read_Short_file_channel(ch, index); return a; } final public IntBuffer putShort(int index, short value) { MappedByteFileBuffer.nio_write_Short_file_channel(ch, index, value); return this; }; + final public IntBuffer asIntBuffer() { return new MappedIntFileBuffer(ch); } final public int getInt() { int a = MappedByteFileBuffer.nio_read_Int_file_channel(ch, position()); position(position() + 4); return a; } final public IntBuffer putInt(int value) { MappedByteFileBuffer.nio_write_Int_file_channel(ch, position(), value); position(position() + 4); return this; } final public int getInt(int index) { int a = MappedByteFileBuffer.nio_read_Int_file_channel(ch, index); return a; } final public IntBuffer putInt(int index, int value) { MappedByteFileBuffer.nio_write_Int_file_channel(ch, index, value); return this; }; + final public LongBuffer asLongBuffer() { return new MappedLongFileBuffer(ch); } final public long getLong() { long a = MappedByteFileBuffer.nio_read_Long_file_channel(ch, position()); position(position() + 4); return a; } final public IntBuffer putLong(long value) { MappedByteFileBuffer.nio_write_Long_file_channel(ch, position(), value); position(position() + 4); return this; } final public long getLong(int index) { long a = MappedByteFileBuffer.nio_read_Long_file_channel(ch, index); return a; } final public IntBuffer putLong(int index, long value) { MappedByteFileBuffer.nio_write_Long_file_channel(ch, index, value); return this; }; + final public FloatBuffer asFloatBuffer() { return new MappedFloatFileBuffer(ch); } final public float getFloat() { float a = MappedByteFileBuffer.nio_read_Float_file_channel(ch, position()); position(position() + 4); return a; } final public IntBuffer putFloat(float value) { MappedByteFileBuffer.nio_write_Float_file_channel(ch, position(), value); position(position() + 4); return this; } final public float getFloat(int index) { float a = MappedByteFileBuffer.nio_read_Float_file_channel(ch, index); return a; } final public IntBuffer putFloat(int index, float value) { MappedByteFileBuffer.nio_write_Float_file_channel(ch, index, value); return this; }; + final public DoubleBuffer asDoubleBuffer() { return new MappedDoubleFileBuffer(ch); } final public double getDouble() { double a = MappedByteFileBuffer.nio_read_Double_file_channel(ch, position()); position(position() + 4); return a; } final public IntBuffer putDouble(double value) { MappedByteFileBuffer.nio_write_Double_file_channel(ch, position(), value); position(position() + 4); return this; } final public double getDouble(int index) { double a = MappedByteFileBuffer.nio_read_Double_file_channel(ch, index); return a; } final public IntBuffer putDouble(int index, double value) { MappedByteFileBuffer.nio_write_Double_file_channel(ch, index, value); return this; }; +} diff --git a/gnu/java/nio/MappedLongFileBuffer.java b/gnu/java/nio/MappedLongFileBuffer.java new file mode 100644 index 000000000..1bddc209d --- /dev/null +++ b/gnu/java/nio/MappedLongFileBuffer.java @@ -0,0 +1,77 @@ +package gnu.java.nio; +import java.nio.*; +final public class MappedLongFileBuffer + extends LongBuffer +{ + public long address; + boolean ro; + boolean direct; + public FileChannelImpl ch; + public MappedLongFileBuffer(FileChannelImpl ch) + { + this.ch = ch; + address = ch.address; + } + public MappedLongFileBuffer(MappedLongFileBuffer b) + { + this.ro = b.ro; + this.ch = b.ch; + address = b.address; + } + public boolean isReadOnly() + { + return ro; + } +final public long get() + { + long a = MappedByteFileBuffer.nio_read_Long_file_channel(ch, position()); + position(position() + 8); + return a; + } +final public LongBuffer put(long b) + { + MappedByteFileBuffer.nio_write_Long_file_channel(ch, position(), b); + position(position() + 8); + return this; + } +final public long get(int index) + { + long a = MappedByteFileBuffer.nio_read_Long_file_channel(ch, index); + return a; + } +final public LongBuffer put(int index, long b) + { + MappedByteFileBuffer.nio_write_Long_file_channel(ch, index, b); + return this; + } +final public LongBuffer compact() + { + return this; + } +final public boolean isDirect() + { + return direct; + } +final public LongBuffer slice() + { + MappedLongFileBuffer A = new MappedLongFileBuffer(this); + return A; + } +public LongBuffer duplicate() + { + return new MappedLongFileBuffer(this); + } +public LongBuffer asReadOnlyBuffer() + { + MappedLongFileBuffer b = new MappedLongFileBuffer(this); + b.ro = true; + return b; + } + final public ByteBuffer asByteBuffer() { return new MappedByteFileBuffer(ch); } final public byte getByte() { byte a = MappedByteFileBuffer.nio_read_Byte_file_channel(ch, position()); position(position() + 8); return a; } final public LongBuffer putByte(byte value) { MappedByteFileBuffer.nio_write_Byte_file_channel(ch, position(), value); position(position() + 8); return this; } final public byte getByte(int index) { byte a = MappedByteFileBuffer.nio_read_Byte_file_channel(ch, index); return a; } final public LongBuffer putByte(int index, byte value) { MappedByteFileBuffer.nio_write_Byte_file_channel(ch, index, value); return this; }; + final public CharBuffer asCharBuffer() { return new MappedCharFileBuffer(ch); } final public char getChar() { char a = MappedByteFileBuffer.nio_read_Char_file_channel(ch, position()); position(position() + 8); return a; } final public LongBuffer putChar(char value) { MappedByteFileBuffer.nio_write_Char_file_channel(ch, position(), value); position(position() + 8); return this; } final public char getChar(int index) { char a = MappedByteFileBuffer.nio_read_Char_file_channel(ch, index); return a; } final public LongBuffer putChar(int index, char value) { MappedByteFileBuffer.nio_write_Char_file_channel(ch, index, value); return this; }; + final public ShortBuffer asShortBuffer() { return new MappedShortFileBuffer(ch); } final public short getShort() { short a = MappedByteFileBuffer.nio_read_Short_file_channel(ch, position()); position(position() + 8); return a; } final public LongBuffer putShort(short value) { MappedByteFileBuffer.nio_write_Short_file_channel(ch, position(), value); position(position() + 8); return this; } final public short getShort(int index) { short a = MappedByteFileBuffer.nio_read_Short_file_channel(ch, index); return a; } final public LongBuffer putShort(int index, short value) { MappedByteFileBuffer.nio_write_Short_file_channel(ch, index, value); return this; }; + final public IntBuffer asIntBuffer() { return new MappedIntFileBuffer(ch); } final public int getInt() { int a = MappedByteFileBuffer.nio_read_Int_file_channel(ch, position()); position(position() + 8); return a; } final public LongBuffer putInt(int value) { MappedByteFileBuffer.nio_write_Int_file_channel(ch, position(), value); position(position() + 8); return this; } final public int getInt(int index) { int a = MappedByteFileBuffer.nio_read_Int_file_channel(ch, index); return a; } final public LongBuffer putInt(int index, int value) { MappedByteFileBuffer.nio_write_Int_file_channel(ch, index, value); return this; }; + final public LongBuffer asLongBuffer() { return new MappedLongFileBuffer(ch); } final public long getLong() { long a = MappedByteFileBuffer.nio_read_Long_file_channel(ch, position()); position(position() + 8); return a; } final public LongBuffer putLong(long value) { MappedByteFileBuffer.nio_write_Long_file_channel(ch, position(), value); position(position() + 8); return this; } final public long getLong(int index) { long a = MappedByteFileBuffer.nio_read_Long_file_channel(ch, index); return a; } final public LongBuffer putLong(int index, long value) { MappedByteFileBuffer.nio_write_Long_file_channel(ch, index, value); return this; }; + final public FloatBuffer asFloatBuffer() { return new MappedFloatFileBuffer(ch); } final public float getFloat() { float a = MappedByteFileBuffer.nio_read_Float_file_channel(ch, position()); position(position() + 8); return a; } final public LongBuffer putFloat(float value) { MappedByteFileBuffer.nio_write_Float_file_channel(ch, position(), value); position(position() + 8); return this; } final public float getFloat(int index) { float a = MappedByteFileBuffer.nio_read_Float_file_channel(ch, index); return a; } final public LongBuffer putFloat(int index, float value) { MappedByteFileBuffer.nio_write_Float_file_channel(ch, index, value); return this; }; + final public DoubleBuffer asDoubleBuffer() { return new MappedDoubleFileBuffer(ch); } final public double getDouble() { double a = MappedByteFileBuffer.nio_read_Double_file_channel(ch, position()); position(position() + 8); return a; } final public LongBuffer putDouble(double value) { MappedByteFileBuffer.nio_write_Double_file_channel(ch, position(), value); position(position() + 8); return this; } final public double getDouble(int index) { double a = MappedByteFileBuffer.nio_read_Double_file_channel(ch, index); return a; } final public LongBuffer putDouble(int index, double value) { MappedByteFileBuffer.nio_write_Double_file_channel(ch, index, value); return this; }; +} diff --git a/gnu/java/nio/MappedShortFileBuffer.java b/gnu/java/nio/MappedShortFileBuffer.java new file mode 100644 index 000000000..d1ad464d0 --- /dev/null +++ b/gnu/java/nio/MappedShortFileBuffer.java @@ -0,0 +1,77 @@ +package gnu.java.nio; +import java.nio.*; +final public class MappedShortFileBuffer + extends ShortBuffer +{ + public long address; + boolean ro; + boolean direct; + public FileChannelImpl ch; + public MappedShortFileBuffer(FileChannelImpl ch) + { + this.ch = ch; + address = ch.address; + } + public MappedShortFileBuffer(MappedShortFileBuffer b) + { + this.ro = b.ro; + this.ch = b.ch; + address = b.address; + } + public boolean isReadOnly() + { + return ro; + } +final public short get() + { + short a = MappedByteFileBuffer.nio_read_Short_file_channel(ch, position()); + position(position() + 2); + return a; + } +final public ShortBuffer put(short b) + { + MappedByteFileBuffer.nio_write_Short_file_channel(ch, position(), b); + position(position() + 2); + return this; + } +final public short get(int index) + { + short a = MappedByteFileBuffer.nio_read_Short_file_channel(ch, index); + return a; + } +final public ShortBuffer put(int index, short b) + { + MappedByteFileBuffer.nio_write_Short_file_channel(ch, index, b); + return this; + } +final public ShortBuffer compact() + { + return this; + } +final public boolean isDirect() + { + return direct; + } +final public ShortBuffer slice() + { + MappedShortFileBuffer A = new MappedShortFileBuffer(this); + return A; + } +public ShortBuffer duplicate() + { + return new MappedShortFileBuffer(this); + } +public ShortBuffer asReadOnlyBuffer() + { + MappedShortFileBuffer b = new MappedShortFileBuffer(this); + b.ro = true; + return b; + } + final public ByteBuffer asByteBuffer() { return new MappedByteFileBuffer(ch); } final public byte getByte() { byte a = MappedByteFileBuffer.nio_read_Byte_file_channel(ch, position()); position(position() + 2); return a; } final public ShortBuffer putByte(byte value) { MappedByteFileBuffer.nio_write_Byte_file_channel(ch, position(), value); position(position() + 2); return this; } final public byte getByte(int index) { byte a = MappedByteFileBuffer.nio_read_Byte_file_channel(ch, index); return a; } final public ShortBuffer putByte(int index, byte value) { MappedByteFileBuffer.nio_write_Byte_file_channel(ch, index, value); return this; }; + final public CharBuffer asCharBuffer() { return new MappedCharFileBuffer(ch); } final public char getChar() { char a = MappedByteFileBuffer.nio_read_Char_file_channel(ch, position()); position(position() + 2); return a; } final public ShortBuffer putChar(char value) { MappedByteFileBuffer.nio_write_Char_file_channel(ch, position(), value); position(position() + 2); return this; } final public char getChar(int index) { char a = MappedByteFileBuffer.nio_read_Char_file_channel(ch, index); return a; } final public ShortBuffer putChar(int index, char value) { MappedByteFileBuffer.nio_write_Char_file_channel(ch, index, value); return this; }; + final public ShortBuffer asShortBuffer() { return new MappedShortFileBuffer(ch); } final public short getShort() { short a = MappedByteFileBuffer.nio_read_Short_file_channel(ch, position()); position(position() + 2); return a; } final public ShortBuffer putShort(short value) { MappedByteFileBuffer.nio_write_Short_file_channel(ch, position(), value); position(position() + 2); return this; } final public short getShort(int index) { short a = MappedByteFileBuffer.nio_read_Short_file_channel(ch, index); return a; } final public ShortBuffer putShort(int index, short value) { MappedByteFileBuffer.nio_write_Short_file_channel(ch, index, value); return this; }; + final public IntBuffer asIntBuffer() { return new MappedIntFileBuffer(ch); } final public int getInt() { int a = MappedByteFileBuffer.nio_read_Int_file_channel(ch, position()); position(position() + 2); return a; } final public ShortBuffer putInt(int value) { MappedByteFileBuffer.nio_write_Int_file_channel(ch, position(), value); position(position() + 2); return this; } final public int getInt(int index) { int a = MappedByteFileBuffer.nio_read_Int_file_channel(ch, index); return a; } final public ShortBuffer putInt(int index, int value) { MappedByteFileBuffer.nio_write_Int_file_channel(ch, index, value); return this; }; + final public LongBuffer asLongBuffer() { return new MappedLongFileBuffer(ch); } final public long getLong() { long a = MappedByteFileBuffer.nio_read_Long_file_channel(ch, position()); position(position() + 2); return a; } final public ShortBuffer putLong(long value) { MappedByteFileBuffer.nio_write_Long_file_channel(ch, position(), value); position(position() + 2); return this; } final public long getLong(int index) { long a = MappedByteFileBuffer.nio_read_Long_file_channel(ch, index); return a; } final public ShortBuffer putLong(int index, long value) { MappedByteFileBuffer.nio_write_Long_file_channel(ch, index, value); return this; }; + final public FloatBuffer asFloatBuffer() { return new MappedFloatFileBuffer(ch); } final public float getFloat() { float a = MappedByteFileBuffer.nio_read_Float_file_channel(ch, position()); position(position() + 2); return a; } final public ShortBuffer putFloat(float value) { MappedByteFileBuffer.nio_write_Float_file_channel(ch, position(), value); position(position() + 2); return this; } final public float getFloat(int index) { float a = MappedByteFileBuffer.nio_read_Float_file_channel(ch, index); return a; } final public ShortBuffer putFloat(int index, float value) { MappedByteFileBuffer.nio_write_Float_file_channel(ch, index, value); return this; }; + final public DoubleBuffer asDoubleBuffer() { return new MappedDoubleFileBuffer(ch); } final public double getDouble() { double a = MappedByteFileBuffer.nio_read_Double_file_channel(ch, position()); position(position() + 2); return a; } final public ShortBuffer putDouble(double value) { MappedByteFileBuffer.nio_write_Double_file_channel(ch, position(), value); position(position() + 2); return this; } final public double getDouble(int index) { double a = MappedByteFileBuffer.nio_read_Double_file_channel(ch, index); return a; } final public ShortBuffer putDouble(int index, double value) { MappedByteFileBuffer.nio_write_Double_file_channel(ch, index, value); return this; }; +} diff --git a/gnu/java/nio/ShortBufferImpl.java b/gnu/java/nio/ShortBufferImpl.java new file mode 100644 index 000000000..1b15d4912 --- /dev/null +++ b/gnu/java/nio/ShortBufferImpl.java @@ -0,0 +1,102 @@ +package gnu.java.nio; +import java.nio.*; +public final class ShortBufferImpl extends java.nio. ShortBuffer +{ + private int array_offset; + short [] backing_buffer; + private boolean ro; + public ShortBufferImpl(int cap, int off, int lim) + { + this.backing_buffer = new short[cap]; + this.capacity(cap); + this.position(off); + this.limit(lim); + } + public ShortBufferImpl(short[] array, int off, int lim) + { + this.backing_buffer = array; + this.capacity(array.length); + this.position(off); + this.limit(lim); + } + public ShortBufferImpl(ShortBufferImpl copy) + { + backing_buffer = copy.backing_buffer; + ro = copy.ro; + position(copy.position()); + limit(copy.limit()); + } + void inc_pos(int a) + { + position(position() + a); + } + private static native short[] nio_cast(byte[]copy); + private static native short[] nio_cast(char[]copy); + private static native short[] nio_cast(short[]copy); + private static native short[] nio_cast(long[]copy); + private static native short[] nio_cast(int[]copy); + private static native short[] nio_cast(float[]copy); + private static native short[] nio_cast(double[]copy); + ShortBufferImpl(byte[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native byte nio_get_Byte(ShortBufferImpl b, int index); private static native void nio_put_Byte(ShortBufferImpl b, int index, byte value); public java.nio. ByteBuffer asByteBuffer() { return new gnu.java.nio. ByteBufferImpl(backing_buffer); } + ShortBufferImpl(char[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native char nio_get_Char(ShortBufferImpl b, int index); private static native void nio_put_Char(ShortBufferImpl b, int index, char value); public java.nio. CharBuffer asCharBuffer() { return new gnu.java.nio. CharBufferImpl(backing_buffer); } + ShortBufferImpl(short[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native short nio_get_Short(ShortBufferImpl b, int index); private static native void nio_put_Short(ShortBufferImpl b, int index, short value); public java.nio. ShortBuffer asShortBuffer() { return new gnu.java.nio. ShortBufferImpl(backing_buffer); } + ShortBufferImpl(int[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native int nio_get_Int(ShortBufferImpl b, int index); private static native void nio_put_Int(ShortBufferImpl b, int index, int value); public java.nio. IntBuffer asIntBuffer() { return new gnu.java.nio. IntBufferImpl(backing_buffer); } + ShortBufferImpl(long[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native long nio_get_Long(ShortBufferImpl b, int index); private static native void nio_put_Long(ShortBufferImpl b, int index, long value); public java.nio. LongBuffer asLongBuffer() { return new gnu.java.nio. LongBufferImpl(backing_buffer); } + ShortBufferImpl(float[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native float nio_get_Float(ShortBufferImpl b, int index); private static native void nio_put_Float(ShortBufferImpl b, int index, float value); public java.nio. FloatBuffer asFloatBuffer() { return new gnu.java.nio. FloatBufferImpl(backing_buffer); } + ShortBufferImpl(double[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native double nio_get_Double(ShortBufferImpl b, int index); private static native void nio_put_Double(ShortBufferImpl b, int index, double value); public java.nio. DoubleBuffer asDoubleBuffer() { return new gnu.java.nio. DoubleBufferImpl(backing_buffer); } + public boolean isReadOnly() + { + return ro; + } + public java.nio. ShortBuffer slice() + { + ShortBufferImpl A = new ShortBufferImpl(this); + A.array_offset = position(); + return A; + } + public java.nio. ShortBuffer duplicate() + { + return new ShortBufferImpl(this); + } + public java.nio. ShortBuffer asReadOnlyBuffer() + { + ShortBufferImpl a = new ShortBufferImpl(this); + a.ro = true; + return a; + } + public java.nio. ShortBuffer compact() + { + return this; + } + public boolean isDirect() + { + return backing_buffer != null; + } + final public short get() + { + short e = backing_buffer[position()]; + position(position()+1); + return e; + } + final public java.nio. ShortBuffer put(short b) + { + backing_buffer[position()] = b; + position(position()+1); + return this; + } + final public short get(int index) + { + return backing_buffer[index]; + } + final public java.nio. ShortBuffer put(int index, short b) + { + backing_buffer[index] = b; + return this; + } + final public char getChar() { char a = nio_get_Char(this, position()); inc_pos(2); return a; } final public java.nio. ShortBuffer putChar(char value) { nio_put_Char(this, position(), value); inc_pos(2); return this; } final public char getChar(int index) { char a = nio_get_Char(this, index); return a; } final public java.nio. ShortBuffer putChar(int index, char value) { nio_put_Char(this, index, value); return this; }; + final public short getShort() { return get(); } final public java.nio. ShortBuffer putShort(short value) { return put(value); } final public short getShort(int index) { return get(index); } final public java.nio. ShortBuffer putShort(int index, short value) { return put(index, value); }; + final public int getInt() { int a = nio_get_Int(this, position()); inc_pos(4); return a; } final public java.nio. ShortBuffer putInt(int value) { nio_put_Int(this, position(), value); inc_pos(4); return this; } final public int getInt(int index) { int a = nio_get_Int(this, index); return a; } final public java.nio. ShortBuffer putInt(int index, int value) { nio_put_Int(this, index, value); return this; }; + final public long getLong() { long a = nio_get_Long(this, position()); inc_pos(8); return a; } final public java.nio. ShortBuffer putLong(long value) { nio_put_Long(this, position(), value); inc_pos(8); return this; } final public long getLong(int index) { long a = nio_get_Long(this, index); return a; } final public java.nio. ShortBuffer putLong(int index, long value) { nio_put_Long(this, index, value); return this; }; + final public float getFloat() { float a = nio_get_Float(this, position()); inc_pos(4); return a; } final public java.nio. ShortBuffer putFloat(float value) { nio_put_Float(this, position(), value); inc_pos(4); return this; } final public float getFloat(int index) { float a = nio_get_Float(this, index); return a; } final public java.nio. ShortBuffer putFloat(int index, float value) { nio_put_Float(this, index, value); return this; }; + final public double getDouble() { double a = nio_get_Double(this, position()); inc_pos(8); return a; } final public java.nio. ShortBuffer putDouble(double value) { nio_put_Double(this, position(), value); inc_pos(8); return this; } final public double getDouble(int index) { double a = nio_get_Double(this, index); return a; } final public java.nio. ShortBuffer putDouble(int index, double value) { nio_put_Double(this, index, value); return this; }; +} diff --git a/java/Makefile.am b/java/Makefile.am index 45be4929e..23b801e29 100644 --- a/java/Makefile.am +++ b/java/Makefile.am @@ -1,3 +1,3 @@ ## Input file for automake to generate the Makefile.in used by configure -SUBDIRS = applet awt beans io lang math net rmi security sql text util +SUBDIRS = applet awt beans io lang math net nio rmi security sql text util diff --git a/java/nio/ByteBuffer.java b/java/nio/ByteBuffer.java new file mode 100644 index 000000000..7590b6f3c --- /dev/null +++ b/java/nio/ByteBuffer.java @@ -0,0 +1,157 @@ +package java.nio; +public abstract class ByteBuffer extends Buffer +{ + private ByteOrder endian = ByteOrder.BIG_ENDIAN; + public static ByteBuffer allocateDirect(int capacity) + { + ByteBuffer b = new gnu.java.nio. ByteBufferImpl(capacity, 0, capacity); + return b; + } + public static ByteBuffer allocate(int capacity) + { + ByteBuffer b = new gnu.java.nio. ByteBufferImpl(capacity, 0, capacity); + return b; + } + final public static ByteBuffer wrap(byte[] array, + int offset, + int length) + { + gnu.java.nio.ByteBufferImpl b = new gnu.java.nio. ByteBufferImpl(array, offset, length); + return b; + } + final public static ByteBuffer wrap(String a) + { + return wrap(a.getBytes(), 0, a.length()); + } + final public static ByteBuffer wrap(byte[] array) + { + return wrap(array, 0, array.length); + } + final public ByteBuffer get(byte[] dst, + int offset, + int length) + { + for (int i = offset; i < offset + length; i++) + { + dst[i] = get(); + } + return this; + } + final public ByteBuffer get(byte[] dst) + { + return get(dst, 0, dst.length); + } + final public ByteBuffer put(ByteBuffer src) + { + while (src.hasRemaining()) + put(src.get()); + return this; + } + final public ByteBuffer put(byte[] src, + int offset, + int length) + { + for (int i = offset; i < offset + length; i++) + put(src[i]); + return this; + } +public final ByteBuffer put(byte[] src) + { + return put(src, 0, src.length); + } +public final boolean hasArray() + { + return false; + } + public final byte[] array() + { + return null; + } + public final int arrayOffset() + { + return 0; + } + public int hashCode() + { + return super.hashCode(); + } + public boolean equals(Object obj) + { + if (obj instanceof ByteBuffer) + { + return compareTo(obj) == 0; + } + return false; + } + public int compareTo(Object ob) + { + ByteBuffer a = (ByteBuffer) ob; + if (a.remaining() != remaining()) + return 1; + if (! hasArray() || + ! a.hasArray()) + { + return 1; + } + int r = remaining(); + int i1 = pos; + int i2 = a.pos; + for (int i=0;i<r;i++) + { + int t = (int) (get(i1)- a.get(i2)); + if (t != 0) + { + return (int) t; + } + } + return 0; + } + public final ByteOrder order() + { + return endian; + } + public final ByteBuffer order(ByteOrder bo) + { + endian = bo; + return this; + } + public abstract byte get(); + public abstract java.nio. ByteBuffer put(byte b); + public abstract byte get(int index); + public abstract java.nio. ByteBuffer put(int index, byte b); + public abstract ByteBuffer compact(); + public abstract boolean isDirect(); + public abstract ByteBuffer slice(); + public abstract ByteBuffer duplicate(); + public abstract ByteBuffer asReadOnlyBuffer(); + public abstract ShortBuffer asShortBuffer(); + public abstract CharBuffer asCharBuffer(); + public abstract IntBuffer asIntBuffer(); + public abstract LongBuffer asLongBuffer(); + public abstract FloatBuffer asFloatBuffer(); + public abstract DoubleBuffer asDoubleBuffer(); + public abstract char getChar(); + public abstract ByteBuffer putChar(char value); + public abstract char getChar(int index); + public abstract ByteBuffer putChar(int index, char value); + public abstract short getShort(); + public abstract ByteBuffer putShort(short value); + public abstract short getShort(int index); + public abstract ByteBuffer putShort(int index, short value); + public abstract int getInt(); + public abstract ByteBuffer putInt(int value); + public abstract int getInt(int index); + public abstract ByteBuffer putInt(int index, int value); + public abstract long getLong(); + public abstract ByteBuffer putLong(long value); + public abstract long getLong(int index); + public abstract ByteBuffer putLong(int index, long value); + public abstract float getFloat(); + public abstract ByteBuffer putFloat(float value); + public abstract float getFloat(int index); + public abstract ByteBuffer putFloat(int index, float value); + public abstract double getDouble(); + public abstract ByteBuffer putDouble(double value); + public abstract double getDouble(int index); + public abstract ByteBuffer putDouble(int index, double value); +} diff --git a/java/nio/CharBuffer.java b/java/nio/CharBuffer.java new file mode 100644 index 000000000..e175ac800 --- /dev/null +++ b/java/nio/CharBuffer.java @@ -0,0 +1,163 @@ +package java.nio; +public abstract class CharBuffer extends Buffer +{ + private ByteOrder endian = ByteOrder.BIG_ENDIAN; + public static CharBuffer allocateDirect(int capacity) + { + CharBuffer b = new gnu.java.nio. CharBufferImpl(capacity, 0, capacity); + return b; + } + public static CharBuffer allocate(int capacity) + { + CharBuffer b = new gnu.java.nio. CharBufferImpl(capacity, 0, capacity); + return b; + } + final public static CharBuffer wrap(char[] array, + int offset, + int length) + { + gnu.java.nio.CharBufferImpl b = new gnu.java.nio. CharBufferImpl(array, offset, length); + return b; + } + final public static CharBuffer wrap(String a) + { + int len = a.length(); + char[] buffer = new char[len]; + for (int i=0;i<len;i++) + { + buffer[i] = (char) a.charAt(i); + } + return wrap(buffer, 0, len); + } + final public static CharBuffer wrap(char[] array) + { + return wrap(array, 0, array.length); + } + final public CharBuffer get(char[] dst, + int offset, + int length) + { + for (int i = offset; i < offset + length; i++) + { + dst[i] = get(); + } + return this; + } + final public CharBuffer get(char[] dst) + { + return get(dst, 0, dst.length); + } + final public CharBuffer put(CharBuffer src) + { + while (src.hasRemaining()) + put(src.get()); + return this; + } + final public CharBuffer put(char[] src, + int offset, + int length) + { + for (int i = offset; i < offset + length; i++) + put(src[i]); + return this; + } +public final CharBuffer put(char[] src) + { + return put(src, 0, src.length); + } +public final boolean hasArray() + { + return false; + } + public final char[] array() + { + return null; + } + public final int arrayOffset() + { + return 0; + } + public int hashCode() + { + return super.hashCode(); + } + public boolean equals(Object obj) + { + if (obj instanceof CharBuffer) + { + return compareTo(obj) == 0; + } + return false; + } + public int compareTo(Object ob) + { + CharBuffer a = (CharBuffer) ob; + if (a.remaining() != remaining()) + return 1; + if (! hasArray() || + ! a.hasArray()) + { + return 1; + } + int r = remaining(); + int i1 = pos; + int i2 = a.pos; + for (int i=0;i<r;i++) + { + int t = (int) (get(i1)- a.get(i2)); + if (t != 0) + { + return (int) t; + } + } + return 0; + } + public final ByteOrder order() + { + return endian; + } + public final CharBuffer order(ByteOrder bo) + { + endian = bo; + return this; + } + public abstract char get(); + public abstract java.nio. CharBuffer put(char b); + public abstract char get(int index); + public abstract java.nio. CharBuffer put(int index, char b); + public abstract CharBuffer compact(); + public abstract boolean isDirect(); + public abstract CharBuffer slice(); + public abstract CharBuffer duplicate(); + public abstract CharBuffer asReadOnlyBuffer(); + public abstract ShortBuffer asShortBuffer(); + public abstract CharBuffer asCharBuffer(); + public abstract IntBuffer asIntBuffer(); + public abstract LongBuffer asLongBuffer(); + public abstract FloatBuffer asFloatBuffer(); + public abstract DoubleBuffer asDoubleBuffer(); + public abstract char getChar(); + public abstract CharBuffer putChar(char value); + public abstract char getChar(int index); + public abstract CharBuffer putChar(int index, char value); + public abstract short getShort(); + public abstract CharBuffer putShort(short value); + public abstract short getShort(int index); + public abstract CharBuffer putShort(int index, short value); + public abstract int getInt(); + public abstract CharBuffer putInt(int value); + public abstract int getInt(int index); + public abstract CharBuffer putInt(int index, int value); + public abstract long getLong(); + public abstract CharBuffer putLong(long value); + public abstract long getLong(int index); + public abstract CharBuffer putLong(int index, long value); + public abstract float getFloat(); + public abstract CharBuffer putFloat(float value); + public abstract float getFloat(int index); + public abstract CharBuffer putFloat(int index, float value); + public abstract double getDouble(); + public abstract CharBuffer putDouble(double value); + public abstract double getDouble(int index); + public abstract CharBuffer putDouble(int index, double value); +} diff --git a/java/nio/DoubleBuffer.java b/java/nio/DoubleBuffer.java new file mode 100644 index 000000000..027320922 --- /dev/null +++ b/java/nio/DoubleBuffer.java @@ -0,0 +1,163 @@ +package java.nio; +public abstract class DoubleBuffer extends Buffer +{ + private ByteOrder endian = ByteOrder.BIG_ENDIAN; + public static DoubleBuffer allocateDirect(int capacity) + { + DoubleBuffer b = new gnu.java.nio. DoubleBufferImpl(capacity, 0, capacity); + return b; + } + public static DoubleBuffer allocate(int capacity) + { + DoubleBuffer b = new gnu.java.nio. DoubleBufferImpl(capacity, 0, capacity); + return b; + } + final public static DoubleBuffer wrap(double[] array, + int offset, + int length) + { + gnu.java.nio.DoubleBufferImpl b = new gnu.java.nio. DoubleBufferImpl(array, offset, length); + return b; + } + final public static DoubleBuffer wrap(String a) + { + int len = a.length(); + double[] buffer = new double[len]; + for (int i=0;i<len;i++) + { + buffer[i] = (double) a.charAt(i); + } + return wrap(buffer, 0, len); + } + final public static DoubleBuffer wrap(double[] array) + { + return wrap(array, 0, array.length); + } + final public DoubleBuffer get(double[] dst, + int offset, + int length) + { + for (int i = offset; i < offset + length; i++) + { + dst[i] = get(); + } + return this; + } + final public DoubleBuffer get(double[] dst) + { + return get(dst, 0, dst.length); + } + final public DoubleBuffer put(DoubleBuffer src) + { + while (src.hasRemaining()) + put(src.get()); + return this; + } + final public DoubleBuffer put(double[] src, + int offset, + int length) + { + for (int i = offset; i < offset + length; i++) + put(src[i]); + return this; + } +public final DoubleBuffer put(double[] src) + { + return put(src, 0, src.length); + } +public final boolean hasArray() + { + return false; + } + public final double[] array() + { + return null; + } + public final int arrayOffset() + { + return 0; + } + public int hashCode() + { + return super.hashCode(); + } + public boolean equals(Object obj) + { + if (obj instanceof DoubleBuffer) + { + return compareTo(obj) == 0; + } + return false; + } + public int compareTo(Object ob) + { + DoubleBuffer a = (DoubleBuffer) ob; + if (a.remaining() != remaining()) + return 1; + if (! hasArray() || + ! a.hasArray()) + { + return 1; + } + int r = remaining(); + int i1 = pos; + int i2 = a.pos; + for (int i=0;i<r;i++) + { + int t = (int) (get(i1)- a.get(i2)); + if (t != 0) + { + return (int) t; + } + } + return 0; + } + public final ByteOrder order() + { + return endian; + } + public final DoubleBuffer order(ByteOrder bo) + { + endian = bo; + return this; + } + public abstract double get(); + public abstract java.nio. DoubleBuffer put(double b); + public abstract double get(int index); + public abstract java.nio. DoubleBuffer put(int index, double b); + public abstract DoubleBuffer compact(); + public abstract boolean isDirect(); + public abstract DoubleBuffer slice(); + public abstract DoubleBuffer duplicate(); + public abstract DoubleBuffer asReadOnlyBuffer(); + public abstract ShortBuffer asShortBuffer(); + public abstract CharBuffer asCharBuffer(); + public abstract IntBuffer asIntBuffer(); + public abstract LongBuffer asLongBuffer(); + public abstract FloatBuffer asFloatBuffer(); + public abstract DoubleBuffer asDoubleBuffer(); + public abstract char getChar(); + public abstract DoubleBuffer putChar(char value); + public abstract char getChar(int index); + public abstract DoubleBuffer putChar(int index, char value); + public abstract short getShort(); + public abstract DoubleBuffer putShort(short value); + public abstract short getShort(int index); + public abstract DoubleBuffer putShort(int index, short value); + public abstract int getInt(); + public abstract DoubleBuffer putInt(int value); + public abstract int getInt(int index); + public abstract DoubleBuffer putInt(int index, int value); + public abstract long getLong(); + public abstract DoubleBuffer putLong(long value); + public abstract long getLong(int index); + public abstract DoubleBuffer putLong(int index, long value); + public abstract float getFloat(); + public abstract DoubleBuffer putFloat(float value); + public abstract float getFloat(int index); + public abstract DoubleBuffer putFloat(int index, float value); + public abstract double getDouble(); + public abstract DoubleBuffer putDouble(double value); + public abstract double getDouble(int index); + public abstract DoubleBuffer putDouble(int index, double value); +} diff --git a/java/nio/FloatBuffer.java b/java/nio/FloatBuffer.java new file mode 100644 index 000000000..7f1ba3c7e --- /dev/null +++ b/java/nio/FloatBuffer.java @@ -0,0 +1,163 @@ +package java.nio; +public abstract class FloatBuffer extends Buffer +{ + private ByteOrder endian = ByteOrder.BIG_ENDIAN; + public static FloatBuffer allocateDirect(int capacity) + { + FloatBuffer b = new gnu.java.nio. FloatBufferImpl(capacity, 0, capacity); + return b; + } + public static FloatBuffer allocate(int capacity) + { + FloatBuffer b = new gnu.java.nio. FloatBufferImpl(capacity, 0, capacity); + return b; + } + final public static FloatBuffer wrap(float[] array, + int offset, + int length) + { + gnu.java.nio.FloatBufferImpl b = new gnu.java.nio. FloatBufferImpl(array, offset, length); + return b; + } + final public static FloatBuffer wrap(String a) + { + int len = a.length(); + float[] buffer = new float[len]; + for (int i=0;i<len;i++) + { + buffer[i] = (float) a.charAt(i); + } + return wrap(buffer, 0, len); + } + final public static FloatBuffer wrap(float[] array) + { + return wrap(array, 0, array.length); + } + final public FloatBuffer get(float[] dst, + int offset, + int length) + { + for (int i = offset; i < offset + length; i++) + { + dst[i] = get(); + } + return this; + } + final public FloatBuffer get(float[] dst) + { + return get(dst, 0, dst.length); + } + final public FloatBuffer put(FloatBuffer src) + { + while (src.hasRemaining()) + put(src.get()); + return this; + } + final public FloatBuffer put(float[] src, + int offset, + int length) + { + for (int i = offset; i < offset + length; i++) + put(src[i]); + return this; + } +public final FloatBuffer put(float[] src) + { + return put(src, 0, src.length); + } +public final boolean hasArray() + { + return false; + } + public final float[] array() + { + return null; + } + public final int arrayOffset() + { + return 0; + } + public int hashCode() + { + return super.hashCode(); + } + public boolean equals(Object obj) + { + if (obj instanceof FloatBuffer) + { + return compareTo(obj) == 0; + } + return false; + } + public int compareTo(Object ob) + { + FloatBuffer a = (FloatBuffer) ob; + if (a.remaining() != remaining()) + return 1; + if (! hasArray() || + ! a.hasArray()) + { + return 1; + } + int r = remaining(); + int i1 = pos; + int i2 = a.pos; + for (int i=0;i<r;i++) + { + int t = (int) (get(i1)- a.get(i2)); + if (t != 0) + { + return (int) t; + } + } + return 0; + } + public final ByteOrder order() + { + return endian; + } + public final FloatBuffer order(ByteOrder bo) + { + endian = bo; + return this; + } + public abstract float get(); + public abstract java.nio. FloatBuffer put(float b); + public abstract float get(int index); + public abstract java.nio. FloatBuffer put(int index, float b); + public abstract FloatBuffer compact(); + public abstract boolean isDirect(); + public abstract FloatBuffer slice(); + public abstract FloatBuffer duplicate(); + public abstract FloatBuffer asReadOnlyBuffer(); + public abstract ShortBuffer asShortBuffer(); + public abstract CharBuffer asCharBuffer(); + public abstract IntBuffer asIntBuffer(); + public abstract LongBuffer asLongBuffer(); + public abstract FloatBuffer asFloatBuffer(); + public abstract DoubleBuffer asDoubleBuffer(); + public abstract char getChar(); + public abstract FloatBuffer putChar(char value); + public abstract char getChar(int index); + public abstract FloatBuffer putChar(int index, char value); + public abstract short getShort(); + public abstract FloatBuffer putShort(short value); + public abstract short getShort(int index); + public abstract FloatBuffer putShort(int index, short value); + public abstract int getInt(); + public abstract FloatBuffer putInt(int value); + public abstract int getInt(int index); + public abstract FloatBuffer putInt(int index, int value); + public abstract long getLong(); + public abstract FloatBuffer putLong(long value); + public abstract long getLong(int index); + public abstract FloatBuffer putLong(int index, long value); + public abstract float getFloat(); + public abstract FloatBuffer putFloat(float value); + public abstract float getFloat(int index); + public abstract FloatBuffer putFloat(int index, float value); + public abstract double getDouble(); + public abstract FloatBuffer putDouble(double value); + public abstract double getDouble(int index); + public abstract FloatBuffer putDouble(int index, double value); +} diff --git a/java/nio/IntBuffer.java b/java/nio/IntBuffer.java new file mode 100644 index 000000000..5d715447f --- /dev/null +++ b/java/nio/IntBuffer.java @@ -0,0 +1,163 @@ +package java.nio; +public abstract class IntBuffer extends Buffer +{ + private ByteOrder endian = ByteOrder.BIG_ENDIAN; + public static IntBuffer allocateDirect(int capacity) + { + IntBuffer b = new gnu.java.nio. IntBufferImpl(capacity, 0, capacity); + return b; + } + public static IntBuffer allocate(int capacity) + { + IntBuffer b = new gnu.java.nio. IntBufferImpl(capacity, 0, capacity); + return b; + } + final public static IntBuffer wrap(int[] array, + int offset, + int length) + { + gnu.java.nio.IntBufferImpl b = new gnu.java.nio. IntBufferImpl(array, offset, length); + return b; + } + final public static IntBuffer wrap(String a) + { + int len = a.length(); + int[] buffer = new int[len]; + for (int i=0;i<len;i++) + { + buffer[i] = (int) a.charAt(i); + } + return wrap(buffer, 0, len); + } + final public static IntBuffer wrap(int[] array) + { + return wrap(array, 0, array.length); + } + final public IntBuffer get(int[] dst, + int offset, + int length) + { + for (int i = offset; i < offset + length; i++) + { + dst[i] = get(); + } + return this; + } + final public IntBuffer get(int[] dst) + { + return get(dst, 0, dst.length); + } + final public IntBuffer put(IntBuffer src) + { + while (src.hasRemaining()) + put(src.get()); + return this; + } + final public IntBuffer put(int[] src, + int offset, + int length) + { + for (int i = offset; i < offset + length; i++) + put(src[i]); + return this; + } +public final IntBuffer put(int[] src) + { + return put(src, 0, src.length); + } +public final boolean hasArray() + { + return false; + } + public final int[] array() + { + return null; + } + public final int arrayOffset() + { + return 0; + } + public int hashCode() + { + return super.hashCode(); + } + public boolean equals(Object obj) + { + if (obj instanceof IntBuffer) + { + return compareTo(obj) == 0; + } + return false; + } + public int compareTo(Object ob) + { + IntBuffer a = (IntBuffer) ob; + if (a.remaining() != remaining()) + return 1; + if (! hasArray() || + ! a.hasArray()) + { + return 1; + } + int r = remaining(); + int i1 = pos; + int i2 = a.pos; + for (int i=0;i<r;i++) + { + int t = (int) (get(i1)- a.get(i2)); + if (t != 0) + { + return (int) t; + } + } + return 0; + } + public final ByteOrder order() + { + return endian; + } + public final IntBuffer order(ByteOrder bo) + { + endian = bo; + return this; + } + public abstract int get(); + public abstract java.nio. IntBuffer put(int b); + public abstract int get(int index); + public abstract java.nio. IntBuffer put(int index, int b); + public abstract IntBuffer compact(); + public abstract boolean isDirect(); + public abstract IntBuffer slice(); + public abstract IntBuffer duplicate(); + public abstract IntBuffer asReadOnlyBuffer(); + public abstract ShortBuffer asShortBuffer(); + public abstract CharBuffer asCharBuffer(); + public abstract IntBuffer asIntBuffer(); + public abstract LongBuffer asLongBuffer(); + public abstract FloatBuffer asFloatBuffer(); + public abstract DoubleBuffer asDoubleBuffer(); + public abstract char getChar(); + public abstract IntBuffer putChar(char value); + public abstract char getChar(int index); + public abstract IntBuffer putChar(int index, char value); + public abstract short getShort(); + public abstract IntBuffer putShort(short value); + public abstract short getShort(int index); + public abstract IntBuffer putShort(int index, short value); + public abstract int getInt(); + public abstract IntBuffer putInt(int value); + public abstract int getInt(int index); + public abstract IntBuffer putInt(int index, int value); + public abstract long getLong(); + public abstract IntBuffer putLong(long value); + public abstract long getLong(int index); + public abstract IntBuffer putLong(int index, long value); + public abstract float getFloat(); + public abstract IntBuffer putFloat(float value); + public abstract float getFloat(int index); + public abstract IntBuffer putFloat(int index, float value); + public abstract double getDouble(); + public abstract IntBuffer putDouble(double value); + public abstract double getDouble(int index); + public abstract IntBuffer putDouble(int index, double value); +} diff --git a/java/nio/LongBuffer.java b/java/nio/LongBuffer.java new file mode 100644 index 000000000..f22c49a6e --- /dev/null +++ b/java/nio/LongBuffer.java @@ -0,0 +1,163 @@ +package java.nio; +public abstract class LongBuffer extends Buffer +{ + private ByteOrder endian = ByteOrder.BIG_ENDIAN; + public static LongBuffer allocateDirect(int capacity) + { + LongBuffer b = new gnu.java.nio. LongBufferImpl(capacity, 0, capacity); + return b; + } + public static LongBuffer allocate(int capacity) + { + LongBuffer b = new gnu.java.nio. LongBufferImpl(capacity, 0, capacity); + return b; + } + final public static LongBuffer wrap(long[] array, + int offset, + int length) + { + gnu.java.nio.LongBufferImpl b = new gnu.java.nio. LongBufferImpl(array, offset, length); + return b; + } + final public static LongBuffer wrap(String a) + { + int len = a.length(); + long[] buffer = new long[len]; + for (int i=0;i<len;i++) + { + buffer[i] = (long) a.charAt(i); + } + return wrap(buffer, 0, len); + } + final public static LongBuffer wrap(long[] array) + { + return wrap(array, 0, array.length); + } + final public LongBuffer get(long[] dst, + int offset, + int length) + { + for (int i = offset; i < offset + length; i++) + { + dst[i] = get(); + } + return this; + } + final public LongBuffer get(long[] dst) + { + return get(dst, 0, dst.length); + } + final public LongBuffer put(LongBuffer src) + { + while (src.hasRemaining()) + put(src.get()); + return this; + } + final public LongBuffer put(long[] src, + int offset, + int length) + { + for (int i = offset; i < offset + length; i++) + put(src[i]); + return this; + } +public final LongBuffer put(long[] src) + { + return put(src, 0, src.length); + } +public final boolean hasArray() + { + return false; + } + public final long[] array() + { + return null; + } + public final int arrayOffset() + { + return 0; + } + public int hashCode() + { + return super.hashCode(); + } + public boolean equals(Object obj) + { + if (obj instanceof LongBuffer) + { + return compareTo(obj) == 0; + } + return false; + } + public int compareTo(Object ob) + { + LongBuffer a = (LongBuffer) ob; + if (a.remaining() != remaining()) + return 1; + if (! hasArray() || + ! a.hasArray()) + { + return 1; + } + int r = remaining(); + int i1 = pos; + int i2 = a.pos; + for (int i=0;i<r;i++) + { + int t = (int) (get(i1)- a.get(i2)); + if (t != 0) + { + return (int) t; + } + } + return 0; + } + public final ByteOrder order() + { + return endian; + } + public final LongBuffer order(ByteOrder bo) + { + endian = bo; + return this; + } + public abstract long get(); + public abstract java.nio. LongBuffer put(long b); + public abstract long get(int index); + public abstract java.nio. LongBuffer put(int index, long b); + public abstract LongBuffer compact(); + public abstract boolean isDirect(); + public abstract LongBuffer slice(); + public abstract LongBuffer duplicate(); + public abstract LongBuffer asReadOnlyBuffer(); + public abstract ShortBuffer asShortBuffer(); + public abstract CharBuffer asCharBuffer(); + public abstract IntBuffer asIntBuffer(); + public abstract LongBuffer asLongBuffer(); + public abstract FloatBuffer asFloatBuffer(); + public abstract DoubleBuffer asDoubleBuffer(); + public abstract char getChar(); + public abstract LongBuffer putChar(char value); + public abstract char getChar(int index); + public abstract LongBuffer putChar(int index, char value); + public abstract short getShort(); + public abstract LongBuffer putShort(short value); + public abstract short getShort(int index); + public abstract LongBuffer putShort(int index, short value); + public abstract int getInt(); + public abstract LongBuffer putInt(int value); + public abstract int getInt(int index); + public abstract LongBuffer putInt(int index, int value); + public abstract long getLong(); + public abstract LongBuffer putLong(long value); + public abstract long getLong(int index); + public abstract LongBuffer putLong(int index, long value); + public abstract float getFloat(); + public abstract LongBuffer putFloat(float value); + public abstract float getFloat(int index); + public abstract LongBuffer putFloat(int index, float value); + public abstract double getDouble(); + public abstract LongBuffer putDouble(double value); + public abstract double getDouble(int index); + public abstract LongBuffer putDouble(int index, double value); +} diff --git a/java/nio/ShortBuffer.java b/java/nio/ShortBuffer.java new file mode 100644 index 000000000..ef9e2efbe --- /dev/null +++ b/java/nio/ShortBuffer.java @@ -0,0 +1,163 @@ +package java.nio; +public abstract class ShortBuffer extends Buffer +{ + private ByteOrder endian = ByteOrder.BIG_ENDIAN; + public static ShortBuffer allocateDirect(int capacity) + { + ShortBuffer b = new gnu.java.nio. ShortBufferImpl(capacity, 0, capacity); + return b; + } + public static ShortBuffer allocate(int capacity) + { + ShortBuffer b = new gnu.java.nio. ShortBufferImpl(capacity, 0, capacity); + return b; + } + final public static ShortBuffer wrap(short[] array, + int offset, + int length) + { + gnu.java.nio.ShortBufferImpl b = new gnu.java.nio. ShortBufferImpl(array, offset, length); + return b; + } + final public static ShortBuffer wrap(String a) + { + int len = a.length(); + short[] buffer = new short[len]; + for (int i=0;i<len;i++) + { + buffer[i] = (short) a.charAt(i); + } + return wrap(buffer, 0, len); + } + final public static ShortBuffer wrap(short[] array) + { + return wrap(array, 0, array.length); + } + final public ShortBuffer get(short[] dst, + int offset, + int length) + { + for (int i = offset; i < offset + length; i++) + { + dst[i] = get(); + } + return this; + } + final public ShortBuffer get(short[] dst) + { + return get(dst, 0, dst.length); + } + final public ShortBuffer put(ShortBuffer src) + { + while (src.hasRemaining()) + put(src.get()); + return this; + } + final public ShortBuffer put(short[] src, + int offset, + int length) + { + for (int i = offset; i < offset + length; i++) + put(src[i]); + return this; + } +public final ShortBuffer put(short[] src) + { + return put(src, 0, src.length); + } +public final boolean hasArray() + { + return false; + } + public final short[] array() + { + return null; + } + public final int arrayOffset() + { + return 0; + } + public int hashCode() + { + return super.hashCode(); + } + public boolean equals(Object obj) + { + if (obj instanceof ShortBuffer) + { + return compareTo(obj) == 0; + } + return false; + } + public int compareTo(Object ob) + { + ShortBuffer a = (ShortBuffer) ob; + if (a.remaining() != remaining()) + return 1; + if (! hasArray() || + ! a.hasArray()) + { + return 1; + } + int r = remaining(); + int i1 = pos; + int i2 = a.pos; + for (int i=0;i<r;i++) + { + int t = (int) (get(i1)- a.get(i2)); + if (t != 0) + { + return (int) t; + } + } + return 0; + } + public final ByteOrder order() + { + return endian; + } + public final ShortBuffer order(ByteOrder bo) + { + endian = bo; + return this; + } + public abstract short get(); + public abstract java.nio. ShortBuffer put(short b); + public abstract short get(int index); + public abstract java.nio. ShortBuffer put(int index, short b); + public abstract ShortBuffer compact(); + public abstract boolean isDirect(); + public abstract ShortBuffer slice(); + public abstract ShortBuffer duplicate(); + public abstract ShortBuffer asReadOnlyBuffer(); + public abstract ShortBuffer asShortBuffer(); + public abstract CharBuffer asCharBuffer(); + public abstract IntBuffer asIntBuffer(); + public abstract LongBuffer asLongBuffer(); + public abstract FloatBuffer asFloatBuffer(); + public abstract DoubleBuffer asDoubleBuffer(); + public abstract char getChar(); + public abstract ShortBuffer putChar(char value); + public abstract char getChar(int index); + public abstract ShortBuffer putChar(int index, char value); + public abstract short getShort(); + public abstract ShortBuffer putShort(short value); + public abstract short getShort(int index); + public abstract ShortBuffer putShort(int index, short value); + public abstract int getInt(); + public abstract ShortBuffer putInt(int value); + public abstract int getInt(int index); + public abstract ShortBuffer putInt(int index, int value); + public abstract long getLong(); + public abstract ShortBuffer putLong(long value); + public abstract long getLong(int index); + public abstract ShortBuffer putLong(int index, long value); + public abstract float getFloat(); + public abstract ShortBuffer putFloat(float value); + public abstract float getFloat(int index); + public abstract ShortBuffer putFloat(int index, float value); + public abstract double getDouble(); + public abstract ShortBuffer putDouble(double value); + public abstract double getDouble(int index); + public abstract ShortBuffer putDouble(int index, double value); +} diff --git a/lib/.cvsignore b/lib/.cvsignore index b15069e63..52db38014 100644 --- a/lib/.cvsignore +++ b/lib/.cvsignore @@ -17,3 +17,4 @@ makefile.dep java.dep compile-classes mkcollections.pl +gen_nio.sh diff --git a/lib/Makefile.am b/lib/Makefile.am index f9cc90797..2fa2e170c 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -102,9 +102,10 @@ glibj.zip: classes compile-classes classes: gen-classlist.sh standard.omit top_builddir=$(top_builddir) $(SHELL) ./gen-classlist.sh standard +gennio: + top_builddir=$(top_builddir) $(SHELL) ./gen_nio.sh genclasses: gen-classlist.sh standard.omit - /bin/sh ./gen_nio.sh top_builddir=$(top_builddir) $(SHELL) ./gen-classlist.sh standard $(JAVA_DEPEND): genclasses diff --git a/lib/gen_nio.sh b/lib/gen_nio.sh deleted file mode 100755 index 613cfd9d2..000000000 --- a/lib/gen_nio.sh +++ /dev/null @@ -1,137 +0,0 @@ -#! /bin/sh - -export CLASSPATH_SRC=../ - -# generate java.nio.ByteBuffer etc - -echo "#define TYPE Byte" > $CLASSPATH_SRC/java/nio/temp.h -echo "#define ELT byte" >> $CLASSPATH_SRC/java/nio/temp.h -echo "#define SIZE 1" >> $CLASSPATH_SRC/java/nio/temp.h -gcc $CLASSPATH_SRC/java/nio/GenericBuffer.cpp -E -P > temp -cat temp | sed s/BUFFER/ByteBuffer/g > $CLASSPATH_SRC/java/nio/ByteBuffer.java - - -echo "#define TYPE Short" > $CLASSPATH_SRC/java/nio/temp.h -echo "#define ELT short" >> $CLASSPATH_SRC/java/nio/temp.h -echo "#define SIZE 2" >> $CLASSPATH_SRC/java/nio/temp.h -gcc $CLASSPATH_SRC/java/nio/GenericBuffer.cpp -E -P > temp -cat temp | sed s/BUFFER/ShortBuffer/g > $CLASSPATH_SRC/java/nio/ShortBuffer.java - - -echo "#define TYPE Char" > $CLASSPATH_SRC/java/nio/temp.h -echo "#define ELT char" >> $CLASSPATH_SRC/java/nio/temp.h -echo "#define SIZE 2" >> $CLASSPATH_SRC/java/nio/temp.h -gcc $CLASSPATH_SRC/java/nio/GenericBuffer.cpp -E -P > temp -cat temp | sed s/BUFFER/CharBuffer/g > $CLASSPATH_SRC/java/nio/CharBuffer.java - - -echo "#define TYPE Int" > $CLASSPATH_SRC/java/nio/temp.h -echo "#define ELT int" >> $CLASSPATH_SRC/java/nio/temp.h -echo "#define SIZE 4" >> $CLASSPATH_SRC/java/nio/temp.h -gcc $CLASSPATH_SRC/java/nio/GenericBuffer.cpp -E -P > temp -cat temp | sed s/BUFFER/IntBuffer/g > $CLASSPATH_SRC/java/nio/IntBuffer.java - - -echo "#define TYPE Long" > $CLASSPATH_SRC/java/nio/temp.h -echo "#define ELT long" >> $CLASSPATH_SRC/java/nio/temp.h -echo "#define SIZE 8" >> $CLASSPATH_SRC/java/nio/temp.h -gcc $CLASSPATH_SRC/java/nio/GenericBuffer.cpp -E -P > temp -cat temp | sed s/BUFFER/LongBuffer/g > $CLASSPATH_SRC/java/nio/LongBuffer.java - - -echo "#define TYPE Float" > $CLASSPATH_SRC/java/nio/temp.h -echo "#define ELT float" >> $CLASSPATH_SRC/java/nio/temp.h -echo "#define SIZE 4" >> $CLASSPATH_SRC/java/nio/temp.h -gcc $CLASSPATH_SRC/java/nio/GenericBuffer.cpp -E -P > temp -cat temp | sed s/BUFFER/FloatBuffer/g > $CLASSPATH_SRC/java/nio/FloatBuffer.java - - -echo "#define TYPE Double" > $CLASSPATH_SRC/java/nio/temp.h -echo "#define ELT double" >> $CLASSPATH_SRC/java/nio/temp.h -echo "#define SIZE 8" >> $CLASSPATH_SRC/java/nio/temp.h -gcc $CLASSPATH_SRC/java/nio/GenericBuffer.cpp -E -P > temp -cat temp | sed s/BUFFER/DoubleBuffer/g > $CLASSPATH_SRC/java/nio/DoubleBuffer.java - -#generate the implementation classes of the above: - -echo "#define TYPE Byte" > $CLASSPATH_SRC/gnu/java/nio/temp.h -echo "#define ELT byte" >> $CLASSPATH_SRC/gnu/java/nio/temp.h -echo "#define SIZE 1" >> $CLASSPATH_SRC/gnu/java/nio/temp.h -echo "#define BYTE 1" >> $CLASSPATH_SRC/gnu/java/nio/temp.h -gcc $CLASSPATH_SRC/gnu/java/nio/GenericBuffer.cpp -E -P > temp -cat temp | sed s/BUFFER/ByteBuffer/g > $CLASSPATH_SRC/gnu/java/nio/ByteBufferImpl.java - -gcc $CLASSPATH_SRC/gnu/java/nio/GenericMappedByteFileBuffer.cpp -E -P > temp -cat temp | sed s/TYPE/Byte/g > $CLASSPATH_SRC/gnu/java/nio/MappedByteFileBuffer.java - - -echo "#define TYPE Short" > $CLASSPATH_SRC/gnu/java/nio/temp.h -echo "#define ELT short" >> $CLASSPATH_SRC/gnu/java/nio/temp.h -echo "#define SIZE 2" >> $CLASSPATH_SRC/gnu/java/nio/temp.h -echo "#define SHORT 2" >> $CLASSPATH_SRC/gnu/java/nio/temp.h -gcc $CLASSPATH_SRC/gnu/java/nio/GenericBuffer.cpp -E -P > temp -cat temp | sed s/BUFFER/ShortBuffer/g > $CLASSPATH_SRC/gnu/java/nio/ShortBufferImpl.java - -gcc $CLASSPATH_SRC/gnu/java/nio/GenericMappedByteFileBuffer.cpp -E -P > temp -cat temp | sed s/TYPE/Short/g > $CLASSPATH_SRC/gnu/java/nio/MappedShortFileBuffer.java - - -echo "#define TYPE Char" > $CLASSPATH_SRC/gnu/java/nio/temp.h -echo "#define ELT char" >> $CLASSPATH_SRC/gnu/java/nio/temp.h -echo "#define SIZE 2" >> $CLASSPATH_SRC/gnu/java/nio/temp.h -echo "#define CHAR 2" >> $CLASSPATH_SRC/gnu/java/nio/temp.h -gcc $CLASSPATH_SRC/gnu/java/nio/GenericBuffer.cpp -E -P > temp -cat temp | sed s/BUFFER/CharBuffer/g > $CLASSPATH_SRC/gnu/java/nio/CharBufferImpl.java - -gcc $CLASSPATH_SRC/gnu/java/nio/GenericMappedByteFileBuffer.cpp -E -P > temp -cat temp | sed s/TYPE/Char/g > $CLASSPATH_SRC/gnu/java/nio/MappedCharFileBuffer.java - - - -echo "#define TYPE Int" > $CLASSPATH_SRC/gnu/java/nio/temp.h -echo "#define ELT int" >> $CLASSPATH_SRC/gnu/java/nio/temp.h -echo "#define SIZE 4" >> $CLASSPATH_SRC/gnu/java/nio/temp.h -echo "#define INT 2" >> $CLASSPATH_SRC/gnu/java/nio/temp.h -gcc $CLASSPATH_SRC/gnu/java/nio/GenericBuffer.cpp -E -P > temp -cat temp | sed s/BUFFER/IntBuffer/g > $CLASSPATH_SRC/gnu/java/nio/IntBufferImpl.java - -gcc $CLASSPATH_SRC/gnu/java/nio/GenericMappedByteFileBuffer.cpp -E -P > temp -cat temp | sed s/TYPE/Int/g > $CLASSPATH_SRC/gnu/java/nio/MappedIntFileBuffer.java - - - -echo "#define TYPE Long" > $CLASSPATH_SRC/gnu/java/nio/temp.h -echo "#define ELT long" >> $CLASSPATH_SRC/gnu/java/nio/temp.h -echo "#define SIZE 8" >> $CLASSPATH_SRC/gnu/java/nio/temp.h -echo "#define LONG" >> $CLASSPATH_SRC/gnu/java/nio/temp.h -gcc $CLASSPATH_SRC/gnu/java/nio/GenericBuffer.cpp -E -P > temp -cat temp | sed s/BUFFER/LongBuffer/g > $CLASSPATH_SRC/gnu/java/nio/LongBufferImpl.java - -gcc $CLASSPATH_SRC/gnu/java/nio/GenericMappedByteFileBuffer.cpp -E -P > temp -cat temp | sed s/TYPE/Long/g > $CLASSPATH_SRC/gnu/java/nio/MappedLongFileBuffer.java - - - - -echo "#define TYPE Float" > $CLASSPATH_SRC/gnu/java/nio/temp.h -echo "#define ELT float" >> $CLASSPATH_SRC/gnu/java/nio/temp.h -echo "#define SIZE 4" >> $CLASSPATH_SRC/gnu/java/nio/temp.h -echo "#define FLOAT" >> $CLASSPATH_SRC/gnu/java/nio/temp.h - -gcc $CLASSPATH_SRC/gnu/java/nio/GenericBuffer.cpp -E -P > temp -cat temp | sed s/BUFFER/FloatBuffer/g > $CLASSPATH_SRC/gnu/java/nio/FloatBufferImpl.java - -gcc $CLASSPATH_SRC/gnu/java/nio/GenericMappedByteFileBuffer.cpp -E -P > temp -cat temp | sed s/TYPE/Float/g > $CLASSPATH_SRC/gnu/java/nio/MappedFloatFileBuffer.java - - - -echo "#define TYPE Double" > $CLASSPATH_SRC/gnu/java/nio/temp.h -echo "#define ELT double" >> $CLASSPATH_SRC/gnu/java/nio/temp.h -echo "#define SIZE 8" >> $CLASSPATH_SRC/gnu/java/nio/temp.h -echo "#define DOUBLE 8" >> $CLASSPATH_SRC/gnu/java/nio/temp.h -gcc $CLASSPATH_SRC/gnu/java/nio/GenericBuffer.cpp -E -P > temp -cat temp | sed s/BUFFER/DoubleBuffer/g > $CLASSPATH_SRC/gnu/java/nio/DoubleBufferImpl.java - -gcc $CLASSPATH_SRC/gnu/java/nio/GenericMappedByteFileBuffer.cpp -E -P > temp -cat temp | sed s/TYPE/Double/g > $CLASSPATH_SRC/gnu/java/nio/MappedDoubleFileBuffer.java
\ No newline at end of file diff --git a/lib/gen_nio.sh.in b/lib/gen_nio.sh.in new file mode 100755 index 000000000..baf13bc3a --- /dev/null +++ b/lib/gen_nio.sh.in @@ -0,0 +1,137 @@ +#! /bin/sh + +export CLASSPATH_SRC=@top_srcdir@ + +# generate java.nio.ByteBuffer etc + +echo "#define TYPE Byte" > ${top_builddir}/include/temp.h +echo "#define ELT byte" >> ${top_builddir}/include/temp.h +echo "#define SIZE 1" >> ${top_builddir}/include/temp.h +gcc $CLASSPATH_SRC/java/nio/GenericBuffer.cpp -E -P -I${top_builddir}/include > temp +cat temp | sed s/BUFFER/ByteBuffer/g > $CLASSPATH_SRC/java/nio/ByteBuffer.java + + +echo "#define TYPE Short" > ${top_builddir}/include/temp.h +echo "#define ELT short" >> ${top_builddir}/include/temp.h +echo "#define SIZE 2" >> ${top_builddir}/include/temp.h +gcc $CLASSPATH_SRC/java/nio/GenericBuffer.cpp -E -P -I${top_builddir}/include > temp +cat temp | sed s/BUFFER/ShortBuffer/g > $CLASSPATH_SRC/java/nio/ShortBuffer.java + + +echo "#define TYPE Char" > ${top_builddir}/include/temp.h +echo "#define ELT char" >> ${top_builddir}/include/temp.h +echo "#define SIZE 2" >> ${top_builddir}/include/temp.h +gcc $CLASSPATH_SRC/java/nio/GenericBuffer.cpp -E -P -I${top_builddir}/include > temp +cat temp | sed s/BUFFER/CharBuffer/g > $CLASSPATH_SRC/java/nio/CharBuffer.java + + +echo "#define TYPE Int" > ${top_builddir}/include/temp.h +echo "#define ELT int" >> ${top_builddir}/include/temp.h +echo "#define SIZE 4" >> ${top_builddir}/include/temp.h +gcc $CLASSPATH_SRC/java/nio/GenericBuffer.cpp -E -P -I${top_builddir}/include > temp +cat temp | sed s/BUFFER/IntBuffer/g > $CLASSPATH_SRC/java/nio/IntBuffer.java + + +echo "#define TYPE Long" > ${top_builddir}/include/temp.h +echo "#define ELT long" >> ${top_builddir}/include/temp.h +echo "#define SIZE 8" >> ${top_builddir}/include/temp.h +gcc $CLASSPATH_SRC/java/nio/GenericBuffer.cpp -E -P -I${top_builddir}/include > temp +cat temp | sed s/BUFFER/LongBuffer/g > $CLASSPATH_SRC/java/nio/LongBuffer.java + + +echo "#define TYPE Float" > ${top_builddir}/include/temp.h +echo "#define ELT float" >> ${top_builddir}/include/temp.h +echo "#define SIZE 4" >> ${top_builddir}/include/temp.h +gcc $CLASSPATH_SRC/java/nio/GenericBuffer.cpp -E -P -I${top_builddir}/include > temp +cat temp | sed s/BUFFER/FloatBuffer/g > $CLASSPATH_SRC/java/nio/FloatBuffer.java + + +echo "#define TYPE Double" > ${top_builddir}/include/temp.h +echo "#define ELT double" >> ${top_builddir}/include/temp.h +echo "#define SIZE 8" >> ${top_builddir}/include/temp.h +gcc $CLASSPATH_SRC/java/nio/GenericBuffer.cpp -E -P -I${top_builddir}/include > temp +cat temp | sed s/BUFFER/DoubleBuffer/g > $CLASSPATH_SRC/java/nio/DoubleBuffer.java + +#generate the implementation classes of the above: + +echo "#define TYPE Byte" > ${top_builddir}/include/temp.h +echo "#define ELT byte" >> ${top_builddir}/include/temp.h +echo "#define SIZE 1" >> ${top_builddir}/include/temp.h +echo "#define BYTE 1" >> ${top_builddir}/include/temp.h +gcc $CLASSPATH_SRC/gnu/java/nio/GenericBuffer.cpp -E -P -I${top_builddir}/include > temp +cat temp | sed s/BUFFER/ByteBuffer/g > $CLASSPATH_SRC/gnu/java/nio/ByteBufferImpl.java + +gcc $CLASSPATH_SRC/gnu/java/nio/GenericMappedByteFileBuffer.cpp -E -P -I${top_builddir}/include > temp +cat temp | sed s/TYPE/Byte/g > $CLASSPATH_SRC/gnu/java/nio/MappedByteFileBuffer.java + + +echo "#define TYPE Short" > ${top_builddir}/include/temp.h +echo "#define ELT short" >> ${top_builddir}/include/temp.h +echo "#define SIZE 2" >> ${top_builddir}/include/temp.h +echo "#define SHORT 2" >> ${top_builddir}/include/temp.h +gcc $CLASSPATH_SRC/gnu/java/nio/GenericBuffer.cpp -E -P -I${top_builddir}/include > temp +cat temp | sed s/BUFFER/ShortBuffer/g > $CLASSPATH_SRC/gnu/java/nio/ShortBufferImpl.java + +gcc $CLASSPATH_SRC/gnu/java/nio/GenericMappedByteFileBuffer.cpp -E -P -I${top_builddir}/include > temp +cat temp | sed s/TYPE/Short/g > $CLASSPATH_SRC/gnu/java/nio/MappedShortFileBuffer.java + + +echo "#define TYPE Char" > ${top_builddir}/include/temp.h +echo "#define ELT char" >> ${top_builddir}/include/temp.h +echo "#define SIZE 2" >> ${top_builddir}/include/temp.h +echo "#define CHAR 2" >> ${top_builddir}/include/temp.h +gcc $CLASSPATH_SRC/gnu/java/nio/GenericBuffer.cpp -E -P -I${top_builddir}/include > temp +cat temp | sed s/BUFFER/CharBuffer/g > $CLASSPATH_SRC/gnu/java/nio/CharBufferImpl.java + +gcc $CLASSPATH_SRC/gnu/java/nio/GenericMappedByteFileBuffer.cpp -E -P -I${top_builddir}/include > temp +cat temp | sed s/TYPE/Char/g > $CLASSPATH_SRC/gnu/java/nio/MappedCharFileBuffer.java + + + +echo "#define TYPE Int" > ${top_builddir}/include/temp.h +echo "#define ELT int" >> ${top_builddir}/include/temp.h +echo "#define SIZE 4" >> ${top_builddir}/include/temp.h +echo "#define INT 2" >> ${top_builddir}/include/temp.h +gcc $CLASSPATH_SRC/gnu/java/nio/GenericBuffer.cpp -E -P -I${top_builddir}/include > temp +cat temp | sed s/BUFFER/IntBuffer/g > $CLASSPATH_SRC/gnu/java/nio/IntBufferImpl.java + +gcc $CLASSPATH_SRC/gnu/java/nio/GenericMappedByteFileBuffer.cpp -E -P -I${top_builddir}/include > temp +cat temp | sed s/TYPE/Int/g > $CLASSPATH_SRC/gnu/java/nio/MappedIntFileBuffer.java + + + +echo "#define TYPE Long" > ${top_builddir}/include/temp.h +echo "#define ELT long" >> ${top_builddir}/include/temp.h +echo "#define SIZE 8" >> ${top_builddir}/include/temp.h +echo "#define LONG" >> ${top_builddir}/include/temp.h +gcc $CLASSPATH_SRC/gnu/java/nio/GenericBuffer.cpp -E -P -I${top_builddir}/include > temp +cat temp | sed s/BUFFER/LongBuffer/g > $CLASSPATH_SRC/gnu/java/nio/LongBufferImpl.java + +gcc $CLASSPATH_SRC/gnu/java/nio/GenericMappedByteFileBuffer.cpp -E -P -I${top_builddir}/include > temp +cat temp | sed s/TYPE/Long/g > $CLASSPATH_SRC/gnu/java/nio/MappedLongFileBuffer.java + + + + +echo "#define TYPE Float" > ${top_builddir}/include/temp.h +echo "#define ELT float" >> ${top_builddir}/include/temp.h +echo "#define SIZE 4" >> ${top_builddir}/include/temp.h +echo "#define FLOAT" >> ${top_builddir}/include/temp.h + +gcc $CLASSPATH_SRC/gnu/java/nio/GenericBuffer.cpp -E -P -I${top_builddir}/include > temp +cat temp | sed s/BUFFER/FloatBuffer/g > $CLASSPATH_SRC/gnu/java/nio/FloatBufferImpl.java + +gcc $CLASSPATH_SRC/gnu/java/nio/GenericMappedByteFileBuffer.cpp -E -P -I${top_builddir}/include > temp +cat temp | sed s/TYPE/Float/g > $CLASSPATH_SRC/gnu/java/nio/MappedFloatFileBuffer.java + + + +echo "#define TYPE Double" > ${top_builddir}/include/temp.h +echo "#define ELT double" >> ${top_builddir}/include/temp.h +echo "#define SIZE 8" >> ${top_builddir}/include/temp.h +echo "#define DOUBLE 8" >> ${top_builddir}/include/temp.h +gcc $CLASSPATH_SRC/gnu/java/nio/GenericBuffer.cpp -E -P -I${top_builddir}/include > temp +cat temp | sed s/BUFFER/DoubleBuffer/g > $CLASSPATH_SRC/gnu/java/nio/DoubleBufferImpl.java + +gcc $CLASSPATH_SRC/gnu/java/nio/GenericMappedByteFileBuffer.cpp -E -P -I${top_builddir}/include > temp +cat temp | sed s/TYPE/Double/g > $CLASSPATH_SRC/gnu/java/nio/MappedDoubleFileBuffer.java |