summaryrefslogtreecommitdiffstats
path: root/libjava/java
diff options
context:
space:
mode:
authormkoch <mkoch@138bc75d-0d04-0410-961f-82ee72b054a4>2003-06-17 19:09:56 +0000
committermkoch <mkoch@138bc75d-0d04-0410-961f-82ee72b054a4>2003-06-17 19:09:56 +0000
commit9228fac157aeefc6c2212565842b92c01c700ae9 (patch)
tree070d161eb50c6f132e76f98bbc8b9ada414dad0f /libjava/java
parent9b1cd64ed71362dc0e8d0b20782cff407ec012a6 (diff)
downloadppe42-gcc-9228fac157aeefc6c2212565842b92c01c700ae9.tar.gz
ppe42-gcc-9228fac157aeefc6c2212565842b92c01c700ae9.zip
2003-06-17 Michael Koch <konqueror@gmx.de>
* java/nio/DirectByteBufferImpl.java (address): Made package private. (DirectByteBufferImpl): New constructor. * java/nio/natDirectByteBufferImpl.cc (allocateImpl): Moved to java.nio namespace, implemented. (freeImpl): Likewise. (getImpl): Likewise. (putImpl): Likewise. * jni.cc (_Jv_JNI_NewDirectByteBuffer): Implemented. (_Jv_JNI_GetDirectBufferAddress): Implemented. (_Jv_JNI_GetDirectBufferCapacity): Implemented. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@68105 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/java')
-rw-r--r--libjava/java/nio/DirectByteBufferImpl.java7
-rw-r--r--libjava/java/nio/natDirectByteBufferImpl.cc24
2 files changed, 18 insertions, 13 deletions
diff --git a/libjava/java/nio/DirectByteBufferImpl.java b/libjava/java/nio/DirectByteBufferImpl.java
index b037385c4af..c746723f0d8 100644
--- a/libjava/java/nio/DirectByteBufferImpl.java
+++ b/libjava/java/nio/DirectByteBufferImpl.java
@@ -42,9 +42,14 @@ import gnu.gcj.RawData;
public class DirectByteBufferImpl extends ByteBuffer
{
- private RawData address;
+ RawData address;
private int offset;
private boolean readOnly;
+
+ public DirectByteBufferImpl (RawData address, long len)
+ {
+ this (address, 0, (int) len, (int) len, 0, -1, false);
+ }
public DirectByteBufferImpl (RawData address, int offset, int capacity,
int limit, int position, int mark,
diff --git a/libjava/java/nio/natDirectByteBufferImpl.cc b/libjava/java/nio/natDirectByteBufferImpl.cc
index 82863900256..2ceea170551 100644
--- a/libjava/java/nio/natDirectByteBufferImpl.cc
+++ b/libjava/java/nio/natDirectByteBufferImpl.cc
@@ -13,33 +13,33 @@ details. */
#include <gcj/cni.h>
#include <jvm.h>
+#include <stdlib.h>
+
#include <gnu/gcj/RawData.h>
#include <java/nio/DirectByteBufferImpl.h>
gnu::gcj::RawData*
-java::nio::DirectByteBufferImpl::allocateImpl (jint /*capacity*/)
+java::nio::DirectByteBufferImpl::allocateImpl (jint capacity)
{
- // FIXME: implement this
- return 0;
+ return reinterpret_cast<gnu::gcj::RawData*> (::malloc (capacity));
}
void
-java::nio::DirectByteBufferImpl::freeImpl (gnu::gcj::RawData* /*address*/)
+java::nio::DirectByteBufferImpl::freeImpl (gnu::gcj::RawData* address)
{
- // FIXME: implement this
+ ::free (reinterpret_cast<void*> (address));
}
jbyte
-java::nio::DirectByteBufferImpl::getImpl (jint /*index*/)
+java::nio::DirectByteBufferImpl::getImpl (jint index)
{
- // FIXME: implement this
- // Dont forget: add offset to index
- return 0;
+ jbyte* pointer = reinterpret_cast<jbyte*> (address) + offset + index;
+ return *pointer;
}
void
-java::nio::DirectByteBufferImpl::putImpl (jint /*index*/, jbyte /*value*/)
+java::nio::DirectByteBufferImpl::putImpl (jint index, jbyte value)
{
- // FIXME: implement this
- // Dont forget: add offset to index
+ jbyte* pointer = reinterpret_cast<jbyte*> (address) + offset + index;
+ *pointer = value;
}
OpenPOWER on IntegriCloud