зеркало из https://github.com/mozilla/gecko-dev.git
Bug 978229 - Remove now unused NormalizeAndCompletePropertyDescriptor(). (r=Waldo)
This commit is contained in:
Родитель
678d3c183c
Коммит
e9ce83973a
|
@ -1111,78 +1111,6 @@ FromGenericPropertyDescriptor(JSContext *cx, MutableHandle<PropDesc> desc, Mutab
|
|||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Aux.3 NormalizePropertyDescriptor(Attributes)
|
||||
*
|
||||
* NOTE: to minimize code duplication, the code for this function is shared with
|
||||
* that for Aux.4 NormalizeAndCompletePropertyDescriptor (see below). The
|
||||
* argument complete is used to distinguish between the two.
|
||||
*/
|
||||
static bool
|
||||
NormalizePropertyDescriptor(JSContext *cx, MutableHandleValue vp, bool complete = false)
|
||||
{
|
||||
// Aux.4 step 1
|
||||
if (complete && vp.isUndefined())
|
||||
return true;
|
||||
|
||||
// Aux.3 steps 1-2 / Aux.4 steps 2-3
|
||||
Rooted<PropDesc> desc(cx);
|
||||
if (!desc.initialize(cx, vp.get()))
|
||||
return false;
|
||||
if (complete)
|
||||
desc.complete();
|
||||
JS_ASSERT(vp.isObject()); // due to desc->initialize
|
||||
RootedObject attributes(cx, &vp.toObject());
|
||||
|
||||
/*
|
||||
* Aux.3 step 3 / Aux.4 step 4
|
||||
*
|
||||
* NOTE: Aux.4 step 4 actually specifies FromPropertyDescriptor here.
|
||||
* However, the way FromPropertyDescriptor is implemented (PropDesc::
|
||||
* makeObject) is actually closer to FromGenericPropertyDescriptor,
|
||||
* and is in fact used to implement the latter, so we might as well call it
|
||||
* directly.
|
||||
*/
|
||||
if (!FromGenericPropertyDescriptor(cx, &desc, vp))
|
||||
return false;
|
||||
if (vp.isUndefined())
|
||||
return true;
|
||||
RootedObject descObj(cx, &vp.toObject());
|
||||
|
||||
// Aux.3 steps 4-5 / Aux.4 steps 5-6
|
||||
AutoIdVector props(cx);
|
||||
if (!GetPropertyNames(cx, attributes, 0, &props))
|
||||
return false;
|
||||
size_t n = props.length();
|
||||
for (size_t i = 0; i < n; ++i) {
|
||||
RootedId id(cx, props[i]);
|
||||
if (JSID_IS_ATOM(id)) {
|
||||
JSAtom *atom = JSID_TO_ATOM(id);
|
||||
const JSAtomState &atomState = cx->names();
|
||||
if (atom == atomState.value || atom == atomState.writable ||
|
||||
atom == atomState.get || atom == atomState.set ||
|
||||
atom == atomState.enumerable || atom == atomState.configurable)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
RootedValue v(cx);
|
||||
if (!JSObject::getGeneric(cx, descObj, attributes, id, &v))
|
||||
return false;
|
||||
if (!JSObject::defineGeneric(cx, descObj, id, v, nullptr, nullptr, JSPROP_ENUMERATE))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Aux.4 NormalizeAndCompletePropertyDescriptor(Attributes)
|
||||
static inline bool
|
||||
NormalizeAndCompletePropertyDescriptor(JSContext *cx, MutableHandleValue vp)
|
||||
{
|
||||
return NormalizePropertyDescriptor(cx, vp, true);
|
||||
}
|
||||
|
||||
static inline bool
|
||||
IsDataDescriptor(const PropertyDescriptor &desc)
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче