Merge from mozilla-central to jsdbg2 branch.
This commit is contained in:
@@ -945,9 +945,7 @@ array_fix(JSContext *cx, JSObject *obj, bool *success, AutoIdVector *props)
|
||||
|
||||
Class js_ArrayClass = {
|
||||
"Array",
|
||||
Class::NON_NATIVE |
|
||||
JSCLASS_HAS_PRIVATE |
|
||||
JSCLASS_HAS_CACHED_PROTO(JSProto_Array),
|
||||
Class::NON_NATIVE | JSCLASS_HAS_PRIVATE | JSCLASS_HAS_CACHED_PROTO(JSProto_Array),
|
||||
PropertyStub, /* addProperty */
|
||||
PropertyStub, /* delProperty */
|
||||
PropertyStub, /* getProperty */
|
||||
@@ -2635,8 +2633,6 @@ array_slice(JSContext *cx, uintN argc, Value *vp)
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
#if JS_HAS_ARRAY_EXTRAS
|
||||
|
||||
static JSBool
|
||||
array_indexOfHelper(JSContext *cx, JSBool isLast, uintN argc, Value *vp)
|
||||
{
|
||||
@@ -2957,7 +2953,6 @@ array_every(JSContext *cx, uintN argc, Value *vp)
|
||||
{
|
||||
return array_extra(cx, EVERY, argc, vp);
|
||||
}
|
||||
#endif
|
||||
|
||||
static JSBool
|
||||
array_isArray(JSContext *cx, uintN argc, Value *vp)
|
||||
@@ -2991,7 +2986,6 @@ static JSFunctionSpec array_methods[] = {
|
||||
JS_FN("concat", array_concat, 1,JSFUN_GENERIC_NATIVE),
|
||||
JS_FN("slice", array_slice, 2,JSFUN_GENERIC_NATIVE),
|
||||
|
||||
#if JS_HAS_ARRAY_EXTRAS
|
||||
JS_FN("indexOf", array_indexOf, 1,JSFUN_GENERIC_NATIVE),
|
||||
JS_FN("lastIndexOf", array_lastIndexOf, 1,JSFUN_GENERIC_NATIVE),
|
||||
JS_FN("forEach", array_forEach, 1,JSFUN_GENERIC_NATIVE),
|
||||
@@ -3001,7 +2995,6 @@ static JSFunctionSpec array_methods[] = {
|
||||
JS_FN("filter", array_filter, 1,JSFUN_GENERIC_NATIVE),
|
||||
JS_FN("some", array_some, 1,JSFUN_GENERIC_NATIVE),
|
||||
JS_FN("every", array_every, 1,JSFUN_GENERIC_NATIVE),
|
||||
#endif
|
||||
|
||||
JS_FS_END
|
||||
};
|
||||
@@ -3052,19 +3045,33 @@ js_Array(JSContext *cx, uintN argc, Value *vp)
|
||||
JSObject *
|
||||
js_InitArrayClass(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
JSObject *proto = js_InitClass(cx, obj, NULL, &js_ArrayClass, js_Array, 1,
|
||||
NULL, array_methods, NULL, array_static_methods);
|
||||
if (!proto)
|
||||
JS_ASSERT(obj->isNative());
|
||||
|
||||
GlobalObject *global = obj->asGlobal();
|
||||
|
||||
JSObject *arrayProto = global->createBlankPrototype(cx, &js_SlowArrayClass);
|
||||
if (!arrayProto || !AddLengthProperty(cx, arrayProto))
|
||||
return NULL;
|
||||
arrayProto->setArrayLength(0);
|
||||
|
||||
JSFunction *ctor = global->createConstructor(cx, js_Array, &js_ArrayClass,
|
||||
CLASS_ATOM(cx, Array), 1);
|
||||
if (!ctor)
|
||||
return NULL;
|
||||
|
||||
/*
|
||||
* Assert that js_InitClass used the correct (slow array, not dense array)
|
||||
* class for proto's emptyShape class.
|
||||
*/
|
||||
JS_ASSERT(proto->emptyShapes && proto->emptyShapes[0]->getClass() == proto->getClass());
|
||||
if (!LinkConstructorAndPrototype(cx, ctor, arrayProto))
|
||||
return NULL;
|
||||
|
||||
proto->setArrayLength(0);
|
||||
return proto;
|
||||
if (!DefinePropertiesAndBrand(cx, arrayProto, NULL, array_methods) ||
|
||||
!DefinePropertiesAndBrand(cx, ctor, NULL, array_static_methods))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!DefineConstructorAndPrototype(cx, global, JSProto_Array, ctor, arrayProto))
|
||||
return NULL;
|
||||
|
||||
return arrayProto;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user