Bug 676936 - Rewrite InitStopIterationClass to be much clearer and simpler. r=luke
authorJeff Walden <jwalden@mit.edu>
Wed, 04 May 2011 16:54:23 -0400
changeset 74048 f25d125362a85d0b0f9f23be253dba53992d6869
parent 74047 aade388e6c6223c34f1220135089c57795303075
child 74049 0d36e53e837d13405e821d3a5ef4bda8e4636051
push id2
push userbsmedberg@mozilla.com
push dateFri, 19 Aug 2011 14:38:13 +0000
reviewersluke
bugs676936
milestone8.0a1
Bug 676936 - Rewrite InitStopIterationClass to be much clearer and simpler. r=luke
js/src/jsiter.cpp
--- a/js/src/jsiter.cpp
+++ b/js/src/jsiter.cpp
@@ -1445,20 +1445,26 @@ InitGeneratorClass(JSContext *cx, Global
 #else
     return true;
 #endif
 }
 
 static JSObject *
 InitStopIterationClass(JSContext *cx, GlobalObject *global)
 {
-    JSObject *proto = js_InitClass(cx, global, NULL, &js_StopIterationClass, NULL, 0,
-                                   NULL, NULL, NULL, NULL);
-    if (proto)
-        MarkStandardClassInitializedNoProto(global, &js_StopIterationClass);
+    JSObject *proto = global->createBlankPrototype(cx, &js_StopIterationClass);
+    if (!proto || !proto->freeze(cx))
+        return NULL;
+
+    /* This should use a non-JSProtoKey'd slot, but this is easier for now. */
+    if (!DefineConstructorAndPrototype(cx, global, JSProto_StopIteration, proto, proto))
+        return NULL;
+
+    MarkStandardClassInitializedNoProto(global, &js_StopIterationClass);
+
     return proto;
 }
 
 JSObject *
 js_InitIteratorClasses(JSContext *cx, JSObject *obj)
 {
     JS_ASSERT(obj->isNative());