From a24b0d2d033e5b38ca11bc4c97cfd360da8d6f23 Mon Sep 17 00:00:00 2001 From: Ray Greenwell Date: Thu, 17 Sep 2009 21:42:25 +0000 Subject: [PATCH] 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 --- src/as/com/threerings/io/Streamer.as | 8 +-- src/as/com/threerings/io/Translations.as | 5 +- .../io/streamers/BooleanStreamer.as | 55 ------------------ .../threerings/io/streamers/ByteStreamer.as | 56 ------------------- .../threerings/io/streamers/FloatStreamer.as | 56 ------------------- .../io/streamers/IntegerStreamer.as | 56 ------------------- .../threerings/io/streamers/LongStreamer.as | 52 ----------------- .../threerings/io/streamers/ShortStreamer.as | 56 ------------------- src/as/com/threerings/util/Byte.as | 26 ++++++++- src/as/com/threerings/util/Float.as | 28 +++++++++- src/as/com/threerings/util/Integer.as | 29 ++++++++-- src/as/com/threerings/util/Long.as | 50 ++++++++++++----- src/as/com/threerings/util/Short.as | 28 +++++++++- src/as/com/threerings/util/langBoolean.as | 10 +++- 14 files changed, 147 insertions(+), 368 deletions(-) delete mode 100644 src/as/com/threerings/io/streamers/BooleanStreamer.as delete mode 100644 src/as/com/threerings/io/streamers/ByteStreamer.as delete mode 100644 src/as/com/threerings/io/streamers/FloatStreamer.as delete mode 100644 src/as/com/threerings/io/streamers/IntegerStreamer.as delete mode 100644 src/as/com/threerings/io/streamers/LongStreamer.as delete mode 100644 src/as/com/threerings/io/streamers/ShortStreamer.as diff --git a/src/as/com/threerings/io/Streamer.as b/src/as/com/threerings/io/Streamer.as index b25dc5864..6723d94b5 100644 --- a/src/as/com/threerings/io/Streamer.as +++ b/src/as/com/threerings/io/Streamer.as @@ -29,14 +29,9 @@ import com.threerings.util.ClassUtil; import com.threerings.util.Enum; import com.threerings.io.streamers.ArrayStreamer; -import com.threerings.io.streamers.BooleanStreamer; -import com.threerings.io.streamers.ByteStreamer; import com.threerings.io.streamers.ByteArrayStreamer; import com.threerings.io.streamers.ByteEnumStreamer; import com.threerings.io.streamers.EnumStreamer; -import com.threerings.io.streamers.FloatStreamer; -import com.threerings.io.streamers.IntegerStreamer; -import com.threerings.io.streamers.LongStreamer; import com.threerings.io.streamers.NumberStreamer; import com.threerings.io.streamers.StringStreamer; @@ -147,8 +142,7 @@ public class Streamer } _byJName = new Dictionary(); for each (var c :Class in - [ StringStreamer, NumberStreamer, ByteStreamer, IntegerStreamer, LongStreamer, - FloatStreamer, ArrayStreamer, ByteArrayStreamer, BooleanStreamer ]) { + [ StringStreamer, NumberStreamer, ArrayStreamer, ByteArrayStreamer ]) { registerStreamer(Streamer(new c())); } } diff --git a/src/as/com/threerings/io/Translations.as b/src/as/com/threerings/io/Translations.as index 01cda1c75..7be8b00b8 100644 --- a/src/as/com/threerings/io/Translations.as +++ b/src/as/com/threerings/io/Translations.as @@ -56,12 +56,13 @@ public class Translations // initialize some standard classes addTranslation("Object", "java.lang.Object"); addTranslation("String", "java.lang.String"); + addTranslation("Array", "[Ljava.lang.Object;"); + addTranslation("flash.utils.ByteArray", "[B"); addTranslation("com.threerings.util.langBoolean", "java.lang.Boolean"); addTranslation("com.threerings.util.Byte", "java.lang.Byte"); + addTranslation("com.threerings.util.Short", "java.lang.Short"); addTranslation("com.threerings.util.Integer", "java.lang.Integer"); addTranslation("com.threerings.util.Long", "java.lang.Long"); addTranslation("com.threerings.util.Float", "java.lang.Float"); - addTranslation("Array", "[Ljava.lang.Object;"); - addTranslation("flash.utils.ByteArray", "[B"); } } diff --git a/src/as/com/threerings/io/streamers/BooleanStreamer.as b/src/as/com/threerings/io/streamers/BooleanStreamer.as deleted file mode 100644 index c5ca1e021..000000000 --- a/src/as/com/threerings/io/streamers/BooleanStreamer.as +++ /dev/null @@ -1,55 +0,0 @@ -// -// $Id$ -// -// Narya library - tools for developing networked games -// Copyright (C) 2002-2009 Three Rings Design, Inc., All Rights Reserved -// http://www.threerings.net/code/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 -// by the Free Software Foundation; either version 2.1 of the License, or -// (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -package com.threerings.io.streamers { - -import com.threerings.util.langBoolean; - -import com.threerings.io.ObjectInputStream; -import com.threerings.io.ObjectOutputStream; -import com.threerings.io.Streamer; - -/** - * A Streamer for Integer objects. - */ -public class BooleanStreamer extends Streamer -{ - public function BooleanStreamer () - { - super(langBoolean, "java.lang.Boolean"); - } - - override public function createObject (ins :ObjectInputStream) :Object - { - return new langBoolean(ins.readBoolean()); - } - - override public function writeObject (obj :Object, out :ObjectOutputStream) :void - { - out.writeBoolean((obj as langBoolean).value); - } - - override public function readObject (obj :Object, ins :ObjectInputStream) :void - { - // unneeded, done in createObject - } -} -} diff --git a/src/as/com/threerings/io/streamers/ByteStreamer.as b/src/as/com/threerings/io/streamers/ByteStreamer.as deleted file mode 100644 index 0bfad2542..000000000 --- a/src/as/com/threerings/io/streamers/ByteStreamer.as +++ /dev/null @@ -1,56 +0,0 @@ -// -// $Id$ -// -// Narya library - tools for developing networked games -// Copyright (C) 2002-2009 Three Rings Design, Inc., All Rights Reserved -// http://www.threerings.net/code/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 -// by the Free Software Foundation; either version 2.1 of the License, or -// (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -package com.threerings.io.streamers { - -import com.threerings.util.Byte; - -import com.threerings.io.ObjectInputStream; -import com.threerings.io.ObjectOutputStream; -import com.threerings.io.Streamer; - -/** - * A Streamer for Byte objects. - */ -public class ByteStreamer extends Streamer -{ - public function ByteStreamer () - { - super(Byte, "java.lang.Byte"); - } - - override public function createObject (ins :ObjectInputStream) :Object - { - return new Byte(ins.readByte()); - } - - override public function writeObject (obj :Object, out :ObjectOutputStream) :void - { - var byte :Byte = (obj as Byte); - out.writeByte(byte.value); - } - - override public function readObject (obj :Object, ins :ObjectInputStream) :void - { - // unneeded, done in createObject - } -} -} diff --git a/src/as/com/threerings/io/streamers/FloatStreamer.as b/src/as/com/threerings/io/streamers/FloatStreamer.as deleted file mode 100644 index 0cfd2d468..000000000 --- a/src/as/com/threerings/io/streamers/FloatStreamer.as +++ /dev/null @@ -1,56 +0,0 @@ -// -// $Id$ -// -// Narya library - tools for developing networked games -// Copyright (C) 2002-2009 Three Rings Design, Inc., All Rights Reserved -// http://www.threerings.net/code/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 -// by the Free Software Foundation; either version 2.1 of the License, or -// (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -package com.threerings.io.streamers { - -import com.threerings.util.Float; - -import com.threerings.io.ObjectInputStream; -import com.threerings.io.ObjectOutputStream; -import com.threerings.io.Streamer; - -/** - * A Streamer for Float objects. - */ -public class FloatStreamer extends Streamer -{ - public function FloatStreamer () - { - super(Float, "java.lang.Float"); - } - - override public function createObject (ins :ObjectInputStream) :Object - { - return new Float(ins.readFloat()); - } - - override public function writeObject (obj :Object, out :ObjectOutputStream) :void - { - var float :Float = (obj as Float); - out.writeFloat(float.value); - } - - override public function readObject (obj :Object, ins :ObjectInputStream) :void - { - // unneeded, done in createObject - } -} -} diff --git a/src/as/com/threerings/io/streamers/IntegerStreamer.as b/src/as/com/threerings/io/streamers/IntegerStreamer.as deleted file mode 100644 index 507811cd9..000000000 --- a/src/as/com/threerings/io/streamers/IntegerStreamer.as +++ /dev/null @@ -1,56 +0,0 @@ -// -// $Id$ -// -// Narya library - tools for developing networked games -// Copyright (C) 2002-2009 Three Rings Design, Inc., All Rights Reserved -// http://www.threerings.net/code/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 -// by the Free Software Foundation; either version 2.1 of the License, or -// (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -package com.threerings.io.streamers { - -import com.threerings.util.Integer; - -import com.threerings.io.ObjectInputStream; -import com.threerings.io.ObjectOutputStream; -import com.threerings.io.Streamer; - -/** - * A Streamer for Integer objects. - */ -public class IntegerStreamer extends Streamer -{ - public function IntegerStreamer () - { - super(Integer, "java.lang.Integer"); - } - - override public function createObject (ins :ObjectInputStream) :Object - { - return new Integer(ins.readInt()); - } - - override public function writeObject (obj :Object, out :ObjectOutputStream) :void - { - var inty :Integer = (obj as Integer); - out.writeInt(inty.value); - } - - override public function readObject (obj :Object, ins :ObjectInputStream) :void - { - // unneeded, done in createObject - } -} -} diff --git a/src/as/com/threerings/io/streamers/LongStreamer.as b/src/as/com/threerings/io/streamers/LongStreamer.as deleted file mode 100644 index afe6ed839..000000000 --- a/src/as/com/threerings/io/streamers/LongStreamer.as +++ /dev/null @@ -1,52 +0,0 @@ -// -// $Id$ -// -// Narya library - tools for developing networked games -// Copyright (C) 2002-2009 Three Rings Design, Inc., All Rights Reserved -// http://www.threerings.net/code/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 -// by the Free Software Foundation; either version 2.1 of the License, or -// (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -package com.threerings.io.streamers { - -import com.threerings.util.Long; - -import com.threerings.io.ObjectInputStream; -import com.threerings.io.ObjectOutputStream; -import com.threerings.io.Streamer; - -/** - * A Streamer for Long objects. - */ -public class LongStreamer extends Streamer -{ - public function LongStreamer () - { - super(Long, "java.lang.Long"); - } - - override public function writeObject (obj :Object, out :ObjectOutputStream) :void - { - var longy :Long = (obj as Long); - out.writeBytes(longy.bytes, 0, longy.bytes.length); - } - - override public function readObject (obj :Object, ins :ObjectInputStream) :void - { - var longy :Long = (obj as Long); - ins.readBytes(longy.bytes, 0, longy.bytes.length); - } -} -} diff --git a/src/as/com/threerings/io/streamers/ShortStreamer.as b/src/as/com/threerings/io/streamers/ShortStreamer.as deleted file mode 100644 index 37e63fc75..000000000 --- a/src/as/com/threerings/io/streamers/ShortStreamer.as +++ /dev/null @@ -1,56 +0,0 @@ -// -// $Id$ -// -// Narya library - tools for developing networked games -// Copyright (C) 2002-2009 Three Rings Design, Inc., All Rights Reserved -// http://www.threerings.net/code/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 -// by the Free Software Foundation; either version 2.1 of the License, or -// (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -package com.threerings.io.streamers { - -import com.threerings.util.Short; - -import com.threerings.io.ObjectInputStream; -import com.threerings.io.ObjectOutputStream; -import com.threerings.io.Streamer; - -/** - * A Streamer for Short objects. - */ -public class ShortStreamer extends Streamer -{ - public function ShortStreamer () - { - super(Short, "java.lang.Short"); - } - - override public function createObject (ins :ObjectInputStream) :Object - { - return new Short(ins.readShort()); - } - - override public function writeObject (obj :Object, out :ObjectOutputStream) :void - { - var short :Short = (obj as Short); - out.writeShort(short.value); - } - - override public function readObject (obj :Object, ins :ObjectInputStream) :void - { - // unneeded, done in createObject - } -} -} diff --git a/src/as/com/threerings/util/Byte.as b/src/as/com/threerings/util/Byte.as index adf399a6c..50c12ab3d 100644 --- a/src/as/com/threerings/util/Byte.as +++ b/src/as/com/threerings/util/Byte.as @@ -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.Byte. */ public class Byte - implements Equalable, Boxed + implements Hashable, Boxed, Streamable { public static function valueOf (val :int) :Byte { @@ -43,7 +47,7 @@ public class Byte /** * Constructor. */ - public function Byte (byteValue :int) + public function Byte (byteValue :int = 0) { _value = byteValue; } @@ -54,6 +58,12 @@ public class Byte return (other is Byte) && (_value === (other as Byte).value); } + // from Hashable + public function hashCode () :int + { + return _value; + } + // from Boxed public function unbox () :Object { @@ -66,6 +76,18 @@ public class Byte return "Byte(" + _value + ")"; } + // from Streamable + public function readObject (ins :ObjectInputStream) :void + { + _value = ins.readByte(); + } + + // from Streamable + public function writeObject (out :ObjectOutputStream) :void + { + out.writeByte(_value); + } + protected var _value :int; } } diff --git a/src/as/com/threerings/util/Float.as b/src/as/com/threerings/util/Float.as index eda5f5136..33d2e3c49 100644 --- a/src/as/com/threerings/util/Float.as +++ b/src/as/com/threerings/util/Float.as @@ -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.Float. */ -public class Float - implements Equalable, Boxed +public final class Float + implements Hashable, Boxed, Streamable { public static function valueOf (val :Number) :Float { @@ -43,7 +47,7 @@ public class Float /** * Constructor. */ - public function Float (floatValue :Number) + public function Float (floatValue :Number = 0) { _value = floatValue; } @@ -54,12 +58,30 @@ public class Float return (other is Float) && (_value === (other as Float).value); } + // from Hashable + public function hashCode () :int + { + return int(_value); + } + // from Boxed public function unbox () :Object { return _value; } + // from Streamable + public function readObject (ins :ObjectInputStream) :void + { + _value = ins.readFloat(); + } + + // from Streamable + public function writeObject (out :ObjectOutputStream) :void + { + out.writeFloat(_value); + } + protected var _value :Number; } } diff --git a/src/as/com/threerings/util/Integer.as b/src/as/com/threerings/util/Integer.as index 38f144ece..c3028e745 100644 --- a/src/as/com/threerings/util/Integer.as +++ b/src/as/com/threerings/util/Integer.as @@ -21,6 +21,10 @@ package com.threerings.util { +import com.threerings.io.ObjectInputStream; +import com.threerings.io.ObjectOutputStream; +import com.threerings.io.Streamable; + /** * Equivalent to java.lang.Integer. */ @@ -29,8 +33,8 @@ package com.threerings.util { // autotranslate between int <--> java.lang.Integer and // Number <--> java.lang.Double. However, a Number object that refers // to an integer value is actually an int. Yes, it's totally fucked. -public class Integer - implements Equalable, Boxed +public final class Integer + implements Hashable, Boxed, Streamable { public static function valueOf (val :int) :Integer { @@ -48,7 +52,7 @@ public class Integer /** * Constructor. */ - public function Integer (intValue :int) + public function Integer (intValue :int = 0) { _value = intValue; } @@ -59,6 +63,12 @@ public class Integer return (other is Integer) && (_value === (other as Integer).value); } + // from Hashable + public function hashCode () :int + { + return _value; + } + // from Boxed public function unbox () :Object { @@ -79,7 +89,18 @@ public class Integer return (val1 > val2) ? 1 : (val1 == val2 ? 0 : -1); } - protected var _value :int; + // from Streamable + public function readObject (ins :ObjectInputStream) :void + { + _value = ins.readInt(); + } + // from Streamable + public function writeObject (out :ObjectOutputStream) :void + { + out.writeInt(_value); + } + + protected var _value :int; } } diff --git a/src/as/com/threerings/util/Long.as b/src/as/com/threerings/util/Long.as index ef30f4ce3..c732252b3 100644 --- a/src/as/com/threerings/util/Long.as +++ b/src/as/com/threerings/util/Long.as @@ -24,20 +24,22 @@ package com.threerings.util { import flash.utils.ByteArray; import flash.utils.Endian; +import com.threerings.io.ObjectInputStream; +import com.threerings.io.ObjectOutputStream; +import com.threerings.io.Streamable; + /** * Equivalent to java.lang.Long. */ -public class Long - implements Equalable +public final class Long + implements Hashable, Streamable { - public var bytes :ByteArray; - public function Long () { - bytes = new ByteArray(); - bytes.endian = Endian.BIG_ENDIAN; - bytes.writeDouble(0); - bytes.position = 0; + _bytes = new ByteArray(); + _bytes.endian = Endian.BIG_ENDIAN; + _bytes.writeDouble(0); + _bytes.position = 0; } /** @@ -57,7 +59,7 @@ public class Long var n :Number = Math.round(value); var l :Long = new Long(); for (var ii :int = 7; ii >= 0; ii--) { - l.bytes[ii] = (n % 256); + l._bytes[ii] = (n % 256); n = Math.floor(n / 256); } return l; @@ -70,10 +72,10 @@ public class Long public function toNumber () :Number { var n :Number = 0; - var positive :Boolean = ((bytes[0] & 0x80) == 0x00); + var positive :Boolean = ((_bytes[0] & 0x80) == 0x00); for (var ii :int = 0; ii < 8; ii++) { // if the number is negative, complement each byte as it comes in, and fix up later - n = n * 256 + (positive ? bytes[ii] : (255 - bytes[ii])); + n = n * 256 + (positive ? _bytes[ii] : (255 - _bytes[ii])); } // now fix up negative numbers if (! positive) { @@ -88,8 +90,8 @@ public class Long for (var ii :int = 0; ii < 8; ii++) { // my kingdom for a hex formatting routine! if (ii != 0) { s += " "; } - if (bytes[ii] < 16) { s += "0"; } - s += int(bytes[ii]).toString(16); + if (_bytes[ii] < 16) { s += "0"; } + s += int(_bytes[ii]).toString(16); } s += "]"; return s; @@ -98,7 +100,27 @@ public class Long // from Equalable public function equals (other :Object) :Boolean { - return (other is Long) && Util.equals(this.bytes, Long(other).bytes); + return (other is Long) && Util.equals(_bytes, Long(other)._bytes); } + + // from Hashable + public function hashCode () :int + { + return _bytes[0]; + } + + // from Streamable + public function readObject (ins :ObjectInputStream) :void + { + ins.readBytes(_bytes, 0, 8); + } + + // from Streamable + public function writeObject (out :ObjectOutputStream) :void + { + out.writeBytes(_bytes, 0, 8); + } + + protected var _bytes :ByteArray; } } diff --git a/src/as/com/threerings/util/Short.as b/src/as/com/threerings/util/Short.as index d9918e77c..fc4d45f1d 100644 --- a/src/as/com/threerings/util/Short.as +++ b/src/as/com/threerings/util/Short.as @@ -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; } } diff --git a/src/as/com/threerings/util/langBoolean.as b/src/as/com/threerings/util/langBoolean.as index e9877fd90..f7ca07e5d 100644 --- a/src/as/com/threerings/util/langBoolean.as +++ b/src/as/com/threerings/util/langBoolean.as @@ -28,8 +28,8 @@ import com.threerings.io.Streamable; /** * Equivalent to java.lang.Boolean. */ -public class langBoolean - implements Equalable, Streamable, Boxed +public final class langBoolean + implements Hashable, Boxed, Streamable { public static function valueOf (val :Boolean) :langBoolean { @@ -59,6 +59,12 @@ public class langBoolean (_value === (other as langBoolean).value); } + // from Hashable + public function hashCode () :int + { + return _value ? 1 : 0; + } + // from Streamable public function writeObject (out :ObjectOutputStream) :void {