From 90921b63a02fa1c62b643bf548ab646f4b98c4f7 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Tue, 14 May 2013 14:17:09 -0400 Subject: [PATCH] Bug 872043. Add an API for getting the canonical Array.prototype for a global. 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 49961dc2bce..c57570640c1 100644 --- a/js/src/jsapi.cpp +++ b/js/src/jsapi.cpp @@ -2242,6 +2242,14 @@ JS_GetFunctionPrototype(JSContext *cx, JSObject *forObj) return forObj->global().getOrCreateFunctionPrototype(cx); } +JS_PUBLIC_API(JSObject *) +JS_GetArrayPrototype(JSContext *cx, JSObject *forObj) +{ + CHECK_REQUEST(cx); + assertSameCompartment(cx, forObj); + return forObj->global().getOrCreateArrayPrototype(cx); +} + JS_PUBLIC_API(JSObject *) JS_GetGlobalForObject(JSContext *cx, JSObject *obj) { diff --git a/js/src/jsapi.h b/js/src/jsapi.h index 1a7a431cc68..8a2588f0d4e 100644 --- a/js/src/jsapi.h +++ b/js/src/jsapi.h @@ -2159,6 +2159,13 @@ JS_GetFunctionPrototype(JSContext *cx, JSObject *forObj); extern JS_PUBLIC_API(JSObject *) JS_GetObjectPrototype(JSContext *cx, JSObject *forObj); +/* + * Returns the original value of |Array.prototype| from the global object in + * which |forObj| was created. + */ +extern JS_PUBLIC_API(JSObject *) +JS_GetArrayPrototype(JSContext *cx, JSObject *forObj); + extern JS_PUBLIC_API(JSObject *) JS_GetGlobalForObject(JSContext *cx, JSObject *obj);