Преглед изворни кода

Merge pull request #1810 from Areloch/AHardTypingEnum

Force enums using unsigned values to actually hard type to U32
Areloch пре 9 година
родитељ
комит
a858fa775f

+ 6 - 1
Engine/source/T3D/gameBase/moveManager.h

@@ -36,7 +36,12 @@ class BitStream;
 
 struct Move
 {
-   enum { ChecksumBits = 16, ChecksumMask = ((1<<ChecksumBits)-1), ChecksumMismatch = U32(-1) };
+   enum : U32 
+   { 
+      ChecksumBits = 16, 
+      ChecksumMask = ((1<<ChecksumBits)-1), 
+      ChecksumMismatch = U32(-1) 
+   };
 
    // packed storage rep, set in clamp
    S32 px, py, pz;

+ 1 - 1
Engine/source/T3D/objectTypes.h

@@ -151,7 +151,7 @@ enum SceneObjectTypes
    /// @}
 };
 
-enum SceneObjectTypeMasks
+enum SceneObjectTypeMasks : U32
 {
    STATIC_COLLISION_TYPEMASK = (StaticShapeObjectType |
    EntityObjectType),

+ 1 - 1
Engine/source/console/consoleObject.h

@@ -441,7 +441,7 @@ public:
    /// @see addGroup, endGroup
    /// @see addGroup, endGroup
    /// @see addDeprecatedField
-   enum ACRFieldTypes
+   enum ACRFieldTypes : U32
    {
       /// The first custom field type... all fields
       /// types greater or equal to this one are not

+ 1 - 1
Engine/source/console/sim.h

@@ -61,7 +61,7 @@ typedef U32 SimObjectId;
 /// The RootGroupId is assigned to gRootGroup, in which most SimObjects
 /// are addded as child members. See simManager.cc for details, particularly
 /// Sim::initRoot() and following.
-enum SimObjectsConstants
+enum SimObjectsConstants : U32
 {
    DataBlockObjectIdFirst = 3,
    DataBlockObjectIdBitSize = 14,

+ 1 - 1
Engine/source/core/stream/fileStream.h

@@ -33,7 +33,7 @@
 class FileStream : public Stream
 {
 public:
-   enum
+   enum : U32
    {
       BUFFER_SIZE = 8 * 1024,       // this can be changed to anything appropriate [in k]
       BUFFER_INVALID = 0xffffffff   // file offsets must all be less than this

+ 2 - 1
Engine/source/gfx/sim/debugDraw.h

@@ -148,7 +148,8 @@ public:
    /// Set the TTL for the last item we entered...
    ///
    /// Primitives default to lasting one frame (ie, ttl=0)
-   enum {
+   enum : U32
+   {
       DD_INFINITE = U32_MAX
    };
    // How long should this primitive be draw for, 0 = one frame, DD_INFINITE = draw forever

+ 2 - 1
Engine/source/gui/controls/guiTextListCtrl.h

@@ -48,7 +48,8 @@ class GuiTextListCtrl : public GuiArrayCtrl
       UP = 0,
       DOWN = 1
    };
-   enum {
+   enum : U32
+   {
       InvalidId = 0xFFFFFFFF
    };
    Vector<S32> mColumnOffsets;

+ 1 - 1
Engine/source/math/mBoxBase.h

@@ -125,7 +125,7 @@ class BoxBase
          NUM_PLANES
       };
 
-      enum PlaneMasks
+      enum PlaneMasks : U32
       {
          PlaneMaskLeft     = ( 1 << LeftPlane ),
          PlaneMaskRight    = ( 1 << RightPlane ),

+ 1 - 1
Engine/source/math/util/frustum.h

@@ -118,7 +118,7 @@ struct FrustumData : public PolyhedronData
       };
 
       /// Used to mask out planes for testing.
-      enum 
+      enum : U32
       {
          PlaneMaskLeft     = ( 1 << PlaneLeft ),
          PlaneMaskRight    = ( 1 << PlaneRight ),

+ 2 - 1
Engine/source/platform/platformMemory.cpp

@@ -53,7 +53,8 @@ void * gMemMutex = NULL;
 #undef new
 #endif
 
-enum MemConstants {
+enum MemConstants : U32
+{
    Allocated            = BIT(0),
    Array                = BIT(1),
    DebugFlag            = BIT(2),

+ 2 - 1
Engine/source/scene/simPath.h

@@ -49,7 +49,8 @@ class Path : public SimGroup
    typedef SimGroup Parent;
 
   public:
-   enum {
+   enum : U32
+   {
       NoPathIndex = 0xFFFFFFFF
    };
 

+ 1 - 1
Engine/source/scene/zones/sceneZoneSpaceManager.h

@@ -65,7 +65,7 @@ class SceneZoneSpaceManager
       ///   of time.
       typedef Signal< void( SceneZoneSpaceManager* ) > ZoningChangedSignal;
 
-      enum
+      enum : U32
       {
          /// Zone ID of the exterior zone.
          RootZoneId = 0,

+ 1 - 1
Engine/source/sfx/sfxSoundscape.h

@@ -73,7 +73,7 @@ class SFXSoundscape
          FlagUnique        = BIT( 1 ),    ///< No other instance of this ambience on stack.
       };
       
-      enum DirtyBits
+      enum DirtyBits : U32
       {
          AmbienceDirty = BIT( 0 ),        ///< Associated ambience has changed.
          AllDirty = 0xFFFFFFFF

+ 2 - 1
Engine/source/sim/netStringTable.h

@@ -44,7 +44,8 @@ class NetStringTable
    friend class RemoteCommandEvent;
 #endif
 
-   enum Constants {
+   enum Constants : U32
+   {
       InitialSize = 16,
       InvalidEntry = 0xFFFFFFFF,
       HashTableSize = 2128,

+ 1 - 1
Engine/source/terrain/terrRender.h

@@ -27,7 +27,7 @@
 #include "terrain/terrData.h"
 #endif
 
-enum TerrConstants 
+enum TerrConstants : U32
 {
    MaxClipPlanes       = 8, ///< left, right, top, bottom - don't need far tho...
    //MaxTerrainMaterials = 256,