From 459f12ded5fb27f5a78857cda3552adb4039c8ea Mon Sep 17 00:00:00 2001 From: Ray Greenwell Date: Sat, 24 Jun 2006 23:03:07 +0000 Subject: [PATCH] Copy Java's valueOf factory method for primitive wrapper classes. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4217 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- src/as/com/threerings/crowd/chat/data/SpeakMarshaller.as | 2 +- src/as/com/threerings/crowd/data/BodyObject.as | 2 +- src/as/com/threerings/crowd/data/LocationMarshaller.as | 2 +- src/as/com/threerings/util/Byte.as | 5 +++++ src/as/com/threerings/util/Float.as | 5 +++++ src/as/com/threerings/util/Integer.as | 5 +++++ src/as/com/threerings/util/Long.as | 5 +++++ src/as/com/threerings/util/Short.as | 5 +++++ 8 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/as/com/threerings/crowd/chat/data/SpeakMarshaller.as b/src/as/com/threerings/crowd/chat/data/SpeakMarshaller.as index d1fa3a4bd..4bde4b9ee 100644 --- a/src/as/com/threerings/crowd/chat/data/SpeakMarshaller.as +++ b/src/as/com/threerings/crowd/chat/data/SpeakMarshaller.as @@ -44,7 +44,7 @@ public class SpeakMarshaller extends InvocationMarshaller // documentation inherited from interface public function speak (arg1 :Client, arg2 :String, arg3 :int) :void { - sendRequest(arg1, SPEAK, [ arg2, new Byte(arg3) ]); + sendRequest(arg1, SPEAK, [ arg2, Byte.valueOf(arg3) ]); } } } diff --git a/src/as/com/threerings/crowd/data/BodyObject.as b/src/as/com/threerings/crowd/data/BodyObject.as index f9ba8baa7..d36c52b00 100644 --- a/src/as/com/threerings/crowd/data/BodyObject.as +++ b/src/as/com/threerings/crowd/data/BodyObject.as @@ -181,7 +181,7 @@ public class BodyObject extends ClientObject { var ovalue :int = this.status; requestAttributeChange( - STATUS, new Byte(value), new Byte(ovalue)); + STATUS, Byte.valueOf(value), Byte.valueOf(ovalue)); this.status = value; } diff --git a/src/as/com/threerings/crowd/data/LocationMarshaller.as b/src/as/com/threerings/crowd/data/LocationMarshaller.as index f568d2e8f..d91a1f388 100644 --- a/src/as/com/threerings/crowd/data/LocationMarshaller.as +++ b/src/as/com/threerings/crowd/data/LocationMarshaller.as @@ -57,7 +57,7 @@ public class LocationMarshaller extends InvocationMarshaller { var listener3 :LocationMarshaller_MoveMarshaller = new LocationMarshaller_MoveMarshaller(); listener3.listener = arg3; - sendRequest(arg1, MOVE_TO, [ new Integer(arg2), listener3 ]); + sendRequest(arg1, MOVE_TO, [ Integer.valueOf(arg2), listener3 ]); } } } diff --git a/src/as/com/threerings/util/Byte.as b/src/as/com/threerings/util/Byte.as index 76c3a33f5..b5a01a71a 100644 --- a/src/as/com/threerings/util/Byte.as +++ b/src/as/com/threerings/util/Byte.as @@ -8,6 +8,11 @@ public class Byte { public var value :int; + public static function valueOf (val :int) :Byte + { + return new Byte(val); + } + public function Byte (value :int) { this.value = value; diff --git a/src/as/com/threerings/util/Float.as b/src/as/com/threerings/util/Float.as index 37263f79b..8d08f66ed 100644 --- a/src/as/com/threerings/util/Float.as +++ b/src/as/com/threerings/util/Float.as @@ -8,6 +8,11 @@ public class Float { public var value :Number; + public static function valueOf (val :Number) :Float + { + return new Float(val); + } + public function Float (value :Number) { this.value = value; diff --git a/src/as/com/threerings/util/Integer.as b/src/as/com/threerings/util/Integer.as index 258fd7ad3..e75efbba0 100644 --- a/src/as/com/threerings/util/Integer.as +++ b/src/as/com/threerings/util/Integer.as @@ -13,6 +13,11 @@ public class Integer { public var value :int; + public static function valueOf (val :int) :Integer + { + return new Integer(val); + } + public function Integer (value :int) { this.value = value; diff --git a/src/as/com/threerings/util/Long.as b/src/as/com/threerings/util/Long.as index 77c1ba877..04196d0a7 100644 --- a/src/as/com/threerings/util/Long.as +++ b/src/as/com/threerings/util/Long.as @@ -9,6 +9,11 @@ public class Long public var high :int; public var low :int; + public static function valueOf (low :int, high :int = 0) :Long + { + return new Long(low, high); + } + public function Long (low :int, high :int = 0) { this.low = low; diff --git a/src/as/com/threerings/util/Short.as b/src/as/com/threerings/util/Short.as index 051862a55..df0cd8330 100644 --- a/src/as/com/threerings/util/Short.as +++ b/src/as/com/threerings/util/Short.as @@ -8,6 +8,11 @@ public class Short { public var value :int; + public static function valueOf (val :int) :Short + { + return new Short(val); + } + public function Short (value :int) { this.value = value;