From 99844f3e8d03e0069b14b2ff48b3cbe34cb16dc7 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Fri, 10 Feb 2012 17:49:39 -0500 Subject: [PATCH] Bug 726182. Add a JS_GetFunctionPrototype API for getting the canonical Function.prototype. r=waldo --- js/src/jsapi.cpp | 8 ++++++++ js/src/jsapi.h | 7 +++++++ 2 files changed, 15 insertions(+) diff --git a/js/src/jsapi.cpp b/js/src/jsapi.cpp index 21fae8357b3..0d0b631c22c 100644 --- a/js/src/jsapi.cpp +++ b/js/src/jsapi.cpp @@ -2169,6 +2169,14 @@ JS_GetObjectPrototype(JSContext *cx, JSObject *forObj) 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_GetGlobalForObject(JSContext *cx, JSObject *obj) { diff --git a/js/src/jsapi.h b/js/src/jsapi.h index 5e14cbc0f06..82b78355b55 100644 --- a/js/src/jsapi.h +++ b/js/src/jsapi.h @@ -2744,6 +2744,13 @@ extern JS_PUBLIC_API(JSBool) JS_GetClassObject(JSContext *cx, JSObject *obj, JSProtoKey key, 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 * which |forObj| was created.