diff --git a/dom/canvas/CanvasGradient.h b/dom/canvas/CanvasGradient.h index 00fbb257e27..8bcf7dfaa0c 100644 --- a/dom/canvas/CanvasGradient.h +++ b/dom/canvas/CanvasGradient.h @@ -23,10 +23,10 @@ public: NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(CanvasGradient) NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(CanvasGradient) - MOZ_BEGIN_NESTED_ENUM_CLASS(Type, uint8_t) + enum class Type : uint8_t { LINEAR = 0, RADIAL - MOZ_END_NESTED_ENUM_CLASS(Type) + }; Type GetType() { @@ -75,8 +75,6 @@ protected: virtual ~CanvasGradient() {} }; -MOZ_FINISH_NESTED_ENUM_CLASS(CanvasGradient::Type) - } // namespace dom } // namespace mozilla diff --git a/dom/canvas/CanvasPattern.h b/dom/canvas/CanvasPattern.h index 9fc171d3cef..93d52ef3050 100644 --- a/dom/canvas/CanvasPattern.h +++ b/dom/canvas/CanvasPattern.h @@ -29,12 +29,12 @@ public: NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(CanvasPattern) NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(CanvasPattern) - MOZ_BEGIN_NESTED_ENUM_CLASS(RepeatMode, uint8_t) + enum class RepeatMode : uint8_t { REPEAT, REPEATX, REPEATY, NOREPEAT - MOZ_END_NESTED_ENUM_CLASS(RepeatMode) + }; CanvasPattern(CanvasRenderingContext2D* aContext, gfx::SourceSurface* aSurface, @@ -74,8 +74,6 @@ public: const RepeatMode mRepeat; }; -MOZ_FINISH_NESTED_ENUM_CLASS(CanvasPattern::RepeatMode) - } } diff --git a/dom/canvas/CanvasRenderingContext2D.h b/dom/canvas/CanvasRenderingContext2D.h index 144800df77f..152eaf0cdd3 100644 --- a/dom/canvas/CanvasRenderingContext2D.h +++ b/dom/canvas/CanvasRenderingContext2D.h @@ -543,17 +543,17 @@ public: NS_DECL_CYCLE_COLLECTION_SKIPPABLE_SCRIPT_HOLDER_CLASS(CanvasRenderingContext2D) - MOZ_BEGIN_NESTED_ENUM_CLASS(CanvasMultiGetterType, uint8_t) + enum class CanvasMultiGetterType : uint8_t { STRING = 0, PATTERN = 1, GRADIENT = 2 - MOZ_END_NESTED_ENUM_CLASS(CanvasMultiGetterType) + }; - MOZ_BEGIN_NESTED_ENUM_CLASS(Style, uint8_t) + enum class Style : uint8_t { STROKE = 0, FILL, MAX - MOZ_END_NESTED_ENUM_CLASS(Style) + }; nsINode* GetParentObject() { @@ -891,31 +891,29 @@ protected: // text -public: // These enums are public only to accomodate non-C++11 legacy path of - // MOZ_FINISH_NESTED_ENUM_CLASS. Can move back to protected as soon - // as that legacy path is dropped. - MOZ_BEGIN_NESTED_ENUM_CLASS(TextAlign, uint8_t) +protected: + enum class TextAlign : uint8_t { START, END, LEFT, RIGHT, CENTER - MOZ_END_NESTED_ENUM_CLASS(TextAlign) + }; - MOZ_BEGIN_NESTED_ENUM_CLASS(TextBaseline, uint8_t) + enum class TextBaseline : uint8_t { TOP, HANGING, MIDDLE, ALPHABETIC, IDEOGRAPHIC, BOTTOM - MOZ_END_NESTED_ENUM_CLASS(TextBaseline) + }; - MOZ_BEGIN_NESTED_ENUM_CLASS(TextDrawOperation, uint8_t) + enum class TextDrawOperation : uint8_t { FILL, STROKE, MEASURE - MOZ_END_NESTED_ENUM_CLASS(TextDrawOperation) + }; protected: gfxFontGroup *GetCurrentFontStyle(); @@ -1104,12 +1102,6 @@ protected: friend class CanvasDrawObserver; }; -MOZ_FINISH_NESTED_ENUM_CLASS(CanvasRenderingContext2D::CanvasMultiGetterType) -MOZ_FINISH_NESTED_ENUM_CLASS(CanvasRenderingContext2D::Style) -MOZ_FINISH_NESTED_ENUM_CLASS(CanvasRenderingContext2D::TextAlign) -MOZ_FINISH_NESTED_ENUM_CLASS(CanvasRenderingContext2D::TextBaseline) -MOZ_FINISH_NESTED_ENUM_CLASS(CanvasRenderingContext2D::TextDrawOperation) - } } diff --git a/dom/canvas/WebGLTexelConversions.cpp b/dom/canvas/WebGLTexelConversions.cpp index 99b177e6bfb..84be38c30d0 100644 --- a/dom/canvas/WebGLTexelConversions.cpp +++ b/dom/canvas/WebGLTexelConversions.cpp @@ -37,7 +37,7 @@ class WebGLImageConverter * texels with typed pointers and this value will tell us by how much we need * to increment these pointers to advance to the next texel. */ - template + template static size_t NumElementsPerTexelForFormat() { switch (Format) { case WebGLTexelFormat::R8: @@ -78,9 +78,9 @@ class WebGLImageConverter * to return immediately in these cases to allow the compiler to avoid generating * useless code. */ - template + template void run() { // check for never-called cases. We early-return to allow the compiler @@ -151,9 +151,9 @@ class WebGLImageConverter typename DataTypeForFormat::Type DstType; - const MOZ_ENUM_CLASS_ENUM_TYPE(WebGLTexelFormat) IntermediateSrcFormat + const WebGLTexelFormat IntermediateSrcFormat = IntermediateFormat::Value; - const MOZ_ENUM_CLASS_ENUM_TYPE(WebGLTexelFormat) IntermediateDstFormat + const WebGLTexelFormat IntermediateDstFormat = IntermediateFormat::Value; typedef typename DataTypeForFormat::Type @@ -218,8 +218,8 @@ class WebGLImageConverter return; } - template + template void run(WebGLTexelPremultiplicationOp premultiplicationOp) { #define WEBGLIMAGECONVERTER_CASE_PREMULTIPLICATIONOP(PremultiplicationOp) \ @@ -237,7 +237,7 @@ class WebGLImageConverter #undef WEBGLIMAGECONVERTER_CASE_PREMULTIPLICATIONOP } - template + template void run(WebGLTexelFormat dstFormat, WebGLTexelPremultiplicationOp premultiplicationOp) { diff --git a/dom/canvas/WebGLTexelConversions.h b/dom/canvas/WebGLTexelConversions.h index 97a4f5b60d5..813b1e8c0b7 100644 --- a/dom/canvas/WebGLTexelConversions.h +++ b/dom/canvas/WebGLTexelConversions.h @@ -155,7 +155,7 @@ enum class WebGLTexelPremultiplicationOp : int { namespace WebGLTexelConversions { -template +template struct IsFloatFormat { static const bool Value = @@ -166,7 +166,7 @@ struct IsFloatFormat Format == WebGLTexelFormat::A32F; }; -template +template struct IsHalfFloatFormat { static const bool Value = @@ -177,7 +177,7 @@ struct IsHalfFloatFormat Format == WebGLTexelFormat::A16F; }; -template +template struct Is16bppFormat { static const bool Value = @@ -186,7 +186,7 @@ struct Is16bppFormat Format == WebGLTexelFormat::RGB565; }; -template::Value, bool Is16bpp = Is16bppFormat::Value, bool IsHalfFloat = IsHalfFloatFormat::Value> @@ -195,28 +195,28 @@ struct DataTypeForFormat typedef uint8_t Type; }; -template +template struct DataTypeForFormat { typedef float Type; }; -template +template struct DataTypeForFormat { typedef uint16_t Type; }; -template +template struct DataTypeForFormat { typedef uint16_t Type; }; -template +template struct IntermediateFormat { - static const MOZ_ENUM_CLASS_ENUM_TYPE(WebGLTexelFormat) Value + static const WebGLTexelFormat Value = IsFloatFormat::Value ? WebGLTexelFormat::RGBA32F : IsHalfFloatFormat::Value ? WebGLTexelFormat::RGBA16F @@ -332,7 +332,7 @@ MOZ_ALWAYS_INLINE bool HasColor(WebGLTexelFormat format) { //---------------------------------------------------------------------- // Pixel unpacking routines. -template +template MOZ_ALWAYS_INLINE void unpack(const SrcType* __restrict src, DstType* __restrict dst) @@ -537,8 +537,8 @@ unpack(const uint16_t* __restrict sr // Pixel packing routines. // -template MOZ_ALWAYS_INLINE void diff --git a/dom/media/MediaDecoderStateMachine.h b/dom/media/MediaDecoderStateMachine.h index 5b463de0e21..002cae06729 100644 --- a/dom/media/MediaDecoderStateMachine.h +++ b/dom/media/MediaDecoderStateMachine.h @@ -1025,11 +1025,11 @@ protected: bool mIsAudioPrerolling; bool mIsVideoPrerolling; - MOZ_BEGIN_NESTED_ENUM_CLASS(RequestStatus) + enum class RequestStatus { Idle, Pending, Waiting - MOZ_END_NESTED_ENUM_CLASS(RequestStatus) + }; // True when we have dispatched a task to the decode task queue to request // decoded audio/video, and/or we are waiting for the requested sample to be diff --git a/gfx/ipc/GfxMessageUtils.h b/gfx/ipc/GfxMessageUtils.h index 114857693c7..6fed7a627ec 100644 --- a/gfx/ipc/GfxMessageUtils.h +++ b/gfx/ipc/GfxMessageUtils.h @@ -198,7 +198,7 @@ struct ParamTraits template <> struct ParamTraits - : public ContiguousTypedEnumSerializer< + : public ContiguousEnumSerializer< gfxContentType, gfxContentType::COLOR, gfxContentType::SENTINEL> @@ -206,7 +206,7 @@ struct ParamTraits template <> struct ParamTraits - : public ContiguousTypedEnumSerializer< + : public ContiguousEnumSerializer< gfxSurfaceType, gfxSurfaceType::Image, gfxSurfaceType::Max> @@ -222,7 +222,7 @@ struct ParamTraits template <> struct ParamTraits - : public ContiguousTypedEnumSerializer< + : public ContiguousEnumSerializer< mozilla::layers::LayersBackend, mozilla::layers::LayersBackend::LAYERS_NONE, mozilla::layers::LayersBackend::LAYERS_LAST> @@ -230,7 +230,7 @@ struct ParamTraits template <> struct ParamTraits - : public ContiguousTypedEnumSerializer< + : public ContiguousEnumSerializer< mozilla::layers::ScaleMode, mozilla::layers::ScaleMode::SCALE_NONE, mozilla::layers::ScaleMode::SENTINEL> @@ -238,7 +238,7 @@ struct ParamTraits template <> struct ParamTraits - : public ContiguousTypedEnumSerializer< + : public ContiguousEnumSerializer< gfxImageFormat, gfxImageFormat::ARGB32, gfxImageFormat::Unknown> @@ -254,7 +254,7 @@ struct ParamTraits template <> struct ParamTraits - : public ContiguousTypedEnumSerializer< + : public ContiguousEnumSerializer< mozilla::gfx::AttributeType, mozilla::gfx::AttributeType::eBool, mozilla::gfx::AttributeType::Max> @@ -262,7 +262,7 @@ struct ParamTraits template <> struct ParamTraits - : public ContiguousTypedEnumSerializer< + : public ContiguousEnumSerializer< mozilla::gfx::PrimitiveType, mozilla::gfx::PrimitiveType::Empty, mozilla::gfx::PrimitiveType::Max> @@ -270,7 +270,7 @@ struct ParamTraits template <> struct ParamTraits - : public ContiguousTypedEnumSerializer< + : public ContiguousEnumSerializer< mozilla::gfx::ColorSpace, mozilla::gfx::ColorSpace::SRGB, mozilla::gfx::ColorSpace::Max> @@ -278,14 +278,14 @@ struct ParamTraits template <> struct ParamTraits - : public BitFlagsTypedEnumSerializer< + : public BitFlagsEnumSerializer< mozilla::layers::TextureFlags, mozilla::layers::TextureFlags::ALL_BITS> {}; template <> struct ParamTraits - : public ContiguousTypedEnumSerializer< + : public ContiguousEnumSerializer< mozilla::layers::TextureIdentifier, mozilla::layers::TextureIdentifier::Front, mozilla::layers::TextureIdentifier::HighBound> @@ -293,14 +293,14 @@ struct ParamTraits template <> struct ParamTraits - : public BitFlagsTypedEnumSerializer< + : public BitFlagsEnumSerializer< mozilla::layers::DeprecatedTextureHostFlags, mozilla::layers::DeprecatedTextureHostFlags::ALL_BITS> {}; template <> struct ParamTraits - : public BitFlagsTypedEnumSerializer< + : public BitFlagsEnumSerializer< mozilla::layers::DiagnosticTypes, mozilla::layers::DiagnosticTypes::ALL_BITS> {}; @@ -854,7 +854,7 @@ struct ParamTraits template <> struct ParamTraits - : public ContiguousTypedEnumSerializer< + : public ContiguousEnumSerializer< mozilla::layers::CompositableType, mozilla::layers::CompositableType::UNKNOWN, mozilla::layers::CompositableType::COUNT> @@ -862,7 +862,7 @@ struct ParamTraits template <> struct ParamTraits - : public ContiguousTypedEnumSerializer< + : public ContiguousEnumSerializer< mozilla::gfx::SurfaceFormat, mozilla::gfx::SurfaceFormat::B8G8R8A8, mozilla::gfx::SurfaceFormat::UNKNOWN> diff --git a/gfx/layers/client/TextureClient.h b/gfx/layers/client/TextureClient.h index e52d9ad0754..c5097186266 100644 --- a/gfx/layers/client/TextureClient.h +++ b/gfx/layers/client/TextureClient.h @@ -89,9 +89,9 @@ public: static TemporaryRef CreateSyncObject(SyncHandle aHandle); - MOZ_BEGIN_NESTED_ENUM_CLASS(SyncType) + enum class SyncType { D3D11, - MOZ_END_NESTED_ENUM_CLASS(SyncType) + }; virtual SyncType GetSyncType() = 0; virtual void FinalizeFrame() = 0; diff --git a/gfx/thebes/gfxPrefs.h b/gfx/thebes/gfxPrefs.h index 3271af05dc8..47c89cf828d 100644 --- a/gfx/thebes/gfxPrefs.h +++ b/gfx/thebes/gfxPrefs.h @@ -78,14 +78,14 @@ private: private: // Enums for the update policy. - MOZ_BEGIN_NESTED_ENUM_CLASS(UpdatePolicy) + enum class UpdatePolicy { Skip, // Set the value to default, skip any Preferences calls Once, // Evaluate the preference once, unchanged during the session Live // Evaluate the preference and set callback so it stays current/live - MOZ_END_NESTED_ENUM_CLASS(UpdatePolicy) + }; // Since we cannot use const char*, use a function that returns it. - template + template class PrefTemplate { public: diff --git a/ipc/glue/IPCMessageUtils.h b/ipc/glue/IPCMessageUtils.h index 60336217fa0..02ecc742149 100644 --- a/ipc/glue/IPCMessageUtils.h +++ b/ipc/glue/IPCMessageUtils.h @@ -129,18 +129,7 @@ struct EnumSerializer { template -struct ContiguousEnumValidator -{ - static bool IsLegalValue(E e) - { - return MinLegal <= e && e < HighBound; - } -}; - -template -class ContiguousTypedEnumValidator +class ContiguousEnumValidator { // Silence overzealous -Wtype-limits bug in GCC fixed in GCC 4.8: // "comparison of unsigned expression >= 0 is always true" @@ -151,9 +140,7 @@ class ContiguousTypedEnumValidator public: static bool IsLegalValue(E e) { - typedef MOZ_TEMPLATE_ENUM_CLASS_ENUM_TYPE(E) ActualEnumType; - return IsLessThanOrEqual(MinLegal, ActualEnumType(e)) && - ActualEnumType(e) < HighBound; + return IsLessThanOrEqual(MinLegal, e) && e < HighBound; } }; @@ -167,16 +154,6 @@ struct BitFlagsEnumValidator } }; -template -struct BitFlagsTypedEnumValidator -{ - static bool IsLegalValue(E e) - { - return (e & AllBits) == e; - } -}; - /** * Specialization of EnumSerializer for enums with contiguous enum values. * @@ -201,19 +178,6 @@ struct ContiguousEnumSerializer ContiguousEnumValidator> {}; -/** - * Similar to ContiguousEnumSerializer, but for MFBT typed enums - * as constructed by MOZ_BEGIN_ENUM_CLASS. This can go away when - * we drop MOZ_BEGIN_ENUM_CLASS and use C++11 enum classes directly. - */ -template -struct ContiguousTypedEnumSerializer - : EnumSerializer> -{}; - /** * Specialization of EnumSerializer for enums representing bit flags. * @@ -241,18 +205,6 @@ struct BitFlagsEnumSerializer BitFlagsEnumValidator> {}; -/** - * Similar to BitFlagsEnumSerializer, but for MFBT typed enums - * as constructed by MOZ_BEGIN_ENUM_CLASS. This can go away when - * we drop MOZ_BEGIN_ENUM_CLASS and use C++11 enum classes directly. - */ -template -struct BitFlagsTypedEnumSerializer - : EnumSerializer> -{}; - template <> struct ParamTraits : public ContiguousEnumSerializer /* static */ bool nsLayoutUtils::PointIsCloserToRect(PointType aPoint, const RectType& aRect, diff --git a/mfbt/EnumeratedArray.h b/mfbt/EnumeratedArray.h index 470d5f5e8d1..daac9b08629 100644 --- a/mfbt/EnumeratedArray.h +++ b/mfbt/EnumeratedArray.h @@ -16,8 +16,7 @@ namespace mozilla { /** * EnumeratedArray is a fixed-size array container for use when an - * array is indexed by a specific enum class, as currently implemented - * by MOZ_BEGIN_ENUM_CLASS. + * array is indexed by a specific enum class. * * This provides type safety by guarding at compile time against accidentally * indexing such arrays with unrelated values. This also removes the need @@ -40,7 +39,7 @@ namespace mozilla { * */ template class EnumeratedArray { diff --git a/xpcom/base/CycleCollectedJSRuntime.h b/xpcom/base/CycleCollectedJSRuntime.h index c3bf60b30c4..0591774f749 100644 --- a/xpcom/base/CycleCollectedJSRuntime.h +++ b/xpcom/base/CycleCollectedJSRuntime.h @@ -212,7 +212,7 @@ private: public: // Two conditions, JSOutOfMemory and JSLargeAllocationFailure, are noted in // crash reports. Here are the values that can appear in the reports: - MOZ_BEGIN_NESTED_ENUM_CLASS(OOMState, uint32_t) + enum class OOMState : uint32_t { // The condition has never happened. No entry appears in the crash report. OK, @@ -240,7 +240,7 @@ public: // GC is taken as a proxy for "we've been banging on the heap a good bit // now and haven't crashed; the OOM was probably handled correctly". Recovered - MOZ_END_NESTED_ENUM_CLASS(OOMState) + }; private: void AnnotateAndSetOutOfMemory(OOMState* aStatePtr, OOMState aNewState); @@ -316,8 +316,6 @@ private: OOMState mLargeAllocationFailureState; }; -MOZ_FINISH_NESTED_ENUM_CLASS(CycleCollectedJSRuntime::OOMState) - void TraceScriptHolder(nsISupports* aHolder, JSTracer* aTracer); // Returns true if the JSGCTraceKind is one the cycle collector cares about. diff --git a/xpcom/glue/EnumeratedArrayCycleCollection.h b/xpcom/glue/EnumeratedArrayCycleCollection.h index ac5469a202a..faabb5a529d 100644 --- a/xpcom/glue/EnumeratedArrayCycleCollection.h +++ b/xpcom/glue/EnumeratedArrayCycleCollection.h @@ -11,7 +11,7 @@ #include "nsCycleCollectionTraversalCallback.h" template inline void ImplCycleCollectionUnlink(mozilla::EnumeratedArray inline void ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback,