Mark StreamableArrayList and StreamableHashMap as replaced by their basic Java counterparts. Basic
Map and List types are streamed as fields, which are smaller on the wire. I'd deprecate them, but yohoho uses them all over the place. Handle generating code for StreamableArrayList and StreamableHashMap in actionscript for existing code. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@6215 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
//
|
||||
// Narya library - tools for developing networked games
|
||||
// Copyright (C) 2002-2010 Three Rings Design, Inc., All Rights Reserved
|
||||
// http://www.threerings.net/code/narya/
|
||||
// http://code.google.com/p/narya/
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License as published
|
||||
@@ -30,8 +30,10 @@ import com.threerings.util.Long;
|
||||
import com.threerings.io.TypedArray;
|
||||
import flash.utils.ByteArray;
|
||||
import com.threerings.io.streamers.ArrayStreamer;
|
||||
import com.threerings.util.StreamableArrayList;
|
||||
import com.threerings.util.Map;
|
||||
import com.threerings.io.streamers.MapStreamer;
|
||||
import com.threerings.util.StreamableHashMap;
|
||||
// GENERATED PREAMBLE END
|
||||
|
||||
import com.threerings.util.Integer;
|
||||
@@ -41,8 +43,6 @@ import com.threerings.util.Util;
|
||||
// GENERATED CLASSDECL START
|
||||
public class ASStreamableSubset extends SimpleStreamableObject
|
||||
{
|
||||
public function ASStreamableSubset ()
|
||||
{}
|
||||
// GENERATED CLASSDECL END
|
||||
|
||||
public static function createWithJavaDefaults () :ASStreamableSubset
|
||||
@@ -85,12 +85,16 @@ public class ASStreamableSubset extends SimpleStreamableObject
|
||||
return bool1 === o.bool1 && short2 === o.short2 && int3 === o.int3 && long4.equals(o.long4) &&
|
||||
float5 === o.float5 && double6 === o.double6 && char7 === o.char7 &&
|
||||
byte8 === o.byte8 && string1 === o.string1 && nullString1 === o.nullString1 &&
|
||||
|
||||
Util.equals(bools, o.bools) && Util.equals(bytes, o.bytes) &&
|
||||
Util.equals(ints, o.ints) && Util.equals(nullBools, o.nullBools) &&
|
||||
Util.equals(nullBytes, o.nullBytes) && Util.equals(nullInts, o.nullInts) &&
|
||||
|
||||
Util.equals(strings, o.strings) && Util.equals(nullStrings, o.nullStrings) &&
|
||||
Util.equals(sal, o.sal) &&
|
||||
|
||||
Maps.equals(stringMap, o.stringMap) && Maps.equals(stringIntMap, o.stringIntMap)
|
||||
Maps.equals(nullStringMap, o.nullStringMap);
|
||||
Maps.equals(nullStringMap, o.nullStringMap) && Maps.equals(shm, o.shm);
|
||||
|
||||
}
|
||||
|
||||
@@ -113,9 +117,11 @@ public class ASStreamableSubset extends SimpleStreamableObject
|
||||
public var nullInts :TypedArray;
|
||||
public var strings :TypedArray;
|
||||
public var nullStrings :TypedArray;
|
||||
public var sal :StreamableArrayList;
|
||||
public var stringMap :Map;
|
||||
public var stringIntMap :Map;
|
||||
public var nullStringMap :Map;
|
||||
public var shm :StreamableHashMap;
|
||||
|
||||
override public function readObject (ins :ObjectInputStream) :void
|
||||
{
|
||||
@@ -138,9 +144,11 @@ public class ASStreamableSubset extends SimpleStreamableObject
|
||||
nullInts = ins.readField(TypedArray.getJavaType(int));
|
||||
strings = ins.readField(ArrayStreamer.INSTANCE);
|
||||
nullStrings = ins.readField(ArrayStreamer.INSTANCE);
|
||||
sal = ins.readObject(StreamableArrayList);
|
||||
stringMap = ins.readField(MapStreamer.INSTANCE);
|
||||
stringIntMap = ins.readField(MapStreamer.INSTANCE);
|
||||
nullStringMap = ins.readField(MapStreamer.INSTANCE);
|
||||
shm = ins.readObject(StreamableHashMap);
|
||||
}
|
||||
|
||||
override public function writeObject (out :ObjectOutputStream) :void
|
||||
@@ -164,9 +172,11 @@ public class ASStreamableSubset extends SimpleStreamableObject
|
||||
out.writeField(nullInts);
|
||||
out.writeField(strings, ArrayStreamer.INSTANCE);
|
||||
out.writeField(nullStrings, ArrayStreamer.INSTANCE);
|
||||
out.writeObject(sal);
|
||||
out.writeField(stringMap, MapStreamer.INSTANCE);
|
||||
out.writeField(stringIntMap, MapStreamer.INSTANCE);
|
||||
out.writeField(nullStringMap, MapStreamer.INSTANCE);
|
||||
out.writeObject(shm);
|
||||
}
|
||||
// GENERATED STREAMING END
|
||||
|
||||
|
||||
@@ -56,9 +56,9 @@ public class StreamableTest extends TestCase
|
||||
"01000200000003000000000000000440a0000040180000000000000007080100036f6e6500010000" +
|
||||
"0003010001010000000301020301000000030000000100000002000000030000000100000003fffe" +
|
||||
"00106a6176612e6c616e672e537472696e6700036f6e650002000374776f00020005746872656500" +
|
||||
"01000000030002000374776f0002000132000200036f6e6500020001310002000574687265650002" +
|
||||
"00013301000000030002000374776ffffd00116a6176612e6c616e672e496e746567657200000002" +
|
||||
"000200036f6e6500030000000100020005746872656500030000000300");
|
||||
"000001000000030002000374776f0002000132000200036f6e650002000131000200057468726565" +
|
||||
"000200013301000000030002000374776ffffd00116a6176612e6c616e672e496e74656765720000" +
|
||||
"0002000200036f6e65000300000001000200057468726565000300000003000000");
|
||||
var input:ObjectInputStream = new ObjectInputStream(javaData);
|
||||
var read :ASStreamableSubset = input.readObject(ASStreamableSubset);
|
||||
assertTrue(sub.equals(read));
|
||||
|
||||
Reference in New Issue
Block a user