It seems that Array streaming now works.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3924 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Ray Greenwell
2006-03-08 03:28:09 +00:00
parent 3163825b29
commit b82b079469
9 changed files with 202 additions and 114 deletions
@@ -0,0 +1,48 @@
package com.threerings.io.streamers {
import com.threerings.io.ObjectInputStream;
import com.threerings.io.ObjectOutputStream;
import com.threerings.io.Streamer;
import com.threerings.io.TypedArray;
/**
* A Streamer for Array objects.
*/
public class ObjectArrayStreamer extends Streamer
{
public function ObjectArrayStreamer ()
{
super(Array, "[Ljava.lang.Object;");
}
public override function isStreamerFor (obj :Object) :Boolean
{
// don't let TypedArrays be streamed with this streamer
return !(obj is TypedArray) && super.isStreamerFor(obj);
}
public override function createObject (ins :ObjectInputStream) :Object
{
return new Array(ins.readInt());
}
public override function writeObject (obj :Object, out :ObjectOutputStream)
:void
{
var arr :Array = (obj as Array);
out.writeInt(arr.length);
for (var ii :int = 0; ii < arr.length; ii++) {
out.writeObject(arr[ii]);
}
}
public override function readObject (obj :Object, ins :ObjectInputStream)
:void
{
var arr :Array = (obj as Array);
for (var ii :int = 0; ii < arr.length; ii++) {
arr[ii] = ins.readObject();
}
}
}
}