author | Bobby Holley <bobbyholley@gmail.com> |
Fri, 22 Nov 2013 10:55:42 -0800 | |
changeset 157163 | 98881f65a6656a258b6b8338120ffe47184b15df |
parent 157162 | 497280442d1ddcbaee8b70a6e57770d15f6a0638 |
child 157164 | 93cead0610da1b529992f85f177fc98f4097cd68 |
push id | 25703 |
push user | philringnalda@gmail.com |
push date | Sat, 23 Nov 2013 16:19:02 +0000 |
treeherder | mozilla-central@ad6589ed742c [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | jorendorff |
bugs | 933681 |
milestone | 28.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
js/src/jsapi.cpp | file | annotate | diff | comparison | revisions | |
js/src/jsapi.h | file | annotate | diff | comparison | revisions |
--- a/js/src/jsapi.cpp +++ b/js/src/jsapi.cpp @@ -1404,16 +1404,33 @@ JS_IdentifyClassPrototype(JSContext *cx, { AssertHeapIsIdle(cx); CHECK_REQUEST(cx); assertSameCompartment(cx, obj); JS_ASSERT(!obj->is<CrossCompartmentWrapperObject>()); return js_IdentifyClassPrototype(obj); } +extern JS_PUBLIC_API(JSProtoKey) +JS_IdToProtoKey(JSContext *cx, JS::HandleId id) +{ + AssertHeapIsIdle(cx); + CHECK_REQUEST(cx); + + if (!JSID_IS_ATOM(id)) + return JSProto_Null; + RootedString idstr(cx, JSID_TO_STRING(id)); + const JSStdName *stdnm = LookupStdName(cx->runtime(), idstr, standard_class_names); + if (!stdnm) + return JSProto_Null; + + MOZ_ASSERT(MOZ_ARRAY_LENGTH(standard_class_names) == JSProto_LIMIT + 1); + return static_cast<JSProtoKey>(stdnm - standard_class_names); +} + JS_PUBLIC_API(JSObject *) JS_GetObjectPrototype(JSContext *cx, JSObject *forObj) { CHECK_REQUEST(cx); assertSameCompartment(cx, forObj); return forObj->global().getOrCreateObjectPrototype(cx); }
--- a/js/src/jsapi.h +++ b/js/src/jsapi.h @@ -1764,16 +1764,19 @@ extern JS_PUBLIC_API(bool) JS_GetClassObject(JSContext *cx, JSObject *obj, JSProtoKey key, JSObject **objp); extern JS_PUBLIC_API(bool) JS_GetClassPrototype(JSContext *cx, JSProtoKey key, JSObject **objp); extern JS_PUBLIC_API(JSProtoKey) JS_IdentifyClassPrototype(JSContext *cx, JSObject *obj); +extern JS_PUBLIC_API(JSProtoKey) +JS_IdToProtoKey(JSContext *cx, JS::HandleId id); + /* * Returns the original value of |Function.prototype| from the global object in * which |forObj| was created. */ extern JS_PUBLIC_API(JSObject *) JS_GetFunctionPrototype(JSContext *cx, JSObject *forObj); /*