diff --git a/js/src/jsarray.cpp b/js/src/jsarray.cpp index cd3e58c43df0..1bebe34b7692 100644 --- a/js/src/jsarray.cpp +++ b/js/src/jsarray.cpp @@ -1004,10 +1004,8 @@ array_getAttributes(JSContext *cx, JSObject *obj, jsid id, uintN *attrsp) static JSBool array_getElementAttributes(JSContext *cx, JSObject *obj, uint32 index, uintN *attrsp) { - jsid id; - if (!IndexToId(cx, index, &id)) - return false; - return array_getAttributes(cx, obj, id, attrsp); + *attrsp = JSPROP_ENUMERATE; + return true; } static JSBool diff --git a/js/src/jsobj.cpp b/js/src/jsobj.cpp index f6bade8a6b32..302becf54296 100644 --- a/js/src/jsobj.cpp +++ b/js/src/jsobj.cpp @@ -6266,6 +6266,24 @@ js_GetAttributes(JSContext *cx, JSObject *obj, jsid id, uintN *attrsp) return true; } +JSBool +js_GetElementAttributes(JSContext *cx, JSObject *obj, uint32 index, uintN *attrsp) +{ + JSProperty *prop; + if (!js_LookupElement(cx, obj, index, &obj, &prop)) + return false; + if (!prop) { + *attrsp = 0; + return true; + } + if (!obj->isNative()) + return obj->getElementAttributes(cx, index, attrsp); + + const Shape *shape = (Shape *)prop; + *attrsp = shape->attributes(); + return true; +} + JSBool js_SetNativeAttributes(JSContext *cx, JSObject *obj, Shape *shape, uintN attrs) { diff --git a/js/src/jsobj.h b/js/src/jsobj.h index 783ff312f735..820a3d99ac73 100644 --- a/js/src/jsobj.h +++ b/js/src/jsobj.h @@ -286,6 +286,9 @@ js_SetPropertyHelper(JSContext *cx, JSObject *obj, jsid id, uintN defineHow, extern JSBool js_GetAttributes(JSContext *cx, JSObject *obj, jsid id, uintN *attrsp); +extern JSBool +js_GetElementAttributes(JSContext *cx, JSObject *obj, uint32 index, uintN *attrsp); + extern JSBool js_SetAttributes(JSContext *cx, JSObject *obj, jsid id, uintN *attrsp); @@ -1426,7 +1429,10 @@ struct JSObject : js::gc::Cell { return (op ? op : js_GetAttributes)(cx, this, id, attrsp); } - inline JSBool getElementAttributes(JSContext *cx, uint32 index, uintN *attrsp); + JSBool getElementAttributes(JSContext *cx, uint32 index, uintN *attrsp) { + js::ElementAttributesOp op = getOps()->getElementAttributes; + return (op ? op : js_GetElementAttributes)(cx, this, index, attrsp); + } inline JSBool setAttributes(JSContext *cx, jsid id, uintN *attrsp); diff --git a/js/src/jsobjinlines.h b/js/src/jsobjinlines.h index 39a7db901b1c..bd42505277c5 100644 --- a/js/src/jsobjinlines.h +++ b/js/src/jsobjinlines.h @@ -1137,15 +1137,6 @@ JSObject::setElement(JSContext *cx, uint32 index, js::Value *vp, JSBool strict) return setProperty(cx, id, vp, strict); } -inline JSBool -JSObject::getElementAttributes(JSContext *cx, uint32 index, uintN *attrsp) -{ - jsid id; - if (!js::IndexToId(cx, index, &id)) - return false; - return getAttributes(cx, id, attrsp); -} - inline JSBool JSObject::setElementAttributes(JSContext *cx, uint32 index, uintN *attrsp) { diff --git a/js/src/jstypedarray.cpp b/js/src/jstypedarray.cpp index 46c89d6da4c6..0d62cbd653a1 100644 --- a/js/src/jstypedarray.cpp +++ b/js/src/jstypedarray.cpp @@ -437,10 +437,10 @@ ArrayBuffer::obj_getAttributes(JSContext *cx, JSObject *obj, jsid id, uintN *att JSBool ArrayBuffer::obj_getElementAttributes(JSContext *cx, JSObject *obj, uint32 index, uintN *attrsp) { - jsid id; - if (!IndexToId(cx, index, &id)) + JSObject *delegate = DelegateObject(cx, obj); + if (!delegate) return false; - return obj_getAttributes(cx, obj, id, attrsp); + return js_GetElementAttributes(cx, delegate, index, attrsp); } JSBool @@ -660,10 +660,8 @@ TypedArray::obj_getAttributes(JSContext *cx, JSObject *obj, jsid id, uintN *attr JSBool TypedArray::obj_getElementAttributes(JSContext *cx, JSObject *obj, uint32 index, uintN *attrsp) { - jsid id; - if (!IndexToId(cx, index, &id)) - return false; - return obj_getAttributes(cx, obj, id, attrsp); + *attrsp = JSPROP_PERMANENT | JSPROP_ENUMERATE; + return true; } JSBool