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
This commit is contained in:
@@ -41,6 +41,11 @@ import flash.utils.Dictionary;
|
|||||||
* super(name);
|
* super(name);
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
|
* public static function valueOf (name :String) :Foo
|
||||||
|
* {
|
||||||
|
* return Enum.valueOf(Foo, name);
|
||||||
|
* }
|
||||||
|
*
|
||||||
* public static function values () :Array
|
* public static function values () :Array
|
||||||
* {
|
* {
|
||||||
* return Enum.values(Foo);
|
* 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.
|
* - declare your enum constants const, and with the same String as their name.
|
||||||
* - call finishedEnumerating() at the end of your constants.
|
* - call finishedEnumerating() at the end of your constants.
|
||||||
* - your enum objects should be immutable
|
* - 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
|
public class Enum
|
||||||
implements Hashable, Comparable
|
implements Hashable, Comparable
|
||||||
@@ -176,10 +181,10 @@ public class Enum
|
|||||||
protected var _name :String;
|
protected var _name :String;
|
||||||
|
|
||||||
/** An array of enums for each enum class. */
|
/** 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? */
|
/** 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
|
finishedEnumerating(Enum); // do not allow any enums in this base class
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user