зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1736737 - Use template magic to specialize WrappedPtrOperations for ArrayBufferOrView subtypes r=jonco
Differential Revision: https://phabricator.services.mozilla.com/D128963
This commit is contained in:
Родитель
c319a865d6
Коммит
b82d87038f
|
@ -117,7 +117,9 @@ namespace js {
|
|||
template <typename T>
|
||||
struct BarrierMethods {};
|
||||
|
||||
template <typename Element, typename Wrapper>
|
||||
// The defaulted Enable parameter is for restricting specializations
|
||||
// with std::enable_if.
|
||||
template <typename Element, typename Wrapper, typename Enable = void>
|
||||
class WrappedPtrOperations {};
|
||||
|
||||
template <typename Element, typename Wrapper>
|
||||
|
|
|
@ -625,8 +625,12 @@ JS_FOR_EACH_TYPED_ARRAY(JS_DECLARE_CLASS_ALIAS)
|
|||
|
||||
namespace js {
|
||||
|
||||
template <class Wrapper>
|
||||
class WrappedPtrOperations_ABoVBase {
|
||||
template <typename T>
|
||||
using EnableIfABOVType =
|
||||
std::enable_if_t<std::is_base_of_v<JS::ArrayBufferOrView, T>>;
|
||||
|
||||
template <typename T, typename Wrapper>
|
||||
class WrappedPtrOperations<T, Wrapper, EnableIfABOVType<T>> {
|
||||
auto get() const { return static_cast<const Wrapper*>(this)->get(); }
|
||||
|
||||
public:
|
||||
|
@ -635,29 +639,6 @@ class WrappedPtrOperations_ABoVBase {
|
|||
bool isDetached() const { return get().isDetached(); }
|
||||
};
|
||||
|
||||
template <typename Wrapper>
|
||||
class WrappedPtrOperations<JS::ArrayBufferOrView, Wrapper>
|
||||
: public WrappedPtrOperations_ABoVBase<Wrapper> {};
|
||||
template <typename Wrapper>
|
||||
class WrappedPtrOperations<JS::ArrayBuffer, Wrapper>
|
||||
: public WrappedPtrOperations_ABoVBase<Wrapper> {};
|
||||
template <typename Wrapper>
|
||||
class WrappedPtrOperations<JS::ArrayBufferView, Wrapper>
|
||||
: public WrappedPtrOperations_ABoVBase<Wrapper> {};
|
||||
template <typename Wrapper>
|
||||
class WrappedPtrOperations<JS::DataView, Wrapper>
|
||||
: public WrappedPtrOperations_ABoVBase<Wrapper> {};
|
||||
template <typename Wrapper>
|
||||
class WrappedPtrOperations<JS::TypedArray_base, Wrapper>
|
||||
: public WrappedPtrOperations_ABoVBase<Wrapper> {};
|
||||
|
||||
#define DECL_TYPED_ARRAY_ROOTED_BASE(_1, _2, Name) \
|
||||
template <typename Wrapper> \
|
||||
class WrappedPtrOperations<JS::TypedArray<JS::Scalar::Name>, Wrapper> \
|
||||
: public WrappedPtrOperations_ABoVBase<Wrapper> {};
|
||||
JS_FOR_EACH_TYPED_ARRAY(DECL_TYPED_ARRAY_ROOTED_BASE)
|
||||
#undef DECL_TYPED_ARRAY_ROOTED_BASE
|
||||
|
||||
} // namespace js
|
||||
|
||||
/*
|
||||
|
|
Загрузка…
Ссылка в новой задаче