Bug 1036507 - Remove deceptive GetClassProtoKey API. r=luke

This thing is basically only useful for ye olde JS_InitClass classes where
people might try to create objects with external JSClasses and expect various
defaults when they invoke JS_NewObject. Let's move it out of the way.
This commit is contained in:
Bobby Holley
2014-07-11 09:09:21 -07:00
parent 1121c8039c
commit 62c3a2b6fc
2 changed files with 14 additions and 14 deletions

View File

@@ -1512,6 +1512,17 @@ js::NewObjectWithGivenProto(ExclusiveContext *cxArg, const js::Class *clasp,
return obj;
}
static JSProtoKey
ClassProtoKeyOrAnonymousOrNull(const js::Class *clasp)
{
JSProtoKey key = JSCLASS_CACHED_PROTO_KEY(clasp);
if (key != JSProto_Null)
return key;
if (clasp->flags & JSCLASS_IS_ANONYMOUS)
return JSProto_Object;
return JSProto_Null;
}
JSObject *
js::NewObjectWithClassProtoCommon(ExclusiveContext *cxArg,
const js::Class *clasp, JSObject *protoArg, JSObject *parentArg,
@@ -1535,7 +1546,7 @@ js::NewObjectWithClassProtoCommon(ExclusiveContext *cxArg,
* stored in an immutable slot on the global (except for ClearScope, which
* will flush the new object cache).
*/
JSProtoKey protoKey = GetClassProtoKey(clasp);
JSProtoKey protoKey = ClassProtoKeyOrAnonymousOrNull(clasp);
NewObjectCache::EntryIndex entry = -1;
if (JSContext *cx = cxArg->maybeJSContext()) {
@@ -3459,7 +3470,7 @@ JS::IdentifyStandardConstructor(JSObject *obj)
bool
js::FindClassObject(ExclusiveContext *cx, MutableHandleObject protop, const Class *clasp)
{
JSProtoKey protoKey = GetClassProtoKey(clasp);
JSProtoKey protoKey = ClassProtoKeyOrAnonymousOrNull(clasp);
if (protoKey != JSProto_Null) {
JS_ASSERT(JSProto_Null < protoKey);
JS_ASSERT(protoKey < JSProto_LIMIT);
@@ -5560,7 +5571,7 @@ bool
js::FindClassPrototype(ExclusiveContext *cx, MutableHandleObject protop, const Class *clasp)
{
protop.set(nullptr);
JSProtoKey protoKey = GetClassProtoKey(clasp);
JSProtoKey protoKey = ClassProtoKeyOrAnonymousOrNull(clasp);
if (protoKey != JSProto_Null)
return GetBuiltinPrototype(cx, protoKey, protop);