Bug 1095660 part 3. Give With objects defineProperty/Element/Generic class hooks. r=luke

This commit is contained in:
Boris Zbarsky 2014-11-12 17:04:28 -05:00
parent 8e9f9042cb
commit 3004f99d36

@ -480,6 +480,32 @@ with_LookupElement(JSContext *cx, HandleObject obj, uint32_t index,
return with_LookupGeneric(cx, obj, id, objp, propp);
}
static bool
with_DefineGeneric(JSContext *cx, HandleObject obj, HandleId id, HandleValue value,
JSPropertyOp getter, JSStrictPropertyOp setter, unsigned attrs)
{
RootedObject actual(cx, &obj->as<DynamicWithObject>().object());
return JSObject::defineGeneric(cx, actual, id, value, getter, setter, attrs);
}
static bool
with_DefineProperty(JSContext *cx, HandleObject obj, HandlePropertyName name, HandleValue value,
JSPropertyOp getter, JSStrictPropertyOp setter, unsigned attrs)
{
Rooted<jsid> id(cx, NameToId(name));
return with_DefineGeneric(cx, obj, id, value, getter, setter, attrs);
}
static bool
with_DefineElement(JSContext *cx, HandleObject obj, uint32_t index, HandleValue value,
JSPropertyOp getter, JSStrictPropertyOp setter, unsigned attrs)
{
RootedId id(cx);
if (!IndexToId(cx, index, &id))
return false;
return with_DefineGeneric(cx, obj, id, value, getter, setter, attrs);
}
static bool
with_GetGeneric(JSContext *cx, HandleObject obj, HandleObject receiver, HandleId id,
MutableHandleValue vp)
@ -593,9 +619,9 @@ const Class DynamicWithObject::class_ = {
with_LookupGeneric,
with_LookupProperty,
with_LookupElement,
nullptr, /* defineGeneric */
nullptr, /* defineProperty */
nullptr, /* defineElement */
with_DefineGeneric,
with_DefineProperty,
with_DefineElement,
with_GetGeneric,
with_GetProperty,
with_GetElement,