Bug 677703 - Add element-valued methods to ObjectOps. Implement forward-to-property versions where necessary for classes which have custom ObjectOps. r=cdleary
This commit is contained in:
@@ -723,6 +723,16 @@ array_lookupProperty(JSContext *cx, JSObject *obj, jsid id, JSObject **objp,
|
||||
return proto->lookupProperty(cx, id, objp, propp);
|
||||
}
|
||||
|
||||
static JSBool
|
||||
array_lookupElement(JSContext *cx, JSObject *obj, uint32 index, JSObject **objp,
|
||||
JSProperty **propp)
|
||||
{
|
||||
jsid id;
|
||||
if (!IndexToId(cx, index, &id))
|
||||
return false;
|
||||
return array_lookupProperty(cx, obj, id, objp, propp);
|
||||
}
|
||||
|
||||
JSBool
|
||||
js_GetDenseArrayElementValue(JSContext *cx, JSObject *obj, jsid id, Value *vp)
|
||||
{
|
||||
@@ -789,6 +799,15 @@ array_getProperty(JSContext *cx, JSObject *obj, JSObject *receiver, jsid id, Val
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
static JSBool
|
||||
array_getElement(JSContext *cx, JSObject *obj, JSObject *receiver, uint32 index, Value *vp)
|
||||
{
|
||||
jsid id;
|
||||
if (!IndexToId(cx, index, &id))
|
||||
return false;
|
||||
return array_getProperty(cx, obj, receiver, id, vp);
|
||||
}
|
||||
|
||||
static JSBool
|
||||
slowarray_addProperty(JSContext *cx, JSObject *obj, jsid id, Value *vp)
|
||||
{
|
||||
@@ -844,6 +863,15 @@ array_setProperty(JSContext *cx, JSObject *obj, jsid id, Value *vp, JSBool stric
|
||||
return js_SetPropertyHelper(cx, obj, id, 0, vp, strict);
|
||||
}
|
||||
|
||||
static JSBool
|
||||
array_setElement(JSContext *cx, JSObject *obj, uint32 index, Value *vp, JSBool strict)
|
||||
{
|
||||
jsid id;
|
||||
if (!IndexToId(cx, index, &id))
|
||||
return false;
|
||||
return array_setProperty(cx, obj, id, vp, strict);
|
||||
}
|
||||
|
||||
JSBool
|
||||
js_PrototypeHasIndexedProperties(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
@@ -868,6 +896,7 @@ js_PrototypeHasIndexedProperties(JSContext *cx, JSObject *obj)
|
||||
|
||||
namespace js {
|
||||
|
||||
/* non-static for direct definition of array elements within the engine */
|
||||
JSBool
|
||||
array_defineProperty(JSContext *cx, JSObject *obj, jsid id, const Value *value,
|
||||
PropertyOp getter, StrictPropertyOp setter, uintN attrs)
|
||||
@@ -903,6 +932,17 @@ array_defineProperty(JSContext *cx, JSObject *obj, jsid id, const Value *value,
|
||||
return js_DefineProperty(cx, obj, id, value, getter, setter, attrs);
|
||||
}
|
||||
|
||||
/* non-static for direct definition of array elements within the engine */
|
||||
JSBool
|
||||
array_defineElement(JSContext *cx, JSObject *obj, uint32 index, const Value *value,
|
||||
PropertyOp getter, StrictPropertyOp setter, uintN attrs)
|
||||
{
|
||||
jsid id;
|
||||
if (!IndexToId(cx, index, &id))
|
||||
return false;
|
||||
return array_defineProperty(cx, obj, id, value, getter, setter, attrs);
|
||||
}
|
||||
|
||||
} // namespace js
|
||||
|
||||
static JSBool
|
||||
@@ -913,6 +953,15 @@ array_getAttributes(JSContext *cx, JSObject *obj, jsid id, uintN *attrsp)
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
static JSBool
|
||||
array_setAttributes(JSContext *cx, JSObject *obj, jsid id, uintN *attrsp)
|
||||
{
|
||||
@@ -921,8 +970,18 @@ array_setAttributes(JSContext *cx, JSObject *obj, jsid id, uintN *attrsp)
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
static JSBool
|
||||
array_setElementAttributes(JSContext *cx, JSObject *obj, uint32 index, uintN *attrsp)
|
||||
{
|
||||
jsid id;
|
||||
if (!IndexToId(cx, index, &id))
|
||||
return false;
|
||||
return array_setAttributes(cx, obj, id, attrsp);
|
||||
}
|
||||
|
||||
namespace js {
|
||||
|
||||
/* non-static for direct deletion of array elements within the engine */
|
||||
JSBool
|
||||
array_deleteProperty(JSContext *cx, JSObject *obj, jsid id, Value *rval, JSBool strict)
|
||||
{
|
||||
@@ -948,6 +1007,16 @@ array_deleteProperty(JSContext *cx, JSObject *obj, jsid id, Value *rval, JSBool
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
/* non-static for direct deletion of array elements within the engine */
|
||||
JSBool
|
||||
array_deleteElement(JSContext *cx, JSObject *obj, uint32 index, Value *rval, JSBool strict)
|
||||
{
|
||||
jsid id;
|
||||
if (!IndexToId(cx, index, &id))
|
||||
return false;
|
||||
return array_deleteProperty(cx, obj, id, rval, strict);
|
||||
}
|
||||
|
||||
} // namespace js
|
||||
|
||||
static void
|
||||
@@ -997,12 +1066,19 @@ Class js::ArrayClass = {
|
||||
JS_NULL_CLASS_EXT,
|
||||
{
|
||||
array_lookupProperty,
|
||||
array_lookupElement,
|
||||
array_defineProperty,
|
||||
array_defineElement,
|
||||
array_getProperty,
|
||||
array_getElement,
|
||||
array_setProperty,
|
||||
array_setElement,
|
||||
array_getAttributes,
|
||||
array_getElementAttributes,
|
||||
array_setAttributes,
|
||||
array_setElementAttributes,
|
||||
array_deleteProperty,
|
||||
array_deleteElement,
|
||||
NULL, /* enumerate */
|
||||
array_typeOf,
|
||||
array_fix,
|
||||
|
||||
Reference in New Issue
Block a user