Add PropertyName to the string-types tree in vm/String.h, and beef up the comment by PropertyName itself to better explain its utility. rs=luke
authorJeff Walden <jwalden@mit.edu>
Wed, 21 Sep 2011 15:37:43 -0700
changeset 77362 b27c16ee468c2d5a694fd34472778d502dfb73b7
parent 77361 ff35c22fc423a082b3c875014a63ee08b76e2acd
child 77363 b117f5ff61dbff1f4b6067309f39f160cf96d21e
push id3
push userfelipc@gmail.com
push dateFri, 30 Sep 2011 20:09:13 +0000
reviewersluke
milestone9.0a1
Add PropertyName to the string-types tree in vm/String.h, and beef up the comment by PropertyName itself to better explain its utility. rs=luke
js/src/vm/String.h
--- a/js/src/vm/String.h
+++ b/js/src/vm/String.h
@@ -141,20 +141,22 @@ js_AtomizeString(JSContext *cx, JSString
  *  | \  \
  *  |  \ JSExternalString       - / char array memory managed by embedding
  *  |   \
  *  |   JSInlineString          - / chars stored in header
  *  |     | \
  *  |     | JSShortString       - / header is fat
  *  |     |        |
  * JSAtom |        |            - / string equality === pointer equality
- *    \   |        |
- *    JSInlineAtom |            - / atomized JSInlineString
- *          \      |
- *          JSShortAtom         - / atomized JSShortString
+ *  | \   |        |
+ *  | JSInlineAtom |            - / atomized JSInlineString
+ *  |       \      |
+ *  |       JSShortAtom         - / atomized JSShortString
+ *  |
+ * js::PropertyName             - / chars don't contain an index (uint32)
  *
  * Classes marked with (abstract) above are not literally C++ Abstract Base
  * Classes (since there are no virtual functions, pure or not, in this
  * hierarchy), but have the same meaning: there are no strings with this type as
  * its most-derived type.
  *
  * Derived string types can be queried from ancestor types via isX() and
  * retrieved with asX() debug-only-checked casts.
@@ -723,19 +725,29 @@ class StaticStrings
 
     static const SmallChar toSmallChar[];
 
     JSAtom *getLength2(jschar c1, jschar c2);
     JSAtom *getLength2(uint32 i);
 };
 
 /*
- * Represents an atomized string which does not contain an unsigned 32-bit
- * value.  That is, it is never the case that for a PropertyName propname,
- * ToString(ToUint32(propname)) is equal to propname.
+ * Represents an atomized string which does not contain an index (that is, an
+ * unsigned 32-bit value).  Thus for any PropertyName propname,
+ * ToString(ToUint32(propname)) never equals propname.
+ *
+ * To more concretely illustrate the utility of PropertyName, consider that it
+ * is used to partition, in a type-safe manner, the ways to refer to a
+ * property, as follows:
+ *
+ *   - uint32 indexes,
+ *   - PropertyName strings which don't encode uint32 indexes, and
+ *   - jsspecial special properties (non-ES5 properties like object-valued
+ *     jsids, JSID_EMPTY, JSID_VOID, E4X's default XML namespace, and maybe in
+ *     the future Harmony-proposed private names).
  */
 class PropertyName : public JSAtom
 {};
 
 JS_STATIC_ASSERT(sizeof(PropertyName) == sizeof(JSString));
 
 } /* namespace js */