Bug 671630 - Make initializing the ArrayBuffer class non-generic. r=mrbkap

--HG--
extra : rebase_source : cd80bf371b06a96e8ed2335ef6191a8a2e0bb2ad
This commit is contained in:
Jeff Walden 2011-05-04 16:54:24 -04:00
Родитель c682dbc9ab
Коммит d2df35cdb7
1 изменённых файлов: 31 добавлений и 16 удалений

Просмотреть файл

@ -1861,6 +1861,36 @@ Class TypedArray::slowClasses[TYPE_MAX] = {
IMPL_TYPED_ARRAY_SLOW_CLASS(Uint8ClampedArray)
};
static JSObject *
InitArrayBufferClass(JSContext *cx, GlobalObject *global)
{
JSObject *arrayBufferProto = global->createBlankPrototype(cx, &ArrayBuffer::slowClass);
if (!arrayBufferProto)
return NULL;
arrayBufferProto->setPrivate(NULL);
/* Ensure ArrayBuffer.prototype is correctly empty. */
if (!AllocateArrayBufferSlots(cx, arrayBufferProto, 0))
return NULL;
JSFunction *ctor =
global->createConstructor(cx, ArrayBuffer::class_constructor, &ArrayBuffer::fastClass,
CLASS_ATOM(cx, ArrayBuffer), 1);
if (!ctor)
return NULL;
if (!LinkConstructorAndPrototype(cx, ctor, arrayBufferProto))
return NULL;
if (!DefinePropertiesAndBrand(cx, arrayBufferProto, ArrayBuffer::jsprops, NULL))
return NULL;
if (!DefineConstructorAndPrototype(cx, global, JSProto_ArrayBuffer, ctor, arrayBufferProto))
return NULL;
return arrayBufferProto;
}
JS_FRIEND_API(JSObject *)
js_InitTypedArrayClasses(JSContext *cx, JSObject *obj)
{
@ -1888,22 +1918,7 @@ js_InitTypedArrayClasses(JSContext *cx, JSObject *obj)
return NULL;
}
JSObject *proto = js_InitClass(cx, global, NULL, &ArrayBuffer::slowClass,
ArrayBuffer::class_constructor, 1,
ArrayBuffer::jsprops, NULL, NULL, NULL);
if (!proto)
return NULL;
proto->setPrivate(NULL);
/*
* Initialize the slots to hold the length as 0
* This is required otherwise the length of a
* ArrayBuffer's prototype is undefined.
*/
if (!AllocateArrayBufferSlots(cx, proto, 0))
return NULL;
return proto;
return InitArrayBufferClass(cx, global);
}
JS_FRIEND_API(JSBool)