Make writing List fields on Streamables possible from ActionScript again, and fix List reading and

writing in the code generated by GenActionScriptStreamableTask.



git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@6199 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Charlie Groves
2010-10-15 07:53:38 +00:00
parent 377fafae1e
commit aad715138c
10 changed files with 87 additions and 37 deletions
+15 -9
View File
@@ -34,7 +34,7 @@ import com.threerings.util.Long;
public class ObjectInputStream
{
/** Enables verbose object I/O debugging. */
public static const DEBUG :Boolean = false;
public static const DEBUG :Boolean = true;
public function ObjectInputStream (source :IDataInput = null, clientProps :Object = null)
{
@@ -172,7 +172,8 @@ public class ObjectInputStream
* Called to read an Object of a known final type into a Streamable object.
*
* @param type either a String representing the java type,
* or a Class object representing the actionscript type.
* a Class representing the actionscript type,
* or the Streamer to be used to read the field.
*/
public function readField (type :Object) :*
//throws IOError
@@ -181,13 +182,18 @@ public class ObjectInputStream
return null;
}
var jname :String = type as String;
if (type is Class) {
jname = Translations.getToServer(ClassUtil.getClassName(type));
}
var streamer :Streamer = Streamer.getStreamerByJavaName(jname);
if (streamer == null) {
throw new Error("Cannot field stream " + type);
var streamer :Streamer;
if (type is Streamer) {
streamer = Streamer(type);
} else {
var jname :String = type as String;
if (type is Class) {
jname = Translations.getToServer(ClassUtil.getClassName(type));
}
streamer= Streamer.getStreamerByJavaName(jname);
if (streamer == null) {
throw new Error("Cannot field stream " + type);
}
}
var obj :Object = streamer.createObject(this);
@@ -86,10 +86,13 @@ public class ObjectOutputStream
writeBareObjectImpl(obj, cmap.streamer);
}
public function writeBareObject (obj :Object) :void
public function writeBareObject (obj :Object, streamer :Streamer = null) :void
//throws IOError
{
writeBareObjectImpl(obj, Streamer.getStreamer(obj));
if (streamer == null) {
streamer = Streamer.getStreamer(obj);
}
writeBareObjectImpl(obj, streamer);
}
public function writeBareObjectImpl (obj :Object, streamer :Streamer) :void
@@ -125,13 +128,13 @@ public class ObjectOutputStream
* }
* </listing>
*/
public function writeField (val :Object) :void
public function writeField (val :Object, streamer :Streamer = null) :void
//throws IOError
{
var b :Boolean = (val != null);
writeBoolean(b);
if (b) {
writeBareObject(val);
writeBareObject(val, streamer);
}
}
@@ -217,7 +220,7 @@ public class ObjectOutputStream
/** The target DataOutput that we route things to. */
protected var _targ :IDataOutput;
/** A counter used to assign codes to streamed classes. */
protected var _nextCode :int = 1;