Bug 933681 - Rename the tables in jsapi.cpp to something that makes sense. r=jorendorff

This commit is contained in:
Bobby Holley 2013-11-22 10:55:42 -08:00
parent 46905c4c30
commit 03430ca901

View File

@ -1200,17 +1200,16 @@ LookupStdName(JSRuntime *rt, HandleString name, const JSStdName *table)
*/ */
#define STD_NAME_ENTRY(name, code, init, clasp) { init, EAGER_CLASS_ATOM(name), clasp }, #define STD_NAME_ENTRY(name, code, init, clasp) { init, EAGER_CLASS_ATOM(name), clasp },
#define STD_DUMMY_ENTRY(name, code, init, dummy) { DummyInit, 0, nullptr }, #define STD_DUMMY_ENTRY(name, code, init, dummy) { DummyInit, 0, nullptr },
static const JSStdName standard_class_atoms[] = { static const JSStdName standard_class_names[] = {
JS_FOR_PROTOTYPES(STD_NAME_ENTRY, STD_DUMMY_ENTRY) JS_FOR_PROTOTYPES(STD_NAME_ENTRY, STD_DUMMY_ENTRY)
{ nullptr, 0, nullptr } { nullptr, 0, nullptr }
}; };
/* /*
* Table of top-level function and constant names and their init functions. * Table of top-level function and constant names and the init function of the
* If you add a "standard" global function or property, remember to update * corresponding standard class that sets them up.
* this table.
*/ */
static const JSStdName standard_class_names[] = { static const JSStdName builtin_property_names[] = {
{js_InitObjectClass, EAGER_ATOM(eval), &JSObject::class_}, {js_InitObjectClass, EAGER_ATOM(eval), &JSObject::class_},
/* Global properties and functions defined by the Number class. */ /* Global properties and functions defined by the Number class. */
@ -1297,11 +1296,11 @@ JS_ResolveStandardClass(JSContext *cx, HandleObject obj, HandleId id, bool *reso
} }
/* Try for class constructors/prototypes named by well-known atoms. */ /* Try for class constructors/prototypes named by well-known atoms. */
stdnm = LookupStdName(rt, idstr, standard_class_atoms); stdnm = LookupStdName(rt, idstr, standard_class_names);
/* Try less frequently used top-level functions and constants. */ /* Try less frequently used top-level functions and constants. */
if (!stdnm) if (!stdnm)
stdnm = LookupStdName(rt, idstr, standard_class_names); stdnm = LookupStdName(rt, idstr, builtin_property_names);
/* /*
* Try even less frequently used names delegated from the global * Try even less frequently used names delegated from the global
@ -1355,9 +1354,16 @@ JS_EnumerateStandardClasses(JSContext *cx, HandleObject obj)
return false; return false;
} }
/* Initialize any classes that have not been initialized yet. */ /*
for (unsigned i = 0; standard_class_atoms[i].init; i++) { * Initialize any classes that have not been initialized yet. Note that
const JSStdName &stdnm = standard_class_atoms[i]; * resolving everything in standard_class_names has the effect of resolving
* everything in builtin_property_names, so we don't need to iterate over
* that separately. Moreover, we'll resolve the Object constructor as well,
* so we can also skip object_prototype_names.
*/
for (unsigned i = 0; standard_class_names[i].init; i++) {
const JSStdName &stdnm = standard_class_names[i];
// Watch out for dummy entries.
if (!stdnm.isDummy() && !obj->as<GlobalObject>().isStandardClassResolved(stdnm.clasp)) { if (!stdnm.isDummy() && !obj->as<GlobalObject>().isStandardClassResolved(stdnm.clasp)) {
if (!stdnm.init(cx, obj)) if (!stdnm.init(cx, obj))
return false; return false;