The readField()/writeField() methods are for marshalling objects that have

basic streamers defined for them (String, Integer, Boolean) and not
other arbitrary objects.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3863 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Ray Greenwell
2006-02-19 03:19:54 +00:00
parent 97953e7668
commit bb379347f0
13 changed files with 21 additions and 41 deletions
@@ -103,9 +103,8 @@ public class ObjectInputStream
} }
} }
// TODO: of course this DOESN'T ACTUALLY WORK, because the actual object // TODO: this is the equivalent of marshalling something for which
// to read could be a subclass of the specified class // we have a basic streamer. Fill out with all the java types
// TODO
public function readField (clazz :Class) :* public function readField (clazz :Class) :*
//throws IOError //throws IOError
{ {
@@ -76,6 +76,8 @@ 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 :*) :void
//throws IOError //throws IOError
{ {
@@ -158,13 +158,13 @@ public class CompoundEvent extends DEvent
public override function writeObject (out :ObjectOutputStream) :void public override function writeObject (out :ObjectOutputStream) :void
{ {
super.writeObject(out); super.writeObject(out);
out.writeField(_events); out.writeObject(_events);
} }
public override function readObject (ins :ObjectInputStream) :void public override function readObject (ins :ObjectInputStream) :void
{ {
super.readObject(ins); super.readObject(ins);
_events = ins.readField(StreamableArrayList); _events = ins.readObject();
} }
/** The object manager that we'll post ourselves to when we're /** The object manager that we'll post ourselves to when we're
@@ -81,7 +81,7 @@ public class ElementUpdatedEvent extends NamedEvent
public override function writeObject (out :ObjectOutputStream) :void public override function writeObject (out :ObjectOutputStream) :void
{ {
super.writeObject(out); super.writeObject(out);
out.writeField(_value); out.writeObject(_value);
out.writeInt(_index); out.writeInt(_index);
} }
@@ -89,7 +89,7 @@ public class ElementUpdatedEvent extends NamedEvent
public override function readObject (ins :ObjectInputStream) :void public override function readObject (ins :ObjectInputStream) :void
{ {
super.readObject(ins); super.readObject(ins);
_value = ins.readField(Object); _value = ins.readObjct();
_index = ins.readInt(); _index = ins.readInt();
} }
@@ -71,13 +71,13 @@ public class EntryAddedEvent extends NamedEvent
public override function writeObject (out :ObjectOutputStream) :void public override function writeObject (out :ObjectOutputStream) :void
{ {
super.writeObject(out); super.writeObject(out);
out.writeField(_entry); out.writeObject(_entry);
} }
public override function readObject (ins :ObjectInputStream) :void public override function readObject (ins :ObjectInputStream) :void
{ {
super.readObject(ins); super.readObject(ins);
_entry = ins.readField(DSetEntry); _entry = ins.readObject();
} }
protected var _entry :DSetEntry; protected var _entry :DSetEntry;
@@ -90,13 +90,13 @@ public class EntryRemovedEvent extends NamedEvent
public override function writeObject (out :ObjectOutputStream) :void public override function writeObject (out :ObjectOutputStream) :void
{ {
super.writeObject(out); super.writeObject(out);
out.writeField(_key); out.writeObject(_key);
} }
public override function readObject (ins :ObjectInputStream) :void public override function readObject (ins :ObjectInputStream) :void
{ {
super.readObject(ins); super.readObject(ins);
_key = ins.readField(Comparable); _key = ins.readObject();
} }
protected var _key :Comparable; protected var _key :Comparable;
@@ -89,13 +89,13 @@ public class EntryUpdatedEvent extends NamedEvent
public override function writeObject (out :ObjectOutputStream) :void public override function writeObject (out :ObjectOutputStream) :void
{ {
super.writeObject(out); super.writeObject(out);
out.writeField(_entry); out.writeObject(_entry);
} }
public override function readObject (ins :ObjectInputStream) :void public override function readObject (ins :ObjectInputStream) :void
{ {
super.readObject(ins); super.readObject(ins);
_entry = ins.readField(DSetEntry); _entry = ins.readObject();
} }
protected var _entry :DSetEntry; protected var _entry :DSetEntry;
@@ -22,7 +22,7 @@ public class AuthRequest extends UpstreamMessage
{ {
super.writeObject(out); super.writeObject(out);
out.writeField(_creds); out.writeObject(_creds);
out.writeField(_version); out.writeField(_version);
} }
@@ -30,7 +30,7 @@ public class AuthRequest extends UpstreamMessage
public function readObject (ins :ObjectInputStream) :void public function readObject (ins :ObjectInputStream) :void
{ {
super.readObject(ins); super.readObject(ins);
_creds = ins.readField(Credentials); _creds = ins.readObject();
_version = ins.readField(String); _version = ins.readField(String);
} }
@@ -13,7 +13,7 @@ public class AuthResponse extends DownstreamMessage
public function readObject (ins :ObjectInputStream) :void public function readObject (ins :ObjectInputStream) :void
{ {
super.readObject(ins); super.readObject(ins);
_data = ins.readField(AuthResponseData); _data = ins.readObject();
} }
protected var _data :AuthResponseData; protected var _data :AuthResponseData;
@@ -32,7 +32,7 @@ public class BootstrapData
public function readObject (ins :ObjectInputStream) :void public function readObject (ins :ObjectInputStream) :void
{ {
clientOid = ins.readInt(); clientOid = ins.readInt();
services = ins.readField(StreamableArrayList); services = ins.readObject();
} }
} }
} }
@@ -12,7 +12,7 @@ public class BootstrapNotification extends DownstreamMessage
public function readObject (ins :ObjectInputStream) :void public function readObject (ins :ObjectInputStream) :void
{ {
super.readObject(ins); super.readObject(ins);
_data = ins.readField(BootstrapData); _data = ins.readObject();
} }
/** The data associated with this notification. */ /** The data associated with this notification. */
@@ -47,13 +47,13 @@ public class ForwardEventRequest extends UpstreamMessage
public override function writeObject (out :ObjectOutputStream) :void public override function writeObject (out :ObjectOutputStream) :void
{ {
super.writeObject(out); super.writeObject(out);
out.writeField(_event); out.writeObject(_event);
} }
public override function readObject (ins :ObjectInputStream) :void public override function readObject (ins :ObjectInputStream) :void
{ {
super.readObject(ins); super.readObject(ins);
_event = ins.readField(DEvent); _event = ins.readObject();
} }
public override function toString () :String public override function toString () :String
-21
View File
@@ -49,35 +49,14 @@ public class Name extends Object
public function writeObject (out :ObjectOutputStream) :void public function writeObject (out :ObjectOutputStream) :void
//throws IOError //throws IOError
{ {
/*
// TODO: oh shit, this is wrong. We need to write a boolean out
// indicating whether the object that follows is null or not
out.writeBareObject(_name);
*/
out.writeField(_name); out.writeField(_name);
// we need a way of doing the following automatically:
/*
var b :Boolean = (_name != null);
out.writeBoolean(b);
if (b) {
out.writeUTF(_name);
}
*/
} }
// documentation inherited from interface Streamable // documentation inherited from interface Streamable
public function readObject (ins :ObjectInputStream) :void public function readObject (ins :ObjectInputStream) :void
//throws IOError //throws IOError
{ {
// TODO: oh shit, this is wrong
_name = ins.readField(String); _name = ins.readField(String);
/*
var b :Boolean = in.readBoolean();
_name = b ? in.readUTF() : null;
*/
} }
protected function normalize (txt :String) :String protected function normalize (txt :String) :String