aboutsummaryrefslogtreecommitdiff
path: root/libjava/gnu/java/nio
diff options
context:
space:
mode:
authorMichael Koch <konqueror@gmx.de>2003-10-12 13:39:07 +0000
committerMichael Koch <mkoch@gcc.gnu.org>2003-10-12 13:39:07 +0000
commit81bc077a39faa66769629155bc7d3c03cfe1d194 (patch)
tree5d08f0f5020b2a6cf46bdef0ba775007240ccd17 /libjava/gnu/java/nio
parentb77d1698d9615b96f094c2bf665f4b16d6c5d674 (diff)
downloadgcc-81bc077a39faa66769629155bc7d3c03cfe1d194.zip
gcc-81bc077a39faa66769629155bc7d3c03cfe1d194.tar.gz
gcc-81bc077a39faa66769629155bc7d3c03cfe1d194.tar.bz2
2003-10-12 Michael Koch <konqueror@gmx.de>
* gnu/java/nio/PipeImpl.java (SourceChannelImpl): New inner class. (SinkChannelImpl): New inner class. (sink): New member variable. (source): New member variable. (PipeImpl): Add SelectorProvider argument, implemented. (nativeInit): New method. (sink): Return sink channel. (source): Return source channel. * gnu/java/nio/SelectorProviderImpl.java (openPipe): Give provider as argument to PipeImpl constructor. * java/nio/channels/spi/SelectorProvider.java (pr): Removed. (systemDefaultProvider): New member variable. (provider): Made it synchronized, use property java.nio.channels.spi.SelectorProvider. * gnu/java/nio/natPipeImpl.cc: New file. * Makefile.am (nat_source_files): Added gnu/java/nio/natPipeImpl.cc. * Makefile.in: Regenerated. From-SVN: r72397
Diffstat (limited to 'libjava/gnu/java/nio')
-rw-r--r--libjava/gnu/java/nio/PipeImpl.java114
-rw-r--r--libjava/gnu/java/nio/SelectorProviderImpl.java4
-rw-r--r--libjava/gnu/java/nio/natPipeImpl.cc38
3 files changed, 150 insertions, 6 deletions
diff --git a/libjava/gnu/java/nio/PipeImpl.java b/libjava/gnu/java/nio/PipeImpl.java
index 77341e7..da608d2 100644
--- a/libjava/gnu/java/nio/PipeImpl.java
+++ b/libjava/gnu/java/nio/PipeImpl.java
@@ -1,5 +1,5 @@
/* PipeImpl.java --
- Copyright (C) 2002 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2003 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -37,21 +37,127 @@ exception statement from your version. */
package gnu.java.nio;
+import java.io.IOException;
+import java.nio.ByteBuffer;
import java.nio.channels.Pipe;
+import java.nio.channels.spi.SelectorProvider;
class PipeImpl extends Pipe
{
- public PipeImpl()
+ public final class SourceChannelImpl extends Pipe.SourceChannel
{
+ private int native_fd;
+
+ public SourceChannelImpl (SelectorProvider selectorProvider,
+ int native_fd)
+ {
+ super (selectorProvider);
+ this.native_fd = native_fd;
+ }
+
+ protected final void implCloseSelectableChannel()
+ throws IOException
+ {
+ throw new Error ("Not implemented");
+ }
+
+ protected void implConfigureBlocking (boolean blocking)
+ throws IOException
+ {
+ throw new Error ("Not implemented");
+ }
+
+ public final int read (ByteBuffer src)
+ throws IOException
+ {
+ throw new Error ("Not implemented");
+ }
+
+ public final long read (ByteBuffer[] srcs)
+ throws IOException
+ {
+ return read (srcs, 0, srcs.length);
+ }
+
+ public final long read (ByteBuffer[] srcs, int offset, int len)
+ throws IOException
+ {
+ throw new Error ("Not implemented");
+ }
+
+ public final int getNativeFD()
+ {
+ return native_fd;
+ }
}
+
+ public final class SinkChannelImpl extends Pipe.SinkChannel
+ {
+ private int native_fd;
+
+ public SinkChannelImpl (SelectorProvider selectorProvider,
+ int native_fd)
+ {
+ super (selectorProvider);
+ this.native_fd = native_fd;
+ }
+
+ protected final void implCloseSelectableChannel()
+ throws IOException
+ {
+ throw new Error ("Not implemented");
+ }
+
+ protected final void implConfigureBlocking (boolean blocking)
+ throws IOException
+ {
+ throw new Error ("Not implemented");
+ }
+
+ public final int write (ByteBuffer dst)
+ throws IOException
+ {
+ throw new Error ("Not implemented");
+ }
+
+ public final long write (ByteBuffer[] dsts)
+ throws IOException
+ {
+ return write (dsts, 0, dsts.length);
+ }
+
+ public final long write (ByteBuffer[] dsts, int offset, int len)
+ throws IOException
+ {
+ throw new Error ("Not implemented");
+ }
+
+ public final int getNativeFD()
+ {
+ return native_fd;
+ }
+ }
+
+ private SinkChannelImpl sink;
+ private SourceChannelImpl source;
+
+ public PipeImpl (SelectorProvider provider)
+ throws IOException
+ {
+ super();
+ nativeInit (provider);
+ }
+
+ private native void nativeInit (SelectorProvider provider)
+ throws IOException;
public Pipe.SinkChannel sink()
{
- return null;
+ return sink;
}
public Pipe.SourceChannel source()
{
- return null;
+ return source;
}
}
diff --git a/libjava/gnu/java/nio/SelectorProviderImpl.java b/libjava/gnu/java/nio/SelectorProviderImpl.java
index d58e10a..41966ef 100644
--- a/libjava/gnu/java/nio/SelectorProviderImpl.java
+++ b/libjava/gnu/java/nio/SelectorProviderImpl.java
@@ -1,5 +1,5 @@
/* SelectorProviderImpl.java --
- Copyright (C) 2002 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2003 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -60,7 +60,7 @@ public class SelectorProviderImpl extends SelectorProvider
public Pipe openPipe ()
throws IOException
{
- return new PipeImpl ();
+ return new PipeImpl (this);
}
public AbstractSelector openSelector ()
diff --git a/libjava/gnu/java/nio/natPipeImpl.cc b/libjava/gnu/java/nio/natPipeImpl.cc
new file mode 100644
index 0000000..522c24c
--- /dev/null
+++ b/libjava/gnu/java/nio/natPipeImpl.cc
@@ -0,0 +1,38 @@
+// natPipeImpl.cc
+
+/* Copyright (C) 2003 Free Software Foundation
+
+ This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
+details. */
+
+#include <config.h>
+#include <platform.h>
+
+#include <errno.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <gnu/java/nio/PipeImpl.h>
+//#include <gnu/java/nio/PipeImpl$SinkChannelImpl.h>
+//#include <gnu/java/nio/PipeImpl$SourceChannelImpl.h>
+#include <java/io/IOException.h>
+#include <java/nio/channels/spi/SelectorProvider.h>
+
+void
+gnu::java::nio::PipeImpl::nativeInit (::java::nio::channels::spi::SelectorProvider* /*provider*/)
+{
+ int filedes [2];
+
+ if (::pipe (filedes) < 0)
+ throw new ::java::io::IOException (JvNewStringUTF (strerror (errno)));
+
+ /* FIXME
+ source = new gnu::java::nio::PipeImpl$SourceChannelImpl
+ (this, provider, filedes [0]);
+ sink = new gnu::java::nio::PipeImpl$SinkChannelImpl
+ (this, provider, filedes [1]);
+ */
+}