Bug 726182. Add a JS_GetFunctionPrototype API for getting the canonical Function.prototype. r=waldo

This commit is contained in:
Boris Zbarsky 2012-02-10 17:49:39 -05:00
parent 0b9c148a1c
commit 99844f3e8d
2 changed files with 15 additions and 0 deletions

View File

@ -2169,6 +2169,14 @@ JS_GetObjectPrototype(JSContext *cx, JSObject *forObj)
return forObj->global().getOrCreateObjectPrototype(cx); return forObj->global().getOrCreateObjectPrototype(cx);
} }
JS_PUBLIC_API(JSObject *)
JS_GetFunctionPrototype(JSContext *cx, JSObject *forObj)
{
CHECK_REQUEST(cx);
assertSameCompartment(cx, forObj);
return forObj->global().getOrCreateFunctionPrototype(cx);
}
JS_PUBLIC_API(JSObject *) JS_PUBLIC_API(JSObject *)
JS_GetGlobalForObject(JSContext *cx, JSObject *obj) JS_GetGlobalForObject(JSContext *cx, JSObject *obj)
{ {

View File

@ -2744,6 +2744,13 @@ extern JS_PUBLIC_API(JSBool)
JS_GetClassObject(JSContext *cx, JSObject *obj, JSProtoKey key, JS_GetClassObject(JSContext *cx, JSObject *obj, JSProtoKey key,
JSObject **objp); JSObject **objp);
/*
* 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);
/* /*
* Returns the original value of |Object.prototype| from the global object in * Returns the original value of |Object.prototype| from the global object in
* which |forObj| was created. * which |forObj| was created.