Bug 978238 - Part 1: Clean up PropDesc<->PropertyDescriptor conversions. (r=jorendorff)
This commit is contained in:
@@ -277,6 +277,9 @@ PropDesc::initFromPropertyDescriptor(Handle<PropertyDescriptor> desc)
|
|||||||
{
|
{
|
||||||
MOZ_ASSERT(isUndefined());
|
MOZ_ASSERT(isUndefined());
|
||||||
|
|
||||||
|
if (!desc.object())
|
||||||
|
return;
|
||||||
|
|
||||||
isUndefined_ = false;
|
isUndefined_ = false;
|
||||||
descObj_ = nullptr;
|
descObj_ = nullptr;
|
||||||
attrs = uint8_t(desc.attributes());
|
attrs = uint8_t(desc.attributes());
|
||||||
@@ -306,6 +309,21 @@ PropDesc::initFromPropertyDescriptor(Handle<PropertyDescriptor> desc)
|
|||||||
hasConfigurable_ = true;
|
hasConfigurable_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
PropDesc::populatePropertyDescriptor(HandleObject obj, MutableHandle<PropertyDescriptor> desc) const
|
||||||
|
{
|
||||||
|
if (isUndefined()) {
|
||||||
|
desc.object().set(nullptr);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
desc.value().set(hasValue() ? value() : UndefinedValue());
|
||||||
|
desc.setGetter(getter());
|
||||||
|
desc.setSetter(setter());
|
||||||
|
desc.setAttributes(attributes());
|
||||||
|
desc.object().set(obj);
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
PropDesc::makeObject(JSContext *cx)
|
PropDesc::makeObject(JSContext *cx)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -683,11 +683,7 @@ ParsePropertyDescriptorObject(JSContext *cx, HandleObject obj, const Value &v,
|
|||||||
return false;
|
return false;
|
||||||
if (complete)
|
if (complete)
|
||||||
d.complete();
|
d.complete();
|
||||||
desc.object().set(obj);
|
d.populatePropertyDescriptor(obj, desc);
|
||||||
desc.value().set(d.hasValue() ? d.value() : UndefinedValue());
|
|
||||||
desc.setAttributes(d.attributes());
|
|
||||||
desc.setGetter(d.getter());
|
|
||||||
desc.setSetter(d.setter());
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -125,6 +125,7 @@ struct PropDesc {
|
|||||||
* new property descriptor JSObject and defining properties on it.
|
* new property descriptor JSObject and defining properties on it.
|
||||||
*/
|
*/
|
||||||
void initFromPropertyDescriptor(Handle<JSPropertyDescriptor> desc);
|
void initFromPropertyDescriptor(Handle<JSPropertyDescriptor> desc);
|
||||||
|
void populatePropertyDescriptor(HandleObject obj, MutableHandle<JSPropertyDescriptor> desc) const;
|
||||||
bool makeObject(JSContext *cx);
|
bool makeObject(JSContext *cx);
|
||||||
|
|
||||||
/* Reset the descriptor entirely. */
|
/* Reset the descriptor entirely. */
|
||||||
@@ -281,6 +282,11 @@ class PropDescOperations
|
|||||||
|
|
||||||
JSPropertyOp getter() const { return desc()->getter(); }
|
JSPropertyOp getter() const { return desc()->getter(); }
|
||||||
JSStrictPropertyOp setter() const { return desc()->setter(); }
|
JSStrictPropertyOp setter() const { return desc()->setter(); }
|
||||||
|
|
||||||
|
void populatePropertyDescriptor(HandleObject obj,
|
||||||
|
MutableHandle<JSPropertyDescriptor> descriptor) const {
|
||||||
|
desc()->populatePropertyDescriptor(obj, descriptor);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename Outer>
|
template <typename Outer>
|
||||||
|
|||||||
Reference in New Issue
Block a user