Bug 699565 - Part 2 - for-of loops on arrays. r=bhackett.
This commit is contained in:
@@ -679,6 +679,13 @@ array_length_setter(JSContext *cx, JSObject *obj, jsid id, JSBool strict, Value
|
||||
return true;
|
||||
}
|
||||
|
||||
static JSObject *
|
||||
array_iterator(JSContext *cx, JSObject *obj, JSBool keysonly)
|
||||
{
|
||||
JS_ASSERT(!keysonly);
|
||||
return ElementIteratorObject::create(cx, obj);
|
||||
}
|
||||
|
||||
/* Returns true if the dense array has an own property at the index. */
|
||||
static inline bool
|
||||
IsDenseArrayIndex(JSObject *obj, uint32_t index)
|
||||
@@ -1215,7 +1222,7 @@ array_fix(JSContext *cx, JSObject *obj, bool *success, AutoIdVector *props)
|
||||
|
||||
Class js::ArrayClass = {
|
||||
"Array",
|
||||
Class::NON_NATIVE | JSCLASS_HAS_CACHED_PROTO(JSProto_Array),
|
||||
Class::NON_NATIVE | JSCLASS_HAS_CACHED_PROTO(JSProto_Array) | JSCLASS_FOR_OF_ITERATION,
|
||||
JS_PropertyStub, /* addProperty */
|
||||
JS_PropertyStub, /* delProperty */
|
||||
JS_PropertyStub, /* getProperty */
|
||||
@@ -1231,7 +1238,14 @@ Class js::ArrayClass = {
|
||||
NULL, /* xdrObject */
|
||||
NULL, /* hasInstance */
|
||||
array_trace, /* trace */
|
||||
JS_NULL_CLASS_EXT,
|
||||
{
|
||||
NULL, /* equality */
|
||||
NULL, /* outerObject */
|
||||
NULL, /* innerObject */
|
||||
array_iterator,
|
||||
NULL, /* unused */
|
||||
false, /* isWrappedNative */
|
||||
},
|
||||
{
|
||||
array_lookupGeneric,
|
||||
array_lookupProperty,
|
||||
@@ -1272,14 +1286,30 @@ Class js::ArrayClass = {
|
||||
|
||||
Class js::SlowArrayClass = {
|
||||
"Array",
|
||||
JSCLASS_HAS_CACHED_PROTO(JSProto_Array),
|
||||
JSCLASS_HAS_CACHED_PROTO(JSProto_Array) | JSCLASS_FOR_OF_ITERATION,
|
||||
slowarray_addProperty,
|
||||
JS_PropertyStub, /* delProperty */
|
||||
JS_PropertyStub, /* getProperty */
|
||||
JS_StrictPropertyStub, /* setProperty */
|
||||
JS_EnumerateStub,
|
||||
JS_ResolveStub,
|
||||
JS_ConvertStub
|
||||
JS_ConvertStub,
|
||||
NULL,
|
||||
NULL, /* reserved0 */
|
||||
NULL, /* checkAccess */
|
||||
NULL, /* call */
|
||||
NULL, /* construct */
|
||||
NULL, /* xdrObject */
|
||||
NULL, /* hasInstance */
|
||||
NULL, /* trace */
|
||||
{
|
||||
NULL, /* equality */
|
||||
NULL, /* outerObject */
|
||||
NULL, /* innerObject */
|
||||
array_iterator,
|
||||
NULL, /* unused */
|
||||
false, /* isWrappedNative */
|
||||
}
|
||||
};
|
||||
|
||||
bool
|
||||
|
||||
Reference in New Issue
Block a user