Browse Source

Replace COMPILER_ASSERT with C++0B static_assert

Adam Johnson 12 years ago
parent
commit
3667fb62e2
  1. 2
      Sources/Plasma/Apps/plUruLauncher/Main.cpp
  2. 8
      Sources/Plasma/CoreLib/HeadSpin.h
  3. 2
      Sources/Plasma/NucleusLib/pnAsyncCore/Private/pnAcIo.h
  4. 2
      Sources/Plasma/NucleusLib/pnAsyncCoreExe/Private/W9x/pnAceW9xSocket.cpp
  5. 2
      Sources/Plasma/NucleusLib/pnAsyncCoreExe/pnAceCore.cpp
  6. 4
      Sources/Plasma/NucleusLib/pnNetBase/pnNbError.cpp
  7. 2
      Sources/Plasma/NucleusLib/pnNetCli/pnNcEncrypt.cpp
  8. 4
      Sources/Plasma/NucleusLib/pnNetProtocol/Private/Protocols/Cli2Auth/pnNpCli2Auth.h
  9. 4
      Sources/Plasma/NucleusLib/pnNetProtocol/Private/Protocols/Cli2Game/pnNpCli2Game.h
  10. 4
      Sources/Plasma/NucleusLib/pnNetProtocol/Private/Protocols/Cli2GateKeeper/pnNpCli2GateKeeper.h
  11. 2
      Sources/Plasma/NucleusLib/pnNetProtocol/Private/pnNpCommon.cpp
  12. 2
      Sources/Plasma/NucleusLib/pnProduct/Private/pnPrBranchId.cpp
  13. 2
      Sources/Plasma/NucleusLib/pnProduct/Private/pnPrBuildId.cpp
  14. 4
      Sources/Plasma/NucleusLib/pnUtils/Win32/pnUtW32Path.cpp
  15. 6
      Sources/Plasma/NucleusLib/pnUtils/Win32/pnUtW32Uuid.cpp
  16. 2
      Sources/Plasma/NucleusLib/pnUtils/pnUtTime.cpp
  17. 2
      Sources/Plasma/PubUtilLib/plNetGameLib/Intern.h
  18. 2
      Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglAuth.cpp

2
Sources/Plasma/Apps/plUruLauncher/Main.cpp

@ -208,7 +208,7 @@ static void LogV (ELogSev sev, const wchar_t fmt[], va_list args) {
{ stdout, L"Inf" },
{ stderr, L"Err" },
};
COMPILER_ASSERT(arrsize(s_log) == kNumLogSev);
static_assert(arrsize(s_log) == kNumLogSev, "Log severity array and enum have different sizes");
fwprintf (s_log[sev].file, L"%s: ", s_log[sev].pre);
vfwprintf(s_log[sev].file, fmt, args);

8
Sources/Plasma/CoreLib/HeadSpin.h

@ -297,14 +297,6 @@ typedef hsColor32 hsRGBAColor32;
# define NULL_STMT ((void)0)
#endif
//===========================================================================
// Old COMPILER_ASSERT Macro
// This DEPRECATED. Use static_assert instead!
//===========================================================================
#define COMPILER_ASSERT(expr) static_assert(expr, "old compiler assert failure")
#define COMPILER_ASSERT_HEADER(prefix,expr) static_assert(expr, "old compiler assert failure")
//===========================================================================
template<class T>
inline T max (const T & a, const T & b) {

2
Sources/Plasma/NucleusLib/pnAsyncCore/Private/pnAcIo.h

@ -171,7 +171,7 @@ enum EConnType {
kNumConnTypes
};
COMPILER_ASSERT_HEADER(EConnType, kNumConnTypes < 256);
static_assert(kNumConnTypes <= 0xFF, "EConnType overflows uint8");
#define IS_TEXT_CONNTYPE(c) \
(((int)(c)) == kConnTypeAdminInterface)

2
Sources/Plasma/NucleusLib/pnAsyncCoreExe/Private/W9x/pnAceW9xSocket.cpp

@ -583,7 +583,7 @@ void CSocket::OnWriteReady () {
&m_sendQueue[result],
m_sendQueue.Bytes() - result
);
COMPILER_ASSERT(sizeof(m_sendQueue[0]) == sizeof(uint8_t));
static_assert(sizeof(m_sendQueue[0]) == sizeof(uint8_t), "SendQueue array members are an unexpected size");
m_sendQueue.SetCount(m_sendQueue.Count() - result);
}

2
Sources/Plasma/NucleusLib/pnAsyncCoreExe/pnAceCore.cpp

