summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichi Henning <michi@zeroc.com>2004-10-29 05:30:20 +0000
committerMichi Henning <michi@zeroc.com>2004-10-29 05:30:20 +0000
commit4ed2504cfbf467d87022fb46de6d39366c8283fb (patch)
treec17ec12b60fa280bafd3d471431b75b7ac2d20e0
parentReference refactoring. (diff)
downloadice-4ed2504cfbf467d87022fb46de6d39366c8283fb.tar.bz2
ice-4ed2504cfbf467d87022fb46de6d39366c8283fb.tar.xz
ice-4ed2504cfbf467d87022fb46de6d39366c8283fb.zip
Added code for streaming interfaces.
-rw-r--r--cs/src/Ice/BasicInputStream.cs22
-rw-r--r--cs/src/Ice/BasicOutputStream.cs23
-rwxr-xr-xcs/src/Ice/Exception.cs27
-rwxr-xr-xcs/src/Ice/Ice.csproj45
-rw-r--r--cs/src/Ice/InputStream.cs59
-rw-r--r--cs/src/Ice/InputStreamI.cs204
-rwxr-xr-xcs/src/Ice/Object.cs31
-rw-r--r--cs/src/Ice/ObjectReader.cs29
-rw-r--r--cs/src/Ice/ObjectWriter.cs30
-rw-r--r--cs/src/Ice/OutputStream.cs56
-rw-r--r--cs/src/Ice/OutputStreamI.cs174
-rwxr-xr-xcs/src/Ice/Patcher.cs7
-rw-r--r--cs/src/Ice/ReadObjectCallback.cs16
-rwxr-xr-xcs/src/Ice/Util.cs12
14 files changed, 732 insertions, 3 deletions
diff --git a/cs/src/Ice/BasicInputStream.cs b/cs/src/Ice/BasicInputStream.cs
new file mode 100644
index 00000000000..ae333117538
--- /dev/null
+++ b/cs/src/Ice/BasicInputStream.cs
@@ -0,0 +1,22 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2004 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
+
+namespace IceInternal
+{
+ public class BasicInputStream : BasicStream
+ {
+ public BasicInputStream(Instance instance, Ice.InputStream inStream)
+ : base(instance)
+ {
+ _in = inStream;
+ }
+
+ public Ice.InputStream _in;
+ }
+}
diff --git a/cs/src/Ice/BasicOutputStream.cs b/cs/src/Ice/BasicOutputStream.cs
new file mode 100644
index 00000000000..11985271ff5
--- /dev/null
+++ b/cs/src/Ice/BasicOutputStream.cs
@@ -0,0 +1,23 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2004 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
+
+namespace IceInternal
+{
+
+ public class BasicOutputStream : BasicStream
+ {
+ public BasicOutputStream(Instance instance, Ice.OutputStream outStream)
+ : base(instance)
+ {
+ _out = outStream;
+ }
+
+ public Ice.OutputStream _out;
+ }
+}
diff --git a/cs/src/Ice/Exception.cs b/cs/src/Ice/Exception.cs
index bd7eb037985..4e01330c444 100755
--- a/cs/src/Ice/Exception.cs
+++ b/cs/src/Ice/Exception.cs
@@ -1,3 +1,14 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2004 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
+
+using System.Diagnostics;
+
namespace Ice
{
@@ -28,7 +39,21 @@ namespace Ice
private static readonly string _dflt = "Ice.UserException";
public abstract void __write(IceInternal.BasicStream __os);
public abstract void __read(IceInternal.BasicStream __is, bool __rid);
- public abstract bool __usesClasses();
+
+ public virtual void __write(Ice.OutputStream __out)
+ {
+ Debug.Assert(false);
+ }
+
+ public virtual void __read(Ice.InputStream __in, bool __rid)
+ {
+ Debug.Assert(false);
+ }
+
+ public virtual bool __usesClasses()
+ {
+ return false;
+ }
}
}
diff --git a/cs/src/Ice/Ice.csproj b/cs/src/Ice/Ice.csproj
index 3ebee81de12..846e7961aed 100755
--- a/cs/src/Ice/Ice.csproj
+++ b/cs/src/Ice/Ice.csproj
@@ -94,6 +94,16 @@
BuildAction = "Compile"
/>
<File
+ RelPath = "BasicInputStream.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "BasicOutputStream.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
RelPath = "BasicStream.cs"
SubType = "Code"
BuildAction = "Compile"
@@ -174,6 +184,16 @@
BuildAction = "Compile"
/>
<File
+ RelPath = "InputStream.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "InputStreamI.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
RelPath = "Instance.cs"
SubType = "Code"
BuildAction = "Compile"
@@ -224,6 +244,16 @@
BuildAction = "Compile"
/>
<File
+ RelPath = "ObjectReader.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "ObjectWriter.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
RelPath = "Outgoing.cs"
SubType = "Code"
BuildAction = "Compile"
@@ -239,6 +269,16 @@
BuildAction = "Compile"
/>
<File
+ RelPath = "OutputStream.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "OutputStreamI.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
RelPath = "Patcher.cs"
SubType = "Code"
BuildAction = "Compile"
@@ -269,6 +309,11 @@
BuildAction = "Compile"
/>
<File
+ RelPath = "ReadObjectCallback.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
RelPath = "Reference.cs"
SubType = "Code"
BuildAction = "Compile"
diff --git a/cs/src/Ice/InputStream.cs b/cs/src/Ice/InputStream.cs
new file mode 100644
index 00000000000..3bbb2decfcf
--- /dev/null
+++ b/cs/src/Ice/InputStream.cs
@@ -0,0 +1,59 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2004 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
+
+namespace Ice
+{
+ public interface InputStream
+ {
+ Communicator communicator();
+
+ void sliceObjects(bool slice);
+
+ bool readBool();
+ bool[] readBoolSeq();
+
+ byte readByte();
+ byte[] readByteSeq();
+
+ short readShort();
+ short[] readShortSeq();
+
+ int readInt();
+ int[] readIntSeq();
+
+ long readLong();
+ long[] readLongSeq();
+
+ float readFloat();
+ float[] readFloatSeq();
+
+ double readDouble();
+ double[] readDoubleSeq();
+
+ string readString();
+ string[] readStringSeq();
+
+ int readSize();
+
+ ObjectPrx readProxy();
+
+ void readObject(ReadObjectCallback cb);
+
+ string readTypeId();
+
+ void throwException();
+
+ void startSlice();
+ void endSlice();
+ void skipSlice();
+
+ void finished();
+ void destroy();
+ }
+}
diff --git a/cs/src/Ice/InputStreamI.cs b/cs/src/Ice/InputStreamI.cs
new file mode 100644
index 00000000000..f335bdfc6d8
--- /dev/null
+++ b/cs/src/Ice/InputStreamI.cs
@@ -0,0 +1,204 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2004 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
+
+namespace Ice
+{
+ public class InputStreamI : InputStream
+ {
+ public InputStreamI(Communicator communicator, byte[] data)
+ {
+ _communicator = communicator;
+ _readObjects = false;
+
+ _is = new IceInternal.BasicInputStream(Util.getInstance(communicator), this);
+ _is.resize(data.Length, true);
+ IceInternal.ByteBuffer buf = _is.prepareRead();
+ buf.position(0);
+ buf.put(data);
+ buf.position(0);
+ }
+
+ ~InputStreamI()
+ {
+ destroy();
+ }
+
+ public Communicator communicator()
+ {
+ return _communicator;
+ }
+
+ public void sliceObjects(bool slice)
+ {
+ _is.sliceObjects(slice);
+ }
+
+ public bool readBool()
+ {
+ return _is.readBool();
+ }
+
+ public bool[] readBoolSeq()
+ {
+ return _is.readBoolSeq();
+ }
+
+ public byte readByte()
+ {
+ return _is.readByte();
+ }
+
+ public byte[] readByteSeq()
+ {
+ return _is.readByteSeq();
+ }
+
+ public short readShort()
+ {
+ return _is.readShort();
+ }
+
+ public short[] readShortSeq()
+ {
+ return _is.readShortSeq();
+ }
+
+ public int readInt()
+ {
+ return _is.readInt();
+ }
+
+ public int[] readIntSeq()
+ {
+ return _is.readIntSeq();
+ }
+
+ public long readLong()
+ {
+ return _is.readLong();
+ }
+
+ public long[] readLongSeq()
+ {
+ return _is.readLongSeq();
+ }
+
+ public float readFloat()
+ {
+ return _is.readFloat();
+ }
+
+ public float[] readFloatSeq()
+ {
+ return _is.readFloatSeq();
+ }
+
+ public double readDouble()
+ {
+ return _is.readDouble();
+ }
+
+ public double[] readDoubleSeq()
+ {
+ return _is.readDoubleSeq();
+ }
+
+ public string readString()
+ {
+ return _is.readString();
+ }
+
+ public string[] readStringSeq()
+ {
+ return _is.readStringSeq();
+ }
+
+ public int readSize()
+ {
+ return _is.readSize();
+ }
+
+ public ObjectPrx readProxy()
+ {
+ return _is.readProxy();
+ }
+
+ private class Patcher : IceInternal.Patcher
+ {
+ public Patcher(ReadObjectCallback cb)
+ {
+ _cb = cb;
+ }
+
+ public override void patch(Ice.Object v)
+ {
+ _cb.invoke(v);
+ }
+
+ public override string type()
+ {
+ return "unknown";
+ }
+
+ ReadObjectCallback _cb;
+ }
+
+ public void readObject(ReadObjectCallback cb)
+ {
+ _readObjects = true;
+ _is.readObject(new Patcher(cb));
+ }
+
+ public string readTypeId()
+ {
+ return _is.readTypeId();
+ }
+
+ public void throwException()
+ {
+ _is.throwException();
+ }
+
+ public void startSlice()
+ {
+ _is.startReadSlice();
+ }
+
+ public void endSlice()
+ {
+ _is.endReadSlice();
+ }
+
+ public void skipSlice()
+ {
+ _is.skipSlice();
+ }
+
+ public void finished()
+ {
+ if(_readObjects)
+ {
+ _is.readPendingObjects();
+ }
+ }
+
+ public void destroy()
+ {
+ if(_is != null)
+ {
+ _is.destroy();
+ _is = null;
+ }
+ }
+
+ private Communicator _communicator;
+ private IceInternal.BasicInputStream _is;
+ private bool _readObjects;
+ }
+}
diff --git a/cs/src/Ice/Object.cs b/cs/src/Ice/Object.cs
index df21b963b06..d8c4d9614cd 100755
--- a/cs/src/Ice/Object.cs
+++ b/cs/src/Ice/Object.cs
@@ -51,8 +51,12 @@ namespace Ice
void ice_postUnmarshal();
IceInternal.DispatchStatus __dispatch(IceInternal.Incoming inc, Current current);
+
void __write(IceInternal.BasicStream __os);
void __read(IceInternal.BasicStream __is, bool __rid);
+
+ void __write(OutputStream __out);
+ void __read(InputStream __in, bool __rid);
}
public class ObjectImpl : Object
@@ -226,6 +230,33 @@ namespace Ice
__is.endReadSlice();
}
+ public void __write(OutputStream __out)
+ {
+ __out.writeTypeId(ice_staticId());
+ __out.startSlice();
+ __out.writeSize(0); // For compatibility with the old AFM.
+ __out.endSlice();
+ }
+
+ public void __read(InputStream __in, bool __rid)
+ {
+ if(__rid)
+ {
+ string myId = __in.readTypeId();
+ }
+
+ __in.startSlice();
+
+ // For compatibility with the old AFM.
+ int sz = __in.readSize();
+ if(sz != 0)
+ {
+ throw new MarshalException();
+ }
+
+ __in.endSlice();
+ }
+
public static Ice.Current defaultCurrent = new Ice.Current();
}
diff --git a/cs/src/Ice/ObjectReader.cs b/cs/src/Ice/ObjectReader.cs
new file mode 100644
index 00000000000..b95212e9b00
--- /dev/null
+++ b/cs/src/Ice/ObjectReader.cs
@@ -0,0 +1,29 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2004 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
+
+using System.Diagnostics;
+
+namespace Ice
+{
+ public abstract class ObjectReader : ObjectImpl
+ {
+ public abstract void read(InputStream inStream, bool rid);
+
+ public override void __write(IceInternal.BasicStream os)
+ {
+ Debug.Assert(false);
+ }
+
+ public override void __read(IceInternal.BasicStream istr, bool rid)
+ {
+ IceInternal.BasicInputStream bis = (IceInternal.BasicInputStream)istr;
+ read(bis._in, rid);
+ }
+ }
+}
diff --git a/cs/src/Ice/ObjectWriter.cs b/cs/src/Ice/ObjectWriter.cs
new file mode 100644
index 00000000000..3268a46ba2a
--- /dev/null
+++ b/cs/src/Ice/ObjectWriter.cs
@@ -0,0 +1,30 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2004 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
+
+using System.Diagnostics;
+
+namespace Ice {
+
+ public abstract class ObjectWriter : ObjectImpl
+ {
+ public abstract void write(OutputStream outStream);
+
+ public override void __write(IceInternal.BasicStream os)
+ {
+ IceInternal.BasicOutputStream bos = (IceInternal.BasicOutputStream)os;
+ write(bos._out);
+ }
+
+ public override void __read(IceInternal.BasicStream istr, bool rid)
+ {
+ Debug.Assert(false);
+ }
+ }
+
+}
diff --git a/cs/src/Ice/OutputStream.cs b/cs/src/Ice/OutputStream.cs
new file mode 100644
index 00000000000..c41d0695780
--- /dev/null
+++ b/cs/src/Ice/OutputStream.cs
@@ -0,0 +1,56 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2004 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
+
+namespace Ice
+{
+ public interface OutputStream
+ {
+ Communicator communicator();
+
+ void writeBool(bool v);
+ void writeBoolSeq(bool[] v);
+
+ void writeByte(byte v);
+ void writeByteSeq(byte[] v);
+
+ void writeShort(short v);
+ void writeShortSeq(short[] v);
+
+ void writeInt(int v);
+ void writeIntSeq(int[] v);
+
+ void writeLong(long v);
+ void writeLongSeq(long[] v);
+
+ void writeFloat(float v);
+ void writeFloatSeq(float[] v);
+
+ void writeDouble(double v);
+ void writeDoubleSeq(double[] v);
+
+ void writeString(string v);
+ void writeStringSeq(string[] v);
+
+ void writeSize(int sz);
+
+ void writeProxy(ObjectPrx v);
+
+ void writeObject(Ice.Object v);
+
+ void writeTypeId(string id);
+
+ void writeException(UserException ex);
+
+ void startSlice();
+ void endSlice();
+
+ byte[] finished();
+ void destroy();
+ }
+}
diff --git a/cs/src/Ice/OutputStreamI.cs b/cs/src/Ice/OutputStreamI.cs
new file mode 100644
index 00000000000..884fc127da8
--- /dev/null
+++ b/cs/src/Ice/OutputStreamI.cs
@@ -0,0 +1,174 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2004 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
+
+namespace Ice
+{
+ public class OutputStreamI : OutputStream
+ {
+ public OutputStreamI(Communicator communicator)
+ {
+ _communicator = communicator;
+ _os = new IceInternal.BasicOutputStream(Util.getInstance(communicator), this);
+ _writeObjects = false;
+ }
+
+ ~OutputStreamI()
+ {
+ destroy();
+ }
+
+ public Communicator communicator()
+ {
+ return _communicator;
+ }
+
+ public void writeBool(bool v)
+ {
+ _os.writeBool(v);
+ }
+
+ public void writeBoolSeq(bool[] v)
+ {
+ _os.writeBoolSeq(v);
+ }
+
+ public void writeByte(byte v)
+ {
+ _os.writeByte(v);
+ }
+
+ public void writeByteSeq(byte[] v)
+ {
+ _os.writeByteSeq(v);
+ }
+
+ public void writeShort(short v)
+ {
+ _os.writeShort(v);
+ }
+
+ public void writeShortSeq(short[] v)
+ {
+ _os.writeShortSeq(v);
+ }
+
+ public void writeInt(int v)
+ {
+ _os.writeInt(v);
+ }
+
+ public void writeIntSeq(int[] v)
+ {
+ _os.writeIntSeq(v);
+ }
+
+ public void writeLong(long v)
+ {
+ _os.writeLong(v);
+ }
+
+ public void writeLongSeq(long[] v)
+ {
+ _os.writeLongSeq(v);
+ }
+
+ public void writeFloat(float v)
+ {
+ _os.writeFloat(v);
+ }
+
+ public void writeFloatSeq(float[] v)
+ {
+ _os.writeFloatSeq(v);
+ }
+
+ public void writeDouble(double v)
+ {
+ _os.writeDouble(v);
+ }
+
+ public void writeDoubleSeq(double[] v)
+ {
+ _os.writeDoubleSeq(v);
+ }
+
+ public void writeString(string v)
+ {
+ _os.writeString(v);
+ }
+
+ public void writeStringSeq(string[] v)
+ {
+ _os.writeStringSeq(v);
+ }
+
+ public void writeSize(int sz)
+ {
+ _os.writeSize(sz);
+ }
+
+ public void writeProxy(ObjectPrx v)
+ {
+ _os.writeProxy(v);
+ }
+
+ public void writeObject(Ice.Object v)
+ {
+ _writeObjects = true;
+ _os.writeObject(v);
+ }
+
+ public void writeTypeId(string id)
+ {
+ _os.writeTypeId(id);
+ }
+
+ public void writeException(UserException v)
+ {
+ _os.writeUserException(v);
+ }
+
+ public void startSlice()
+ {
+ _os.startWriteSlice();
+ }
+
+ public void endSlice()
+ {
+ _os.endWriteSlice();
+ }
+
+ public byte[] finished()
+ {
+ if(_writeObjects)
+ {
+ _os.writePendingObjects();
+ }
+
+ IceInternal.ByteBuffer buf = _os.prepareWrite();
+ byte[] result = new byte[buf.limit()];
+ buf.get(result);
+
+ return result;
+ }
+
+ public void destroy()
+ {
+ if(_os != null)
+ {
+ _os.destroy();
+ _os = null;
+ }
+ }
+
+ private Communicator _communicator;
+ private IceInternal.BasicOutputStream _os;
+ private bool _writeObjects;
+ }
+}
diff --git a/cs/src/Ice/Patcher.cs b/cs/src/Ice/Patcher.cs
index 2860b523025..8b99211ecf7 100755
--- a/cs/src/Ice/Patcher.cs
+++ b/cs/src/Ice/Patcher.cs
@@ -26,12 +26,17 @@ namespace IceInternal
public abstract void patch(Ice.Object v);
- public string type()
+ public virtual string type()
{
Debug.Assert(_type != null);
return _type.FullName;
}
+ public virtual void invoke(Ice.Object v)
+ {
+ patch(v);
+ }
+
protected System.Type _type;
}
diff --git a/cs/src/Ice/ReadObjectCallback.cs b/cs/src/Ice/ReadObjectCallback.cs
new file mode 100644
index 00000000000..6f5c59b6c1e
--- /dev/null
+++ b/cs/src/Ice/ReadObjectCallback.cs
@@ -0,0 +1,16 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2004 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
+
+namespace Ice
+{
+ public interface ReadObjectCallback
+ {
+ void invoke(Ice.Object obj);
+ }
+}
diff --git a/cs/src/Ice/Util.cs b/cs/src/Ice/Util.cs
index c7131c45ab9..fbf363b5152 100755
--- a/cs/src/Ice/Util.cs
+++ b/cs/src/Ice/Util.cs
@@ -361,7 +361,17 @@ namespace Ice
}
}
}
-
+
+ public static InputStream createInputStream(Communicator communicator, byte[] bytes)
+ {
+ return new InputStreamI(communicator, bytes);
+ }
+
+ public static OutputStream createOutputStream(Communicator communicator)
+ {
+ return new OutputStreamI(communicator);
+ }
+
private static Properties _defaultProperties = null;
}