Streaming fixups on the path towards getting things working in beta3.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4105 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Ray Greenwell
2006-05-10 00:40:15 +00:00
parent e100ef4faf
commit b82108ecea
5 changed files with 50 additions and 40 deletions
@@ -183,9 +183,9 @@ public class PlaceObject extends DObject
public override function writeObject (out :ObjectOutputStream) :void
{
super.writeObject(out);
out.writeField(occupants);
out.writeField(occupantInfo);
out.writeField(speakService);
out.writeObject(occupants);
out.writeObject(occupantInfo);
out.writeObject(speakService);
}
// documentation inherited
@@ -193,9 +193,9 @@ public class PlaceObject extends DObject
{
super.readObject(ins);
// TODO: this needs fixing!
occupants = (ins.readField(OidList) as OidList);
occupantInfo = (ins.readField(DSet) as DSet);
speakService = (ins.readField(SpeakMarshaller) as SpeakMarshaller);
occupants = (ins.readObject() as OidList);
occupantInfo = (ins.readObject() as DSet);
speakService = (ins.readObject() as SpeakMarshaller);
}
}
}
@@ -56,11 +56,11 @@ public class ObjectInputStream
Log.warning("OMG, cannot stream " + cname);
return null;
}
Log.debug("Got streamer (" + streamer + ")");
// Log.debug("Got streamer (" + streamer + ")");
cmap = new ClassMapping(code, cname, streamer);
_classMap[code] = cmap;
Log.debug("Created mapping for (" + code + "): " + cname);
// Log.debug("Created mapping for (" + code + "): " + cname);
} else {
Log.debug("Read known code: " + code);
+10 -7
View File
@@ -70,7 +70,7 @@ public class Streamer
initStreamers();
// see if we have a streamer for it
Log.debug("getStreamer/existing");
// Log.debug("getStreamer/existing");
for each (var streamer :Streamer in _streamers) {
if (streamer.getJavaClassName() === jname) {
return streamer;
@@ -78,7 +78,7 @@ public class Streamer
}
// see if it's an array that we unstream using an ArrayStreamer
Log.debug("getStreamer/array");
// Log.debug("getStreamer/array");
if (jname.charAt(0) === "[") {
var streamer :Streamer = new ArrayStreamer(jname);
_streamers.push(streamer);
@@ -86,18 +86,21 @@ public class Streamer
}
// otherwise see if it represents a Streamable
Log.debug("getStreamer/Class:Streamable");
// Log.debug("getStreamer/Class:Streamable");
var clazz :Class = ClassUtil.getClassByName(
Translations.getFromServer(jname));
Log.debug("getStreamer/Class:Streamable2");
// Log.debug("getStreamer/Class:Streamable2");
if (ClassUtil.isAssignableAs(Streamable, clazz)) {
return null; // it's streamable
}
// TEMP: workaround for fucked-up bug!!! FUCK ACTIONSCRIPT!
if (clazz == StreamableArrayList) {
return null; // it's streamable, yes it is
// TEMP: workaround for fucked-up bug!!!
// The isAssignableAs (above) does not work right now, so we assume
// ALL classes are streamable, to get things working.
if (true) {
return null;
}
// END: hacky temp
return BAD_STREAMER;
}
@@ -18,24 +18,27 @@ public class ArrayStreamer extends Streamer
{
super(TypedArray, jname);
if (jname.charAt(1) === "[") {
var secondChar :String = jname.charAt(1);
if (secondChar === "[") {
// if we're a multi-dimensional array then we need a delegate
_delegate = Streamer.getStreamerByJavaName(jname.substring(1));
_isFinal = true; // it just is
} else {
if (jname.charAt(1) === "L") {
// form is "[L<class>;"
var baseClass :String = jname.substring(2, jname.length - 1);
baseClass = Translations.getFromServer(baseClass);
_elementType = ClassUtil.getClassByName(baseClass);
_isFinal = ClassUtil.isFinal(_elementType);
} else if (secondChar === "L") {
// form is "[L<class>;"
var baseClass :String = jname.substring(2, jname.length - 1);
baseClass = Translations.getFromServer(baseClass);
_elementType = ClassUtil.getClassByName(baseClass);
_isFinal = ClassUtil.isFinal(_elementType);
} else {
com.threerings.presents.Log.warning("Other array types are currently not handled yet " +
"[jname=" + jname + "].");
throw new Error("Unimplemented bit");
}
} else if (secondChar === "I") {
_elementType = int;
} else {
com.threerings.presents.Log.warning("Other array types are " +
"currently not handled yet [jname=" + jname + "].");
throw new Error("Unimplemented bit");
}
}
@@ -57,7 +60,12 @@ public class ArrayStreamer extends Streamer
{
var arr :Array = (obj as Array);
out.writeInt(arr.length);
if (_isFinal) {
if (_elementType == int) {
for (var ii :int = 0; ii < arr.length; ii++) {
out.writeInt(arr[ii] as int);
}
} else if (_isFinal) {
var mask :ArrayMask = new ArrayMask(arr.length);
for (var ii :int = 0; ii < arr.length; ii++) {
if (arr[ii] != null) {
@@ -84,7 +92,12 @@ public class ArrayStreamer extends Streamer
:void
{
var arr :Array = (obj as Array);
if (_isFinal) {
if (_elementType == int) {
for (var ii :int = 0; ii < arr.length; ii++) {
arr[ii] = ins.readInt();
}
} else if (_isFinal) {
var mask :ArrayMask = new ArrayMask();
mask.readFrom(ins);
for (var ii :int = 0; ii < length; ii++) {
+4 -10
View File
@@ -4,6 +4,7 @@ import com.threerings.io.Streamable;
import com.threerings.io.ObjectInputStream;
import com.threerings.io.ObjectOutputStream;
import com.threerings.io.TypedArray;
import com.threerings.util.StringBuilder;
@@ -23,7 +24,7 @@ public class OidList
*/
public function OidList ()
{
_oids = new Array();
_oids = new TypedArray("[I");
}
/**
@@ -107,16 +108,9 @@ public class OidList
// documentation inherited from interface Streamable
public function readObject (ins :ObjectInputStream) :void
{
// TODO: this is some custom shit. We need to work out array streaming
_oids = new Array();
var ecount :int = ins.readInt();
for (var ii :int = 0; ii < ecount; ii++) {
_oids.push(ins.readInt());
}
_oids.length = ins.readInt(); // then, limit the length to the size
_oids = (ins.readField("[I") as TypedArray);
}
public function toString () :String
{
var buf :StringBuilder = new StringBuilder();
@@ -126,6 +120,6 @@ public class OidList
return buf.toString();
}
private var _oids :Array;
private var _oids :TypedArray;
}
}