Well, it compiles.
It's not functional, there are still large holes in the implementation. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3868 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -26,7 +26,7 @@ public class ObjectInputStream
|
||||
_source = source;
|
||||
}
|
||||
|
||||
public function readObject () :*
|
||||
public function readObject () :Object
|
||||
//throws IOError
|
||||
{
|
||||
try {
|
||||
@@ -61,7 +61,7 @@ public class ObjectInputStream
|
||||
}
|
||||
}
|
||||
|
||||
var target :*;
|
||||
var target :Object;
|
||||
if (cmap.streamer === null) {
|
||||
var clazz :Class = flash.util.getClassByName(cmap.classname);
|
||||
target = new clazz();
|
||||
@@ -75,15 +75,16 @@ public class ObjectInputStream
|
||||
} catch (me :MemoryError) {
|
||||
throw new IOError("out of memory" + me.message);
|
||||
}
|
||||
return null; // not reached: compiler dumb
|
||||
}
|
||||
|
||||
public function readBareObject (obj :*) :void
|
||||
public function readBareObject (obj :Object) :void
|
||||
//throws IOError
|
||||
{
|
||||
readBareObjectImpl(obj, Streamer.getStreamer(obj));
|
||||
}
|
||||
|
||||
protected function readBareObjectImpl (obj :*, streamer :Streamer) :void
|
||||
protected function readBareObjectImpl (obj :Object, streamer :Streamer) :void
|
||||
{
|
||||
// streamable objects
|
||||
if (streamer == null) {
|
||||
@@ -105,11 +106,11 @@ public class ObjectInputStream
|
||||
|
||||
// TODO: this is the equivalent of marshalling something for which
|
||||
// we have a basic streamer. Fill out with all the java types
|
||||
public function readField (clazz :Class) :*
|
||||
public function readField (clazz :Class) :Object
|
||||
//throws IOError
|
||||
{
|
||||
if (readBoolean()) {
|
||||
var obj :* = new clazz();
|
||||
var obj :Object = new clazz();
|
||||
return readBareObject(obj);
|
||||
}
|
||||
return null;
|
||||
@@ -179,7 +180,7 @@ public class ObjectInputStream
|
||||
/**
|
||||
* Used by a Streamer that is reading an array of Streamable instances.
|
||||
*/
|
||||
protected function setCurrent (streamer :Streamer, current :*)
|
||||
protected function setCurrent (streamer :Streamer, current :Object)
|
||||
{
|
||||
_streamer = streamer;
|
||||
_current = current;
|
||||
@@ -189,7 +190,7 @@ public class ObjectInputStream
|
||||
protected var _source :IDataInput;
|
||||
|
||||
/** The object currently being read from the stream. */
|
||||
protected var _current :*;
|
||||
protected var _current :Object;
|
||||
|
||||
/** The stramer being used currently. */
|
||||
protected var _streamer :Streamer;
|
||||
|
||||
@@ -15,7 +15,7 @@ public class ObjectOutputStream
|
||||
_targ = targ;
|
||||
}
|
||||
|
||||
public function writeObject (obj :*) :void
|
||||
public function writeObject (obj :Object) :void
|
||||
//throws IOError
|
||||
{
|
||||
// if the object to be written is null (or undefined) write a zero
|
||||
@@ -53,13 +53,13 @@ public class ObjectOutputStream
|
||||
writeBareObjectImpl(obj, cmap.streamer);
|
||||
}
|
||||
|
||||
public function writeBareObject (obj :*) :void
|
||||
public function writeBareObject (obj :Object) :void
|
||||
//throws IOError
|
||||
{
|
||||
writeBareObjectImpl(obj, Streamer.getStreamer(obj));
|
||||
}
|
||||
|
||||
protected function writeBareObjectImpl (obj :*, streamer :Streamer)
|
||||
protected function writeBareObjectImpl (obj :Object, streamer :Streamer)
|
||||
{
|
||||
// if it's Streamable, it goes straight through
|
||||
if (streamer == null) {
|
||||
@@ -80,7 +80,7 @@ public class ObjectOutputStream
|
||||
|
||||
// TODO: this is equivalent to marshalling a field for which there
|
||||
// is a basic streamer. Work needs doing here.
|
||||
public function writeField (val :*) :void
|
||||
public function writeField (val :Object) :void
|
||||
//throws IOError
|
||||
{
|
||||
var b :Boolean = (val != null);
|
||||
@@ -165,7 +165,7 @@ public class ObjectOutputStream
|
||||
/**
|
||||
* Used by a Streamer that is writing an array of Streamable instances.
|
||||
*/
|
||||
protected function setCurrent (streamer :Streamer, current :*)
|
||||
protected function setCurrent (streamer :Streamer, current :Object)
|
||||
{
|
||||
_streamer = streamer;
|
||||
_current = current;
|
||||
@@ -178,7 +178,7 @@ public class ObjectOutputStream
|
||||
protected var _nextCode :int = 1;
|
||||
|
||||
/** The object currently being written out. */
|
||||
protected var _current :*;
|
||||
protected var _current :Object;
|
||||
|
||||
/** The streamer being used currently. */
|
||||
protected var _streamer :Streamer;
|
||||
|
||||
@@ -32,7 +32,7 @@ public class Streamer
|
||||
}
|
||||
*/
|
||||
|
||||
public static function getStreamer (obj :*) :Streamer
|
||||
public static function getStreamer (obj :Object) :Streamer
|
||||
{
|
||||
if (obj is Streamable) {
|
||||
return null;
|
||||
@@ -74,7 +74,7 @@ public class Streamer
|
||||
_jname = jname;
|
||||
}
|
||||
|
||||
public function isStreamerFor (obj :*) :Boolean
|
||||
public function isStreamerFor (obj :Object) :Boolean
|
||||
{
|
||||
return (obj is _targ); // scripting langs are weird
|
||||
}
|
||||
@@ -87,7 +87,7 @@ public class Streamer
|
||||
return _jname;
|
||||
}
|
||||
|
||||
public function writeObject (obj :*, out :ObjectOutputStream) :void
|
||||
public function writeObject (obj :Object, out :ObjectOutputStream) :void
|
||||
//throws IOError
|
||||
{
|
||||
trace("TODO");
|
||||
@@ -102,14 +102,14 @@ public class Streamer
|
||||
}
|
||||
}
|
||||
|
||||
public function createObject (ins :ObjectInputStream) :*
|
||||
public function createObject (ins :ObjectInputStream) :Object
|
||||
//throws IOError
|
||||
{
|
||||
// actionscript is so fucked up
|
||||
return new _targ();
|
||||
}
|
||||
|
||||
public function readObject (obj :*, ins :ObjectInputStream) :void
|
||||
public function readObject (obj :Object, ins :ObjectInputStream) :void
|
||||
//throws IOError
|
||||
{
|
||||
trace("TODO");
|
||||
|
||||
@@ -14,12 +14,13 @@ public class ArrayStreamer extends Streamer
|
||||
super(Array, "[Ljava.lang.Object");
|
||||
}
|
||||
|
||||
public override function createObject (ins :ObjectInputStream) :*
|
||||
public override function createObject (ins :ObjectInputStream) :Object
|
||||
{
|
||||
return new Array(ins.readInt());
|
||||
}
|
||||
|
||||
public override function writeObject (obj :*, out :ObjectOutputStream) :void
|
||||
public override function writeObject (obj :Object, out :ObjectOutputStream)
|
||||
:void
|
||||
{
|
||||
var arr :Array = (obj as Array);
|
||||
out.writeInt(arr.length);
|
||||
@@ -28,7 +29,8 @@ public class ArrayStreamer extends Streamer
|
||||
}
|
||||
}
|
||||
|
||||
public override function readObject (obj :*, ins :ObjectInputStream) :void
|
||||
public override function readObject (obj :Object, ins :ObjectInputStream)
|
||||
:void
|
||||
{
|
||||
var arr :Array = (obj as Array);
|
||||
for (var ii :int = 0; ii < arr.length; ii++) {
|
||||
|
||||
@@ -16,21 +16,23 @@ public class ByteArrayStreamer extends Streamer
|
||||
super(ByteArray, "[B"); // yes, that's the Java class for a byte[].
|
||||
}
|
||||
|
||||
public override function createObject (ins :ObjectInputStream) :*
|
||||
public override function createObject (ins :ObjectInputStream) :Object
|
||||
{
|
||||
var bytes :ByteArray = new ByteArray();
|
||||
bytes.length = ins.readInt();
|
||||
return bytes;
|
||||
}
|
||||
|
||||
public override function writeObject (obj :*, out :ObjectOutputStream) :void
|
||||
public override function writeObject (obj :Object, out :ObjectOutputStream)
|
||||
:void
|
||||
{
|
||||
var bytes :ByteArray = (obj as ByteArray);
|
||||
out.writeInt(bytes.length);
|
||||
out.writeBytes(bytes);
|
||||
}
|
||||
|
||||
public override function readObject (obj :*, ins :ObjectInputStream) :void
|
||||
public override function readObject (obj :Object, ins :ObjectInputStream)
|
||||
:void
|
||||
{
|
||||
var bytes :ByteArray = (obj as ByteArray);
|
||||
ins.readBytes(bytes, 0, bytes.length);
|
||||
|
||||
@@ -14,18 +14,20 @@ public class IntStreamer extends Streamer
|
||||
super(int, "java.lang.Integer");
|
||||
}
|
||||
|
||||
public override function createObject (ins :ObjectInputStream) :*
|
||||
public override function createObject (ins :ObjectInputStream) :Object
|
||||
{
|
||||
return ins.readInt();
|
||||
}
|
||||
|
||||
public override function writeObject (obj :*, out :ObjectOutputStream) :void
|
||||
public override function writeObject (obj :Object, out :ObjectOutputStream)
|
||||
:void
|
||||
{
|
||||
var i :int = (obj as int);
|
||||
out.writeInt(i);
|
||||
}
|
||||
|
||||
public override function readObject (obj :*, ins :ObjectInputStream) :void
|
||||
public override function readObject (obj :Object, ins :ObjectInputStream)
|
||||
:void
|
||||
{
|
||||
// nothing here, the int is fully read in createObject()
|
||||
}
|
||||
|
||||
@@ -14,18 +14,20 @@ public class NumberStreamer extends Streamer
|
||||
super(Number, "java.lang.Double");
|
||||
}
|
||||
|
||||
public override function createObject (ins :ObjectInputStream) :*
|
||||
public override function createObject (ins :ObjectInputStream) :Object
|
||||
{
|
||||
return ins.readDouble();
|
||||
}
|
||||
|
||||
public override function writeObject (obj :*, out :ObjectOutputStream) :void
|
||||
public override function writeObject (obj :Object, out :ObjectOutputStream)
|
||||
:void
|
||||
{
|
||||
var n :Number = (obj as Number);
|
||||
out.writeDouble(n);
|
||||
}
|
||||
|
||||
public override function readObject (obj :*, ins :ObjectInputStream) :void
|
||||
public override function readObject (obj :Object, ins :ObjectInputStream)
|
||||
:void
|
||||
{
|
||||
// nothing here, the Number is fully read in createObject()
|
||||
}
|
||||
|
||||
@@ -14,18 +14,20 @@ public class StringStreamer extends Streamer
|
||||
super(String, "java.lang.String");
|
||||
}
|
||||
|
||||
public override function createObject (ins :ObjectInputStream) :*
|
||||
public override function createObject (ins :ObjectInputStream) :Object
|
||||
{
|
||||
return ins.readUTF();
|
||||
}
|
||||
|
||||
public override function writeObject (obj :*, out :ObjectOutputStream) :void
|
||||
public override function writeObject (obj :Object, out :ObjectOutputStream)
|
||||
:void
|
||||
{
|
||||
var s :String = (obj as String);
|
||||
out.writeUTF(s);
|
||||
}
|
||||
|
||||
public override function readObject (obj :*, ins :ObjectInputStream) :void
|
||||
public override function readObject (obj :Object, ins :ObjectInputStream)
|
||||
:void
|
||||
{
|
||||
// nothing here, the String is fully read in createObject()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user