зеркало из https://github.com/mozilla/gecko-dev.git
Bug 885729 - Inline array and proxy specializations of js::DefineProperty into js::DefineProperties. r=jwalden
--HG-- extra : rebase_source : eaed8f6a1ba9a171c3d0d47641482b8d3273bd8d
This commit is contained in:
Родитель
ba80bab8ed
Коммит
0139cd9c05
|
@ -23,25 +23,6 @@ using js::frontend::IsIdentifier;
|
|||
using mozilla::ArrayLength;
|
||||
|
||||
|
||||
// Duplicated in jsobj.cpp
|
||||
static bool
|
||||
DefineProperties(JSContext *cx, HandleObject obj, HandleObject props)
|
||||
{
|
||||
AutoIdVector ids(cx);
|
||||
AutoPropDescArrayRooter descs(cx);
|
||||
if (!ReadPropertyDescriptors(cx, props, true, &ids, &descs))
|
||||
return false;
|
||||
|
||||
bool dummy;
|
||||
for (size_t i = 0, len = ids.length(); i < len; i++) {
|
||||
if (!DefineProperty(cx, obj, ids.handleAt(i), descs[i], true, &dummy))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
JSBool
|
||||
js::obj_construct(JSContext *cx, unsigned argc, Value *vp)
|
||||
{
|
||||
|
|
|
@ -1053,18 +1053,44 @@ js::ReadPropertyDescriptors(JSContext *cx, HandleObject props, bool checkAccesso
|
|||
return true;
|
||||
}
|
||||
|
||||
// Duplicated in Object.cpp
|
||||
static bool
|
||||
DefineProperties(JSContext *cx, HandleObject obj, HandleObject props)
|
||||
bool
|
||||
js::DefineProperties(JSContext *cx, HandleObject obj, HandleObject props)
|
||||
{
|
||||
AutoIdVector ids(cx);
|
||||
AutoPropDescArrayRooter descs(cx);
|
||||
if (!ReadPropertyDescriptors(cx, props, true, &ids, &descs))
|
||||
return false;
|
||||
|
||||
if (obj->is<ArrayObject>()) {
|
||||
bool dummy;
|
||||
Rooted<ArrayObject*> arr(cx, &obj->as<ArrayObject>());
|
||||
for (size_t i = 0, len = ids.length(); i < len; i++) {
|
||||
if (!DefinePropertyOnArray(cx, arr, ids.handleAt(i), descs[i], true, &dummy))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if (obj->getOps()->lookupGeneric) {
|
||||
/*
|
||||
* FIXME: Once ScriptedIndirectProxies are removed, this code should call
|
||||
* TrapDefineOwnProperty directly
|
||||
*/
|
||||
if (obj->isProxy()) {
|
||||
for (size_t i = 0, len = ids.length(); i < len; i++) {
|
||||
RootedValue pd(cx, descs[i].pd());
|
||||
if (!Proxy::defineProperty(cx, obj, ids.handleAt(i), pd))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
bool dummy;
|
||||
return Reject(cx, obj, JSMSG_OBJECT_NOT_EXTENSIBLE, true, &dummy);
|
||||
}
|
||||
|
||||
bool dummy;
|
||||
for (size_t i = 0, len = ids.length(); i < len; i++) {
|
||||
if (!DefineProperty(cx, obj, ids.handleAt(i), descs[i], true, &dummy))
|
||||
if (!DefinePropertyOnObject(cx, obj, ids.handleAt(i), descs[i], true, &dummy))
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -1316,6 +1316,9 @@ DefineProperty(JSContext *cx, js::HandleObject obj,
|
|||
js::HandleId id, const PropDesc &desc, bool throwError,
|
||||
bool *rval);
|
||||
|
||||
bool
|
||||
DefineProperties(JSContext *cx, HandleObject obj, HandleObject props);
|
||||
|
||||
/*
|
||||
* Read property descriptors from props, as for Object.defineProperties. See
|
||||
* ES5 15.2.3.7 steps 3-5.
|
||||
|
|
Загрузка…
Ссылка в новой задаче