From 059e7f760d2bd26316be4703227676e3279e5fa0 Mon Sep 17 00:00:00 2001 From: Ray Greenwell Date: Thu, 11 Sep 2008 21:01:10 +0000 Subject: [PATCH] Shock! Is that 'private' you see there? Omigod. It is. Normally we eschew private because we feel like people should be able to use our classes how they see fit. However, you *really* shouldn't be futzing with these fields, and them being protected would allow someone to write an Enum subclass and fuck-up other unrelated Enum subclasses, so I'm making an exception here. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5365 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- src/as/com/threerings/util/Enum.as | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/as/com/threerings/util/Enum.as b/src/as/com/threerings/util/Enum.as index 188f6d96d..6e48137b8 100644 --- a/src/as/com/threerings/util/Enum.as +++ b/src/as/com/threerings/util/Enum.as @@ -41,6 +41,11 @@ import flash.utils.Dictionary; * super(name); * } * + * public static function valueOf (name :String) :Foo + * { + * return Enum.valueOf(Foo, name); + * } + * * public static function values () :Array * { * return Enum.values(Foo); @@ -53,7 +58,7 @@ import flash.utils.Dictionary; * - declare your enum constants const, and with the same String as their name. * - call finishedEnumerating() at the end of your constants. * - your enum objects should be immutable - * - implement a static values() method for extra points, as above. + * - implement a static valueOf() and values() methods for extra points, as above. */ public class Enum implements Hashable, Comparable @@ -176,10 +181,10 @@ public class Enum protected var _name :String; /** An array of enums for each enum class. */ - protected static const _enums :Dictionary = new Dictionary(true); + private static const _enums :Dictionary = new Dictionary(true); /** Is further instantiation of enum constants for a class allowed? */ - protected static const _blocked :Dictionary = new Dictionary(true); + private static const _blocked :Dictionary = new Dictionary(true); finishedEnumerating(Enum); // do not allow any enums in this base class }