So, these classes like Integer and langBoolean exist solely for

streaming to our java server, so let's just make them streamable directly.
Does away with the need for custom Streamers.
Also made them Hashable, in case we read a StreamableHashMap containing
Integers as keys, for example.
Less code is better code.
(Why was BooleanStreamer added the other day? langBoolean was already Streamable
 and was already in Translations)


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5960 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Ray Greenwell
2009-09-17 21:42:25 +00:00
parent 055aac9b55
commit a24b0d2d03
14 changed files with 147 additions and 368 deletions
+25 -3
View File
@@ -21,11 +21,15 @@
package com.threerings.util {
import com.threerings.io.ObjectInputStream;
import com.threerings.io.ObjectOutputStream;
import com.threerings.io.Streamable;
/**
* Equivalent to java.lang.Short.
*/
public class Short
implements Equalable, Boxed
public final class Short
implements Hashable, Boxed, Streamable
{
/** The minimum possible short value. */
public static const MIN_VALUE :int = -Math.pow(2, 15);
@@ -46,7 +50,7 @@ public class Short
return _value;
}
public function Short (shortValue :int)
public function Short (shortValue :int = 0)
{
_value = shortValue;
}
@@ -57,12 +61,30 @@ public class Short
return (other is Short) && (_value === (other as Short).value);
}
// from Hashable
public function hashCode () :int
{
return _value;
}
// from Boxed
public function unbox () :Object
{
return _value;
}
// from Streamable
public function readObject (ins :ObjectInputStream) :void
{
_value = ins.readShort();
}
// from Streamable
public function writeObject (out :ObjectOutputStream) :void
{
out.writeShort(_value);
}
protected var _value :int;
}
}