Checkpoint.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3912 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Ray Greenwell
2006-03-04 02:43:14 +00:00
parent 15c258cdd4
commit a75f496e76
8 changed files with 216 additions and 11 deletions
+2 -4
View File
@@ -3,7 +3,6 @@ package com.threerings.io {
import flash.util.ByteArray;
public class ArrayMask
implements Streamable
{
public function ArrayMask (length :int = 0)
{
@@ -31,15 +30,14 @@ public class ArrayMask
return (_mask[index/8] & (1 << (index % 8))) != 0;
}
// documentation inherited from interface Streamable
public function writeObject (out :ObjectOutputStream) :void
public function writeTo (out :ObjectOutputStream) :void
{
out.writeShort(_mask.length);
out.writeBytes(_mask);
}
// documentation inherited from interface Streamable
public function readObject (ins :ObjectInputStream) :void
public function readFrom (ins :ObjectInputStream) :void
{
_mask.length = ins.readShort();
ins.readBytes(_mask, 0, _mask.length);
@@ -100,7 +100,7 @@ public class ObjectInputStream
readBareObjectImpl(obj, Streamer.getStreamer(obj));
}
internal function readBareObjectImpl (obj :Object, streamer :Streamer) :void
public function readBareObjectImpl (obj :Object, streamer :Streamer) :void
{
// streamable objects
if (streamer == null) {
@@ -74,7 +74,7 @@ public class ObjectOutputStream
writeBareObjectImpl(obj, Streamer.getStreamer(obj));
}
protected function writeBareObjectImpl (obj :Object, streamer :Streamer)
public function writeBareObjectImpl (obj :Object, streamer :Streamer)
{
// if it's Streamable, it goes straight through
if (streamer == null) {
+4
View File
@@ -1,5 +1,9 @@
package com.threerings.io {
/**
* Note: all Streamable instances should have a constructor that copes
* with no arguments.
*/
public interface Streamable
{
function writeObject (out :ObjectOutputStream) :void;
+9 -5
View File
@@ -36,7 +36,7 @@ public class Streamer
initStreamers();
for each (var streamer :Streamer in _streamers) {
if (streamer._targ == clazz) {
if (streamer._target == clazz) {
return streamer;
}
}
@@ -61,13 +61,13 @@ public class Streamer
public function Streamer (targ :Class, jname :String)
//throws IOError
{
_targ = targ;
_target = targ;
_jname = jname;
}
public function isStreamerFor (obj :Object) :Boolean
{
return (obj is _targ); // scripting langs are weird
return (obj is _target); // scripting langs are weird
}
/**
@@ -97,7 +97,7 @@ public class Streamer
//throws IOError
{
// actionscript is so fucked up
return new _targ();
return new _target();
}
public function readObject (obj :Object, ins :ObjectInputStream) :void
@@ -124,10 +124,14 @@ public class Streamer
}
}
protected var _targ :Class;
protected var _target :Class;
protected var _jname :String;
/** If our target class is an array, this is a reference to a streamer
* that can stream our array elements, otherwise it is null. */
protected var _delegate :Streamer;
/** Just a list of our standard streamers. */
protected static var _streamers :Array;
}