- Changed some stuff around with streaming.

- Before, the Input/OutputStream classes handled Streamables directly
    and Streamers were never created for them. Simplified the code somewhat
    by always creating a Streamer. It's now more like the Java side, too.
  - No more BAD_STREAMER, since null now means "bad".
- Built-in support for streaming enums.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5352 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Ray Greenwell
2008-09-04 01:27:18 +00:00
parent 85a5cc1de1
commit ec2b50c153
5 changed files with 128 additions and 91 deletions
+3 -11
View File
@@ -59,12 +59,11 @@ public class ObjectOutputStream
// create a class mapping if we've not got one
if (cmap == null) {
var streamer :Streamer = Streamer.getStreamer(obj);
// streamer may be null to indicate a Streamable object
if (streamer == Streamer.BAD_STREAMER) {
if (streamer == null) {
throw new Error("Unable to stream " + cname);
}
cmap = new ClassMapping(_nextCode++, cname, streamer);
cmap = new ClassMapping(_nextCode++, streamer);
_classMap.put(cname, cmap);
if (_nextCode > Short.MAX_VALUE) {
@@ -76,8 +75,7 @@ public class ObjectOutputStream
}
writeShort(-cmap.code);
writeUTF((streamer == null) ? Translations.getToServer(cname)
: streamer.getJavaClassName());
writeUTF(streamer.getJavaClassName());
} else {
writeShort(cmap.code);
@@ -94,12 +92,6 @@ public class ObjectOutputStream
public function writeBareObjectImpl (obj :Object, streamer :Streamer) :void
{
// if it's Streamable, it goes straight through
if (streamer == null) {
obj.writeObject(this); // obj is a Streamable
return;
}
// otherwise, stream it!
_current = obj;
_streamer = streamer;