Issue #1742 - Part 1: Refactor rooting base class templates

Based on Bug 1325406
This commit is contained in:
Moonchild 2022-05-24 06:51:11 +00:00 committed by roytam1
commit 80d7d43961
24 changed files with 239 additions and 512 deletions

View file

@ -2546,10 +2546,14 @@ struct JS_PUBLIC_API(PropertyDescriptor) {
void trace(JSTracer* trc);
};
template <typename Outer>
class PropertyDescriptorOperations
} // namespace JS
namespace js {
template <typename Wrapper>
class WrappedPtrOperations<JS::PropertyDescriptor, Wrapper>
{
const PropertyDescriptor& desc() const { return static_cast<const Outer*>(this)->get(); }
const JS::PropertyDescriptor& desc() const { return static_cast<const Wrapper*>(this)->get(); }
bool has(unsigned bit) const {
MOZ_ASSERT(bit != 0);
@ -2678,10 +2682,11 @@ class PropertyDescriptorOperations
}
};
template <typename Outer>
class MutablePropertyDescriptorOperations : public PropertyDescriptorOperations<Outer>
template <typename Wrapper>
class MutableWrappedPtrOperations<JS::PropertyDescriptor, Wrapper>
: public js::WrappedPtrOperations<JS::PropertyDescriptor, Wrapper>
{
PropertyDescriptor& desc() { return static_cast<Outer*>(this)->get(); }
JS::PropertyDescriptor& desc() { return static_cast<Wrapper*>(this)->get(); }
public:
void clear() {
@ -2692,7 +2697,7 @@ class MutablePropertyDescriptorOperations : public PropertyDescriptorOperations<
value().setUndefined();
}
void initFields(HandleObject obj, HandleValue v, unsigned attrs,
void initFields(JS::HandleObject obj, JS::HandleValue v, unsigned attrs,
JSGetterOp getterOp, JSSetterOp setterOp) {
MOZ_ASSERT(getterOp != JS_PropertyStub);
MOZ_ASSERT(setterOp != JS_StrictPropertyStub);
@ -2704,7 +2709,7 @@ class MutablePropertyDescriptorOperations : public PropertyDescriptorOperations<
setSetter(setterOp);
}
void assign(PropertyDescriptor& other) {
void assign(JS::PropertyDescriptor& other) {
object().set(other.obj);
setAttributes(other.attrs);
setGetter(other.getter);
@ -2712,7 +2717,7 @@ class MutablePropertyDescriptorOperations : public PropertyDescriptorOperations<
value().set(other.value);
}
void setDataDescriptor(HandleValue v, unsigned attrs) {
void setDataDescriptor(JS::HandleValue v, unsigned attrs) {
MOZ_ASSERT((attrs & ~(JSPROP_ENUMERATE |
JSPROP_PERMANENT |
JSPROP_READONLY |
@ -2787,26 +2792,7 @@ class MutablePropertyDescriptorOperations : public PropertyDescriptorOperations<
}
};
} /* namespace JS */
namespace js {
template <>
class RootedBase<JS::PropertyDescriptor>
: public JS::MutablePropertyDescriptorOperations<JS::Rooted<JS::PropertyDescriptor>>
{};
template <>
class HandleBase<JS::PropertyDescriptor>
: public JS::PropertyDescriptorOperations<JS::Handle<JS::PropertyDescriptor>>
{};
template <>
class MutableHandleBase<JS::PropertyDescriptor>
: public JS::MutablePropertyDescriptorOperations<JS::MutableHandle<JS::PropertyDescriptor>>
{};
} /* namespace js */
} // namespace js
namespace JS {