@ -235,7 +235,7 @@ void AsyncSleep (unsigned sleepMs) {
//============================================================================
long AsyncPerfGetCounter (unsigned id) {
COMPILER_ASSERT(arrsize(s_perf) == kNumAsyncPerfCounters);
static_assert(arrsize(s_perf) == kNumAsyncPerfCounters, "Max async counters and array size do not match.");
ASSERT(id < kNumAsyncPerfCounters);
return s_perf[id];
}

4
Sources/Plasma/NucleusLib/pnNetBase/pnNbError.cpp

@ -105,7 +105,7 @@ const wchar_t * NetErrorToString (ENetError code) {
L"Server Busy", // kNetErrServerBusy
L"Vault Node Access Violation", // kNetErrVaultNodeAccessViolation
};
COMPILER_ASSERT(arrsize(s_errors) == kNumNetErrors);
static_assert(arrsize(s_errors) == kNumNetErrors, "Number of Net Error descriptions and total Net Error count are not equal");
if ((unsigned)code >= arrsize(s_errors)) {
if (code == kNetPending)
@ -172,7 +172,7 @@ const wchar_t * NetErrorAsString (ENetError code) {
L"kNetErrServerBusy",
L"kNetErrVaultNodeAccessViolation",
};
COMPILER_ASSERT(arrsize(s_errors) == kNumNetErrors);
static_assert(arrsize(s_errors) == kNumNetErrors, "Number of string-ized Net Errors and total Net Error count are not equal");
if ((unsigned)code >= arrsize(s_errors)) {
if (code == kNetPending)

2
Sources/Plasma/NucleusLib/pnNetCli/pnNcEncrypt.cpp

@ -78,7 +78,7 @@ namespace pnNetCli {
***/
COMPILER_ASSERT(IS_POW2(kNetDiffieHellmanKeyBits));
static_assert(IS_POW2(kNetDiffieHellmanKeyBits), "DH Key bit count is not a power of 2");
/*****************************************************************************

4
Sources/Plasma/NucleusLib/pnNetProtocol/Private/Protocols/Cli2Auth/pnNpCli2Auth.h

@ -133,7 +133,7 @@ enum {
kNumCli2AuthMessages
};
COMPILER_ASSERT_HEADER(Cli2Auth, kNumCli2AuthMessages <= (uint16_t)-1);
static_assert(kNumCli2AuthMessages <= 0xFFFF, "Cli2Auth message types overflow uint16");
enum {
// Global
@ -212,7 +212,7 @@ enum {
kNumAuth2CliMessages
};
COMPILER_ASSERT_HEADER(Cli2Auth, kNumAuth2CliMessages <= (uint16_t)-1);
static_assert(kNumAuth2CliMessages <= 0xFFFF, "Auth2Cli message types overflow uint16");
//============================================================================

4
Sources/Plasma/NucleusLib/pnNetProtocol/Private/Protocols/Cli2Game/pnNpCli2Game.h

@ -65,7 +65,7 @@ enum {
kNumCli2GameMessages
};
COMPILER_ASSERT_HEADER(Cli2Game, kNumCli2GameMessages <= (uint16_t)-1);
static_assert(kNumCli2GameMessages <= 0xFFFF, "Cli2Game message types overflow uint16");
enum {
// Global
@ -80,7 +80,7 @@ enum {
kNumGame2CliMessages
};
COMPILER_ASSERT_HEADER(Cli2Game, kNumGame2CliMessages <= (uint16_t)-1);
static_assert(kNumGame2CliMessages <= 0xFFFF, "Game2Cli message types overflow uint16");
//============================================================================

4
Sources/Plasma/NucleusLib/pnNetProtocol/Private/Protocols/Cli2GateKeeper/pnNpCli2GateKeeper.h

@ -62,7 +62,7 @@ enum {
kNumCli2GateKeeperMessages
};
COMPILER_ASSERT_HEADER(Cli2GateKeeper, kNumCli2GateKeeperMessages <= (uint16_t)-1);
static_assert(kNumCli2GateKeeperMessages <= 0xFFFF, "Cli2GateKeeper message types overflow uint16");
enum {
// Global
@ -72,7 +72,7 @@ enum {
kNumGateKeeper2CliMessages
};
COMPILER_ASSERT_HEADER(Cli2GateKeeper, kNumGateKeeper2CliMessages <= (uint16_t)-1);
static_assert(kNumGateKeeper2CliMessages <= 0xFFFF, "GateKeeper2Cli message types overflow uint16");
//============================================================================

2
Sources/Plasma/NucleusLib/pnNetProtocol/Private/pnNpCommon.cpp

@ -53,7 +53,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
namespace pnNpCommon {
// Verify our uint64_t constants were properly inited as such.
COMPILER_ASSERT(NetVaultNode::kBlob_2);
static_assert(NetVaultNode::kBlob_2, "NetVaultNode constants failed to init");

2
Sources/Plasma/NucleusLib/pnProduct/Private/pnPrBranchId.cpp

@ -60,7 +60,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
// This value is manually changed upon each branch so that client applications
// built from this branch may not connect to servers built from another.
#define BRANCH_ID 1
COMPILER_ASSERT(BRANCH_ID != 0);
static_assert(BRANCH_ID != 0, "BranchID cannot be 0");
#else

2
Sources/Plasma/NucleusLib/pnProduct/Private/pnPrBuildId.cpp

@ -58,7 +58,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
// This line must NEVER be modified manually; it is automatically updated
// by the build server.
#define BUILD_ID 912
COMPILER_ASSERT(BUILD_ID != 0);
static_assert(BUILD_ID != 0, "BuildID cannot be 0");
/*****************************************************************************

4
Sources/Plasma/NucleusLib/pnUtils/Win32/pnUtW32Path.cpp

@ -56,7 +56,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
***/
// make sure our definition is at least as big as the compiler's definition
COMPILER_ASSERT(MAX_PATH >= _MAX_PATH);
static_assert(MAX_PATH >= _MAX_PATH, "Windows and STDlib MAX_PATH constants differ");
//===========================================================================
@ -546,7 +546,7 @@ EPathCreateDirError PathCreateDirectory (const wchar_t path[], unsigned flags) {
// if we successfully created the directory then we're done
if (result) {
// Avoid check for kPathCreateDirFlagOsError
COMPILER_ASSERT(kPathCreateDirSuccess == NO_ERROR);
static_assert(kPathCreateDirSuccess == NO_ERROR, "Path creation success and NO_ERROR constants differ");
return kPathCreateDirSuccess;
}

6
Sources/Plasma/NucleusLib/pnUtils/Win32/pnUtW32Uuid.cpp

@ -51,8 +51,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#if 0
COMPILER_ASSERT(sizeof(Uuid) >= sizeof(GUID));
void Uuid::Clear()
{
UuidCreateNil( (GUID *)this );
@ -120,7 +118,7 @@ Uuid Uuid::Generate()
*
***/
COMPILER_ASSERT(sizeof(Uuid) >= sizeof(GUID));
static_assert(sizeof(Uuid) >= sizeof(GUID), "pnUtils Uuid and Win32 GUID types differ in size");
//============================================================================
Uuid GuidGenerate () {
@ -137,7 +135,7 @@ void GuidClear (Uuid * uuid) {
//============================================================================
bool GuidFromString (const wchar_t str[], Uuid * uuid) {
ASSERT(uuid);
COMPILER_ASSERT(sizeof(wchar_t) == sizeof(unsigned short));
static_assert(sizeof(wchar_t) == sizeof(unsigned short), "Wchar is not an uint16");
return RPC_S_OK == UuidFromStringW((unsigned short *) str, (GUID *) uuid);
}

2
Sources/Plasma/NucleusLib/pnUtils/pnUtTime.cpp

@ -118,7 +118,7 @@ uint32_t TimeGetSecondsSince2001Utc () {
uint64_t TimeGetTime () {
#ifdef HS_BUILD_FOR_WIN32
uint64_t time;
COMPILER_ASSERT(sizeof(uint64_t) == sizeof(FILETIME));
static_assert(sizeof(uint64_t) == sizeof(FILETIME), "FILETIME is not a uint64");
GetSystemTimeAsFileTime((FILETIME *) &time);
return time;
#else

2
Sources/Plasma/PubUtilLib/plNetGameLib/Intern.h

@ -271,7 +271,7 @@ static const char * s_transTypes[] = {
"GkAuthSrvIpAddress",
};
COMPILER_ASSERT(arrsize(s_transTypes) == kNumTransTypes);
static_assert(arrsize(s_transTypes) == kNumTransTypes, "Ngl Trans array and enum differ in size");
static long s_perfTransCount[kNumTransTypes];

2
Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglAuth.cpp

@ -4017,7 +4017,7 @@ bool VaultFindNodeTrans::Recv (
const Auth2Cli_VaultNodeFindReply & reply = *(const Auth2Cli_VaultNodeFindReply *) msg;
if (IS_NET_SUCCESS(reply.result)) {
COMPILER_ASSERT(sizeof(unsigned) == sizeof(uint32_t));
static_assert(sizeof(unsigned) == sizeof(uint32_t), "unsigned is not the same size as uint32_t");
m_nodeIds.Set((unsigned *)reply.nodeIds, reply.nodeIdCount);
}

Loading…
Cancel
Save