Bug 1225392 part 1. Expose JSAPI for getting %IteratorPrototype%. r=efaust
authorBoris Zbarsky <bzbarsky@mit.edu>
Wed, 18 Nov 2015 18:26:07 -0500
changeset 273172 0aff4d08702d9d8be59a02fbae60c98129ea432e
parent 273171 7b54175c1241fe2c758619d8faa7f471cef4472e
child 273173 ff8e1e77c6151b0c94b9f9d8cf2b95b41030a5d5
push id68192
push userbzbarsky@mozilla.com
push dateWed, 18 Nov 2015 23:26:33 +0000
treeherdermozilla-inbound@ff8e1e77c615 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersefaust
bugs1225392
milestone45.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
Bug 1225392 part 1. Expose JSAPI for getting %IteratorPrototype%. r=efaust
js/src/jsapi.cpp
js/src/jsapi.h
--- a/js/src/jsapi.cpp
+++ b/js/src/jsapi.cpp
@@ -1216,16 +1216,24 @@ JS_PUBLIC_API(JSObject*)
 JS_GetErrorPrototype(JSContext* cx)
 {
     CHECK_REQUEST(cx);
     Rooted<GlobalObject*> global(cx, cx->global());
     return GlobalObject::getOrCreateCustomErrorPrototype(cx, global, JSEXN_ERR);
 }
 
 JS_PUBLIC_API(JSObject*)
+JS_GetIteratorPrototype(JSContext* cx)
+{
+    CHECK_REQUEST(cx);
+    Rooted<GlobalObject*> global(cx, cx->global());
+    return GlobalObject::getOrCreateIteratorPrototype(cx, global);
+}
+
+JS_PUBLIC_API(JSObject*)
 JS_GetGlobalForObject(JSContext* cx, JSObject* obj)
 {
     AssertHeapIsIdle(cx);
     assertSameCompartment(cx, obj);
     return &obj->global();
 }
 
 extern JS_PUBLIC_API(bool)
--- a/js/src/jsapi.h
+++ b/js/src/jsapi.h
@@ -1498,16 +1498,23 @@ JS_GetArrayPrototype(JSContext* cx, JS::
 
 /**
  * Returns the original value of |Error.prototype| from the global
  * object of the current compartment of cx.
  */
 extern JS_PUBLIC_API(JSObject*)
 JS_GetErrorPrototype(JSContext* cx);
 
+/**
+ * Returns the %IteratorPrototype% object that all built-in iterator prototype
+ * chains go through for the global object of the current compartment of cx.
+ */
+extern JS_PUBLIC_API(JSObject*)
+JS_GetIteratorPrototype(JSContext* cx);
+
 extern JS_PUBLIC_API(JSObject*)
 JS_GetGlobalForObject(JSContext* cx, JSObject* obj);
 
 extern JS_PUBLIC_API(bool)
 JS_IsGlobalObject(JSObject* obj);
 
 extern JS_PUBLIC_API(JSObject*)
 JS_GlobalLexicalScope(JSObject* obj);