Bug 960848 - Part 3: Generate consts rather than enum values for nsFrameState bits for VS2010. r=dbaron,f=glandium

This commit is contained in:
Cameron McCormack 2014-02-05 13:00:03 +11:00
parent a8bfc1897b
commit 3292446211

View File

@ -14,6 +14,30 @@ typedef uint64_t nsFrameState_size_t;
#define NS_FRAME_STATE_BIT(n_) (nsFrameState(nsFrameState_size_t(1) << (n_)))
#if (_MSC_VER == 1600)
/*
* Visual Studio 2010 has trouble with the sized enum. Although sized enums
* are supported, two problems arise:
*
* 1. Implicit conversions from the enum type to the equivalently sized
* integer size are not performed, leading to many compile errors.
* 2. Even with explicit casts added to avoid the errors from (1), odd
* test failures result, which might well be due to a compiler bug.
*
* So with VS2010 we use consts for the state bits and forgo the increased
* type safety of the enum. (Visual Studio 2012 has no problem with
* nsFrameState being a sized enum, however.)
*/
typedef nsFrameState_size_t nsFrameState;
#define FRAME_STATE_BIT(group_, value_, name_) \
const nsFrameState name_ = NS_FRAME_STATE_BIT(value_);
#include "nsFrameStateBits.h"
#undef FRAME_STATE_BIT
#else
enum nsFrameState : nsFrameState_size_t {
#define FRAME_STATE_BIT(group_, value_, name_) \
name_ = NS_FRAME_STATE_BIT(value_),
@ -59,6 +83,8 @@ inline nsFrameState& operator^=(nsFrameState& aLeft, nsFrameState aRight)
return aLeft;
}
#endif
// Bits 20-31 and 60-63 of the frame state are reserved for implementations.
#define NS_FRAME_IMPL_RESERVED nsFrameState(0xF0000000FFF00000)
#define NS_FRAME_RESERVED ~NS_FRAME_IMPL_RESERVED