Bug 1142784, part 3 - Change js::DefinePropertyOp and a few property-defining functions to use PropertyDescriptor rather than separate (value, attrs, getter, setter) arguments. r=Waldo.

This commit is contained in:
Jason Orendorff
2015-02-28 11:23:44 -06:00
parent f8862424e5
commit 43fc5cd147
14 changed files with 82 additions and 50 deletions

View File

@@ -3173,23 +3173,30 @@ js::GetOwnPropertyDescriptor(JSContext *cx, HandleObject obj, HandleId id,
return true;
}
bool
js::DefineProperty(JSContext *cx, HandleObject obj, HandleId id, Handle<PropertyDescriptor> desc,
ObjectOpResult &result)
{
if (DefinePropertyOp op = obj->getOps()->defineProperty)
return op(cx, obj, id, desc, result);
return NativeDefineProperty(cx, obj.as<NativeObject>(), id, desc, result);
}
bool
js::DefineProperty(ExclusiveContext *cx, HandleObject obj, HandleId id, HandleValue value,
JSGetterOp getter, JSSetterOp setter, unsigned attrs,
ObjectOpResult &result)
{
MOZ_ASSERT(getter != JS_PropertyStub);
MOZ_ASSERT(setter != JS_StrictPropertyStub);
MOZ_ASSERT(!(attrs & JSPROP_PROPOP_ACCESSORS));
DefinePropertyOp op = obj->getOps()->defineProperty;
if (op) {
Rooted<PropertyDescriptor> desc(cx);
desc.initFields(obj, value, attrs, getter, setter);
if (DefinePropertyOp op = obj->getOps()->defineProperty) {
if (!cx->shouldBeJSContext())
return false;
return op(cx->asJSContext(), obj, id, value, getter, setter, attrs, result);
return op(cx->asJSContext(), obj, id, desc, result);
}
return NativeDefineProperty(cx, obj.as<NativeObject>(), id, value, getter, setter, attrs,
result);
return NativeDefineProperty(cx, obj.as<NativeObject>(), id, desc, result);
}
bool