Bug 1469217 part 3 - Clean up TryResolvePropertyFromSpecs; remove a bunch of macros. r=anba

This commit is contained in:
Jan de Mooij 2018-06-21 11:05:42 +02:00
Родитель 45a7ade57e
Коммит b47f1cb4ba
2 изменённых файлов: 17 добавлений и 44 удалений

Просмотреть файл

@ -1460,9 +1460,6 @@ private:
namespace JS {
namespace detail {
/* NEVER DEFINED, DON'T USE. For use by JS_CAST_NATIVE_TO only. */
inline int CheckIsNative(JSNative native);
/* NEVER DEFINED, DON'T USE. For use by JS_CAST_STRING_TO only. */
template<size_t N>
inline int
@ -1471,19 +1468,9 @@ CheckIsCharacterLiteral(const char (&arr)[N]);
/* NEVER DEFINED, DON'T USE. For use by JS_CAST_INT32_TO only. */
inline int CheckIsInt32(int32_t value);
/* NEVER DEFINED, DON'T USE. For use by JS_PROPERTYOP_GETTER only. */
inline int CheckIsGetterOp(JSGetterOp op);
/* NEVER DEFINED, DON'T USE. For use by JS_PROPERTYOP_SETTER only. */
inline int CheckIsSetterOp(JSSetterOp op);
} // namespace detail
} // namespace JS
#define JS_CAST_NATIVE_TO(v, To) \
(static_cast<void>(sizeof(JS::detail::CheckIsNative(v))), \
reinterpret_cast<To>(v))
#define JS_CAST_STRING_TO(s, To) \
(static_cast<void>(sizeof(JS::detail::CheckIsCharacterLiteral(s))), \
reinterpret_cast<To>(s))
@ -1496,14 +1483,6 @@ inline int CheckIsSetterOp(JSSetterOp op);
(static_cast<mozilla::EnableIf<((flags) & ~(JSPROP_ENUMERATE | JSPROP_PERMANENT)) == 0>::Type>(0), \
(flags))
#define JS_PROPERTYOP_GETTER(v) \
(static_cast<void>(sizeof(JS::detail::CheckIsGetterOp(v))), \
reinterpret_cast<JSNative>(v))
#define JS_PROPERTYOP_SETTER(v) \
(static_cast<void>(sizeof(JS::detail::CheckIsSetterOp(v))), \
reinterpret_cast<JSNative>(v))
#define JS_PS_ACCESSOR_SPEC(name, getter, setter, flags, extraFlags) \
{ name, uint8_t(JS_CHECK_ACCESSOR_FLAGS(flags) | extraFlags), \
{ { getter, setter } } }

Просмотреть файл

@ -421,36 +421,30 @@ TryResolvePropertyFromSpecs(JSContext* cx, HandleId id, HandleObject holder,
desc.value().setUndefined();
unsigned flags = psMatch->flags;
if (psMatch->isAccessor()) {
RootedFunction getterObj(cx);
RootedFunction setterObj(cx);
RootedObject getterObj(cx);
RootedObject setterObj(cx);
if (psMatch->isSelfHosted()) {
getterObj = JS::GetSelfHostedFunction(cx, psMatch->accessors.getter.selfHosted.funname, id, 0);
if (!getterObj)
JSFunction* getterFun = JS::GetSelfHostedFunction(cx, psMatch->accessors.getter.selfHosted.funname, id, 0);
if (!getterFun)
return false;
desc.setGetterObject(JS_GetFunctionObject(getterObj));
getterObj = JS_GetFunctionObject(getterFun);
if (psMatch->accessors.setter.selfHosted.funname) {
MOZ_ASSERT(flags & JSPROP_SETTER);
setterObj = JS::GetSelfHostedFunction(cx, psMatch->accessors.setter.selfHosted.funname, id, 0);
if (!setterObj)
JSFunction* setterFun = JS::GetSelfHostedFunction(cx, psMatch->accessors.setter.selfHosted.funname, id, 0);
if (!setterFun)
return false;
desc.setSetterObject(JS_GetFunctionObject(setterObj));
setterObj = JS_GetFunctionObject(setterFun);
}
if (!JS_DefinePropertyById(cx, holder, id, getterObj, setterObj, flags))
return false;
} else {
desc.setGetter(JS_CAST_NATIVE_TO(psMatch->accessors.getter.native.op,
JSGetterOp));
desc.setSetter(JS_CAST_NATIVE_TO(psMatch->accessors.setter.native.op,
JSSetterOp));
}
desc.setAttributes(flags);
if (!JS_DefinePropertyById(cx, holder, id,
JS_PROPERTYOP_GETTER(desc.getter()),
JS_PROPERTYOP_SETTER(desc.setter()),
// This particular descriptor, unlike most,
// actually stores JSNatives directly,
// since we just set it up.
desc.attributes()))
{
return false;
if (!JS_DefinePropertyById(cx, holder, id,
psMatch->accessors.getter.native.op,
psMatch->accessors.setter.native.op,
flags))
{
return false;
}
}
} else {
RootedValue v(cx);