Bug 1625138 - Part 35: Replace mozilla::TrueType with std::true_type. r=froydnj,jgilbert

Differential Revision: https://phabricator.services.mozilla.com/D68554

--HG--
extra : moz-landing-system : lando
This commit is contained in:
André Bargull 2020-03-28 13:57:20 +00:00
parent f8eb4c162e
commit 2712714d84
24 changed files with 105 additions and 98 deletions

View File

@ -1580,7 +1580,7 @@ struct PcqParamTraits {
// ---------------------------------------------------------------
template <>
struct IsTriviallySerializable<PcqStatus> : TrueType {};
struct IsTriviallySerializable<PcqStatus> : std::true_type {};
// ---------------------------------------------------------------
@ -2061,7 +2061,7 @@ struct PcqParamTraits<UniquePtr<T>> {
// it use FileDescriptor::auto_close.
#if defined(OS_WIN)
template <>
struct IsTriviallySerializable<base::SharedMemoryHandle> : TrueType {};
struct IsTriviallySerializable<base::SharedMemoryHandle> : std::true_type {};
#elif defined(OS_POSIX)
// SharedMemoryHandle is typedefed to base::FileDescriptor
template <>

View File

@ -20,41 +20,42 @@ template <typename T>
struct PcqParamTraits;
template <>
struct IsTriviallySerializable<FloatOrInt> : TrueType {};
struct IsTriviallySerializable<FloatOrInt> : std::true_type {};
template <>
struct IsTriviallySerializable<webgl::ShaderPrecisionFormat> : TrueType {};
struct IsTriviallySerializable<webgl::ShaderPrecisionFormat> : std::true_type {
};
template <>
struct IsTriviallySerializable<WebGLContextOptions> : TrueType {};
struct IsTriviallySerializable<WebGLContextOptions> : std::true_type {};
template <>
struct IsTriviallySerializable<WebGLPixelStore> : TrueType {};
struct IsTriviallySerializable<WebGLPixelStore> : std::true_type {};
template <>
struct IsTriviallySerializable<WebGLTexImageData> : TrueType {};
struct IsTriviallySerializable<WebGLTexImageData> : std::true_type {};
template <>
struct IsTriviallySerializable<WebGLTexPboOffset> : TrueType {};
struct IsTriviallySerializable<WebGLTexPboOffset> : std::true_type {};
template <>
struct IsTriviallySerializable<webgl::ExtensionBits> : TrueType {};
struct IsTriviallySerializable<webgl::ExtensionBits> : std::true_type {};
template <>
struct IsTriviallySerializable<webgl::GetUniformData> : TrueType {};
struct IsTriviallySerializable<webgl::GetUniformData> : std::true_type {};
template <>
struct IsTriviallySerializable<ICRData> : TrueType {};
struct IsTriviallySerializable<ICRData> : std::true_type {};
template <>
struct IsTriviallySerializable<gfx::IntSize> : TrueType {};
struct IsTriviallySerializable<gfx::IntSize> : std::true_type {};
template <typename T>
struct IsTriviallySerializable<avec2<T>> : TrueType {};
struct IsTriviallySerializable<avec2<T>> : std::true_type {};
template <typename T>
struct IsTriviallySerializable<avec3<T>> : TrueType {};
struct IsTriviallySerializable<avec3<T>> : std::true_type {};
template <>
struct IsTriviallySerializable<webgl::TexUnpackBlob> : TrueType {};
struct IsTriviallySerializable<webgl::TexUnpackBlob> : std::true_type {};
/*
template <>
struct PcqParamTraits<WebGLActiveInfo> {

View File

@ -34,7 +34,7 @@ struct DDLoggedTypeTraits;
struct DDLoggedTypeTraits<TYPE> { \
using Type = TYPE; \
static constexpr const char* Name() { return #TYPE; } \
using HasBase = TrueType; \
using HasBase = std::true_type; \
using BaseType = BASE; \
static constexpr const char* BaseTypeName() { \
return DDLoggedTypeTraits<BASE>::Name(); \
@ -56,7 +56,7 @@ struct DDLoggedTypeTraits;
struct DDLoggedTypeTraits<TYPE> { \
using Type = TYPE; \
static constexpr const char* Name() { return #NAME; } \
using HasBase = TrueType; \
using HasBase = std::true_type; \
using BaseType = BASE; \
static constexpr const char* BaseTypeName() { \
return DDLoggedTypeTraits<BASE>::Name(); \

View File

@ -19,6 +19,7 @@
#include "mozilla/TypeTraits.h"
#include <cmath>
#include <type_traits>
namespace mozilla {
@ -33,7 +34,7 @@ struct UnknownUnits {};
} // namespace gfx
template <>
struct IsPixel<gfx::UnknownUnits> : TrueType {};
struct IsPixel<gfx::UnknownUnits> : std::true_type {};
namespace gfx {

View File

@ -14,6 +14,7 @@
#include <stdint.h> // for uint16_t, uint32_t
#include <sys/types.h> // for int32_t
#include <type_traits>
#include "LayersLogging.h" // for print_stderr
#include "mozilla/gfx/gfxVars.h"
#include "mozilla/gfx/Logging.h" // for gfxCriticalError
@ -28,7 +29,7 @@ namespace mozilla {
struct TileCoordUnit {};
template <>
struct IsPixel<TileCoordUnit> : mozilla::TrueType {};
struct IsPixel<TileCoordUnit> : std::true_type {};
namespace layers {

View File

@ -8,6 +8,7 @@
#define mozilla_layers_APZUtils_h
#include <stdint.h> // for uint32_t
#include <type_traits>
#include "gfxTypes.h"
#include "FrameMetrics.h"
#include "LayersTypes.h"
@ -23,7 +24,7 @@ namespace mozilla {
struct ExternalPixel;
template <>
struct IsPixel<ExternalPixel> : TrueType {};
struct IsPixel<ExternalPixel> : std::true_type {};
typedef gfx::CoordTyped<ExternalPixel> ExternalCoord;
typedef gfx::IntCoordTyped<ExternalPixel> ExternalIntCoord;

View File

@ -23,7 +23,7 @@ template <typename T>
struct TypeIsGCThing : std::false_type {};
template <>
struct TypeIsGCThing<JS::Value> : mozilla::TrueType {};
struct TypeIsGCThing<JS::Value> : std::true_type {};
} // namespace detail

View File

@ -7,6 +7,8 @@
#ifndef frontend_NameAnalysisTypes_h
#define frontend_NameAnalysisTypes_h
#include <type_traits>
#include "vm/BytecodeUtil.h"
#include "vm/Scope.h"
@ -341,10 +343,10 @@ using FunctionBoxVector = Vector<const FunctionBox*, 8>;
namespace mozilla {
template <>
struct IsPod<js::frontend::DeclaredNameInfo> : TrueType {};
struct IsPod<js::frontend::DeclaredNameInfo> : std::true_type {};
template <>
struct IsPod<js::frontend::NameLocation> : TrueType {};
struct IsPod<js::frontend::NameLocation> : std::true_type {};
} // namespace mozilla

View File

@ -22,6 +22,7 @@
#include <inttypes.h>
#include <stdio.h>
#include <string.h>
#include <type_traits>
#include "jsapi.h"
#include "jsnum.h"
@ -291,7 +292,7 @@ struct OffsetAndDefIndex {
namespace mozilla {
template <>
struct IsPod<OffsetAndDefIndex> : TrueType {};
struct IsPod<OffsetAndDefIndex> : std::true_type {};
} // namespace mozilla

View File

@ -86,7 +86,7 @@ enum MaybeCheckTDZ { CheckTDZ = true, DontCheckTDZ = false };
namespace mozilla {
template <>
struct IsPod<js::MaybeCheckTDZ> : TrueType {};
struct IsPod<js::MaybeCheckTDZ> : std::true_type {};
} // namespace mozilla
/*****************************************************************************/

View File

@ -22,6 +22,8 @@
#include "mozilla/CompactPair.h"
#include "mozilla/Poison.h"
#include <type_traits>
#include "jit/AtomicOp.h"
#include "js/Printf.h"
#include "wasm/WasmUtility.h"
@ -2729,9 +2731,9 @@ namespace mozilla {
// Specialize IsPod for the Nothing specializations.
template <>
struct IsPod<js::wasm::TypeAndValueT<Nothing>> : TrueType {};
struct IsPod<js::wasm::TypeAndValueT<Nothing>> : std::true_type {};
template <>
struct IsPod<js::wasm::ControlStackEntry<Nothing>> : TrueType {};
struct IsPod<js::wasm::ControlStackEntry<Nothing>> : std::true_type {};
} // namespace mozilla

View File

@ -29,6 +29,8 @@
#include "mozilla/RefPtr.h"
#include "mozilla/Unused.h"
#include <type_traits>
#include "NamespaceImports.h"
#include "ds/LifoAlloc.h"
@ -124,15 +126,15 @@ typedef Vector<UniqueChars, 0, SystemAllocPolicy> UniqueCharsVector;
// which is pretty verbose to do within js::wasm, so factor that process out
// into a macro.
#define WASM_DECLARE_POD_VECTOR(Type, VectorName) \
} \
} \
namespace mozilla { \
template <> \
struct IsPod<js::wasm::Type> : TrueType {}; \
} \
namespace js { \
namespace wasm { \
#define WASM_DECLARE_POD_VECTOR(Type, VectorName) \
} \
} \
namespace mozilla { \
template <> \
struct IsPod<js::wasm::Type> : std::true_type {}; \
} \
namespace js { \
namespace wasm { \
typedef Vector<Type, 0, SystemAllocPolicy> VectorName;
// A wasm Module and everything it contains must support serialization and

View File

@ -11,6 +11,7 @@
#include <functional>
#include <limits>
#include <stdlib.h> // for div()
#include <type_traits>
#include "gfxContext.h"
#include "mozilla/AutoRestore.h"
#include "mozilla/ComputedStyle.h"
@ -313,7 +314,7 @@ MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(TrackSize::StateBits)
namespace mozilla {
template <>
struct IsPod<nsGridContainerFrame::TrackSize> : TrueType {};
struct IsPod<nsGridContainerFrame::TrackSize> : std::true_type {};
} // namespace mozilla
TrackSize::StateBits nsGridContainerFrame::TrackSize::Initialize(

View File

@ -51,17 +51,17 @@ template <typename T>
struct AllowDeprecatedAbsFixed : std::false_type {};
template <>
struct AllowDeprecatedAbsFixed<int32_t> : TrueType {};
struct AllowDeprecatedAbsFixed<int32_t> : std::true_type {};
template <>
struct AllowDeprecatedAbsFixed<int64_t> : TrueType {};
struct AllowDeprecatedAbsFixed<int64_t> : std::true_type {};
template <typename T>
struct AllowDeprecatedAbs : AllowDeprecatedAbsFixed<T> {};
template <>
struct AllowDeprecatedAbs<int> : TrueType {};
struct AllowDeprecatedAbs<int> : std::true_type {};
template <>
struct AllowDeprecatedAbs<long> : TrueType {};
struct AllowDeprecatedAbs<long> : std::true_type {};
} // namespace detail

View File

@ -285,7 +285,7 @@ template <typename T>
struct IsResult : std::false_type {};
template <typename V, typename E>
struct IsResult<Result<V, E>> : TrueType {};
struct IsResult<Result<V, E>> : std::true_type {};
} // namespace detail

View File

@ -74,8 +74,7 @@ template <class T>
struct is_span_oracle : std::false_type {};
template <class ElementType, size_t Extent>
struct is_span_oracle<mozilla::Span<ElementType, Extent>> : mozilla::TrueType {
};
struct is_span_oracle<mozilla::Span<ElementType, Extent>> : std::true_type {};
template <class T>
struct is_span : public is_span_oracle<std::remove_cv_t<T>> {};
@ -84,8 +83,7 @@ template <class T>
struct is_std_array_oracle : std::false_type {};
template <class ElementType, size_t Extent>
struct is_std_array_oracle<std::array<ElementType, Extent>>
: mozilla::TrueType {};
struct is_std_array_oracle<std::array<ElementType, Extent>> : std::true_type {};
template <class T>
struct is_std_array : public is_std_array_oracle<std::remove_cv_t<T>> {};

View File

@ -22,11 +22,6 @@
namespace mozilla {
/* 20.9.3 Helper classes [meta.help] */
/** Convenient aliases. */
typedef std::integral_constant<bool, true> TrueType;
/* 20.9.4 Unary type traits [meta.unary] */
/* 20.9.4.3 Type properties [meta.unary.prop] */
@ -34,7 +29,7 @@ typedef std::integral_constant<bool, true> TrueType;
/**
* Traits class for identifying POD types. Until C++11 there's no automatic
* way to detect PODs, so for the moment this is done manually. Users may
* define specializations of this class that inherit from mozilla::TrueType and
* define specializations of this class that inherit from std::true_type and
* std::false_type (or equivalently std::integral_constant<bool, true or
* false>, or conveniently from mozilla::IsPod for composite types) as needed to
* ensure correct IsPod behavior.
@ -43,45 +38,45 @@ template <typename T>
struct IsPod : public std::false_type {};
template <>
struct IsPod<char> : TrueType {};
struct IsPod<char> : std::true_type {};
template <>
struct IsPod<signed char> : TrueType {};
struct IsPod<signed char> : std::true_type {};
template <>
struct IsPod<unsigned char> : TrueType {};
struct IsPod<unsigned char> : std::true_type {};
template <>
struct IsPod<short> : TrueType {};
struct IsPod<short> : std::true_type {};
template <>
struct IsPod<unsigned short> : TrueType {};
struct IsPod<unsigned short> : std::true_type {};
template <>
struct IsPod<int> : TrueType {};
struct IsPod<int> : std::true_type {};
template <>
struct IsPod<unsigned int> : TrueType {};
struct IsPod<unsigned int> : std::true_type {};
template <>
struct IsPod<long> : TrueType {};
struct IsPod<long> : std::true_type {};
template <>
struct IsPod<unsigned long> : TrueType {};
struct IsPod<unsigned long> : std::true_type {};
template <>
struct IsPod<long long> : TrueType {};
struct IsPod<long long> : std::true_type {};
template <>
struct IsPod<unsigned long long> : TrueType {};
struct IsPod<unsigned long long> : std::true_type {};
template <>
struct IsPod<bool> : TrueType {};
struct IsPod<bool> : std::true_type {};
template <>
struct IsPod<float> : TrueType {};
struct IsPod<float> : std::true_type {};
template <>
struct IsPod<double> : TrueType {};
struct IsPod<double> : std::true_type {};
template <>
struct IsPod<wchar_t> : TrueType {};
struct IsPod<wchar_t> : std::true_type {};
template <>
struct IsPod<char16_t> : TrueType {};
struct IsPod<char16_t> : std::true_type {};
template <typename T>
struct IsPod<T*> : TrueType {};
struct IsPod<T*> : std::true_type {};
namespace detail {
struct DoIsDestructibleImpl {
template <typename T, typename = decltype(std::declval<T&>().~T())>
static TrueType test(int);
static std::true_type test(int);
template <typename T>
static std::false_type test(...);
};
@ -125,7 +120,7 @@ template <typename T, typename U>
struct IsSame : std::false_type {};
template <typename T>
struct IsSame<T, T> : TrueType {};
struct IsSame<T, T> : std::true_type {};
} /* namespace mozilla */

View File

@ -59,10 +59,10 @@ template <typename T>
struct IsAtomic : std::false_type {};
template <typename T, MemoryOrdering Order>
struct IsAtomic<Atomic<T, Order>> : TrueType {};
struct IsAtomic<Atomic<T, Order>> : std::true_type {};
template <typename T>
struct IsAtomic<std::atomic<T>> : TrueType {};
struct IsAtomic<std::atomic<T>> : std::true_type {};
namespace StaticPrefs {

View File

@ -113,7 +113,8 @@ def main(output, *filenames):
print("\ntemplate<class T> struct IsCategoricalLabelEnum : std::false_type {};", file=output)
for name, _, _ in enums:
print("template<> struct IsCategoricalLabelEnum<%s> : TrueType {};" % name, file=output)
print("template<> struct IsCategoricalLabelEnum<%s> : std::true_type {};" % name,
file=output)
print("\ntemplate<class T> struct CategoricalLabelId {};", file=output)
for name, _, id in enums:

View File

@ -400,7 +400,7 @@ class ThreadSafeAutoRefCnt {
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr) override; \
NS_IMETHOD_(MozExternalRefCountType) AddRef(void) override; \
NS_IMETHOD_(MozExternalRefCountType) Release(void) override; \
typedef mozilla::TrueType HasThreadSafeRefCnt; \
using HasThreadSafeRefCnt = std::true_type; \
\
protected: \
::mozilla::ThreadSafeAutoRefCnt mRefCnt; \
@ -647,7 +647,7 @@ class ThreadSafeAutoRefCnt {
} \
return count; \
} \
typedef mozilla::TrueType HasThreadSafeRefCnt; \
using HasThreadSafeRefCnt = std::true_type; \
\
protected: \
::mozilla::ThreadSafeAutoRefCnt mRefCnt; \

View File

@ -7,6 +7,8 @@
#ifndef nsAtom_h
#define nsAtom_h
#include <type_traits>
#include "nsISupportsImpl.h"
#include "nsString.h"
#include "mozilla/Atomics.h"
@ -87,7 +89,7 @@ class nsAtom {
inline MozExternalRefCountType AddRef();
inline MozExternalRefCountType Release();
typedef mozilla::TrueType HasThreadSafeRefCnt;
using HasThreadSafeRefCnt = std::true_type;
protected:
// Used by nsStaticAtom.

View File

@ -914,7 +914,7 @@ struct IsCompareMethod : std::false_type {};
template <typename T, typename U>
struct IsCompareMethod<
T, U, decltype(std::declval<T>()(std::declval<U>(), std::declval<U>()))>
: mozilla::TrueType {};
: std::true_type {};
// These two wrappers allow us to use either a tri-state comparator, or an
// object with Equals() and LessThan() methods interchangeably. They provide a

View File

@ -96,7 +96,7 @@ struct IsMozPromise : std::false_type {};
template <typename ResolveValueT, typename RejectValueT, bool IsExclusive>
struct IsMozPromise<MozPromise<ResolveValueT, RejectValueT, IsExclusive>>
: TrueType {};
: std::true_type {};
/*
* A promise manages an asynchronous request that may or may not be able to be

View File

@ -576,10 +576,10 @@ template <typename CVRemoved>
struct IsRefcountedSmartPointerHelper : std::false_type {};
template <typename Pointee>
struct IsRefcountedSmartPointerHelper<RefPtr<Pointee>> : TrueType {};
struct IsRefcountedSmartPointerHelper<RefPtr<Pointee>> : std::true_type {};
template <typename Pointee>
struct IsRefcountedSmartPointerHelper<nsCOMPtr<Pointee>> : TrueType {};
struct IsRefcountedSmartPointerHelper<nsCOMPtr<Pointee>> : std::true_type {};
} // namespace detail
@ -897,7 +897,7 @@ struct StoreCopyPassByValue {
};
template <typename S>
struct IsParameterStorageClass<StoreCopyPassByValue<S>>
: public mozilla::TrueType {};
: public std::true_type {};
template <typename T>
struct StoreCopyPassByConstLRef {
@ -910,7 +910,7 @@ struct StoreCopyPassByConstLRef {
};
template <typename S>
struct IsParameterStorageClass<StoreCopyPassByConstLRef<S>>
: public mozilla::TrueType {};
: public std::true_type {};
template <typename T>
struct StoreCopyPassByLRef {
@ -922,8 +922,8 @@ struct StoreCopyPassByLRef {
passed_type PassAsParameter() { return m; }
};
template <typename S>
struct IsParameterStorageClass<StoreCopyPassByLRef<S>>
: public mozilla::TrueType {};
struct IsParameterStorageClass<StoreCopyPassByLRef<S>> : public std::true_type {
};
template <typename T>
struct StoreCopyPassByRRef {
@ -935,8 +935,8 @@ struct StoreCopyPassByRRef {
passed_type PassAsParameter() { return std::move(m); }
};
template <typename S>
struct IsParameterStorageClass<StoreCopyPassByRRef<S>>
: public mozilla::TrueType {};
struct IsParameterStorageClass<StoreCopyPassByRRef<S>> : public std::true_type {
};
template <typename T>
struct StoreRefPassByLRef {
@ -948,8 +948,8 @@ struct StoreRefPassByLRef {
passed_type PassAsParameter() { return m; }
};
template <typename S>
struct IsParameterStorageClass<StoreRefPassByLRef<S>>
: public mozilla::TrueType {};
struct IsParameterStorageClass<StoreRefPassByLRef<S>> : public std::true_type {
};
template <typename T>
struct StoreConstRefPassByConstLRef {
@ -962,7 +962,7 @@ struct StoreConstRefPassByConstLRef {
};
template <typename S>
struct IsParameterStorageClass<StoreConstRefPassByConstLRef<S>>
: public mozilla::TrueType {};
: public std::true_type {};
template <typename T>
struct StoreRefPtrPassByPtr {
@ -975,7 +975,7 @@ struct StoreRefPtrPassByPtr {
};
template <typename S>
struct IsParameterStorageClass<StoreRefPtrPassByPtr<S>>
: public mozilla::TrueType {};
: public std::true_type {};
template <typename T>
struct StorePtrPassByPtr {
@ -987,8 +987,7 @@ struct StorePtrPassByPtr {
passed_type PassAsParameter() { return m; }
};
template <typename S>
struct IsParameterStorageClass<StorePtrPassByPtr<S>>
: public mozilla::TrueType {};
struct IsParameterStorageClass<StorePtrPassByPtr<S>> : public std::true_type {};
template <typename T>
struct StoreConstPtrPassByConstPtr {
@ -1001,7 +1000,7 @@ struct StoreConstPtrPassByConstPtr {
};
template <typename S>
struct IsParameterStorageClass<StoreConstPtrPassByConstPtr<S>>
: public mozilla::TrueType {};
: public std::true_type {};
template <typename T>
struct StoreCopyPassByConstPtr {
@ -1014,7 +1013,7 @@ struct StoreCopyPassByConstPtr {
};
template <typename S>
struct IsParameterStorageClass<StoreCopyPassByConstPtr<S>>
: public mozilla::TrueType {};
: public std::true_type {};
template <typename T>
struct StoreCopyPassByPtr {
@ -1026,13 +1025,13 @@ struct StoreCopyPassByPtr {
passed_type PassAsParameter() { return &m; }
};
template <typename S>
struct IsParameterStorageClass<StoreCopyPassByPtr<S>>
: public mozilla::TrueType {};
struct IsParameterStorageClass<StoreCopyPassByPtr<S>> : public std::true_type {
};
namespace detail {
template <typename>
struct SFINAE1True : mozilla::TrueType {};
struct SFINAE1True : std::true_type {};
template <class T>
static auto HasRefCountMethodsTest(int)