Bug 676936 - Rewrite InitGeneratorClass to be much clearer and simpler. r=luke

This commit is contained in:
Jeff Walden 2011-05-04 16:54:23 -04:00
parent 2639d4438d
commit 9e604da3b5
2 changed files with 10 additions and 3 deletions

View File

@ -1433,8 +1433,15 @@ static bool
InitGeneratorClass(JSContext *cx, GlobalObject *global)
{
#if JS_HAS_GENERATORS
return js_InitClass(cx, global, NULL, &js_GeneratorClass, NULL, 0,
NULL, generator_methods, NULL, NULL);
JSObject *proto = global->createBlankPrototype(cx, &js_GeneratorClass);
if (!proto)
return false;
if (!DefinePropertiesAndBrand(cx, proto, NULL, generator_methods))
return false;
/* This should use a non-JSProtoKey'd slot, but this is easier for now. */
return DefineConstructorAndPrototype(cx, global, JSProto_Generator, proto, proto);
#else
return true;
#endif

View File

@ -1373,7 +1373,7 @@ CopyInitializerObject(JSContext *cx, JSObject *baseobj)
inline bool
DefineConstructorAndPrototype(JSContext *cx, GlobalObject *global,
JSProtoKey key, JSFunction *ctor, JSObject *proto)
JSProtoKey key, JSObject *ctor, JSObject *proto)
{
JS_ASSERT(!global->nativeEmpty()); /* reserved slots already allocated */
JS_ASSERT(ctor);