Bug 712936 - Convert users of PR_STATIC_ASSERT to MOZ_STATIC_ASSERT. r=jwalden

This commit is contained in:
Mark Capella 2012-04-02 17:21:24 -07:00
parent 5019ff0713
commit 38934b4912
11 changed files with 42 additions and 28 deletions

View File

@ -70,7 +70,8 @@ FramePropertyTable::Set(nsIFrame* aFrame, const FramePropertyDescriptor* aProper
// We need to expand the single current entry to an array
PropertyValue current = entry->mProp;
entry->mProp.mProperty = nsnull;
PR_STATIC_ASSERT(sizeof(nsTArray<PropertyValue>) <= sizeof(void *));
MOZ_STATIC_ASSERT(sizeof(nsTArray<PropertyValue>) <= sizeof(void *),
"Property array must fit entirely within entry->mProp.mValue");
new (&entry->mProp.mValue) nsTArray<PropertyValue>(4);
entry->mProp.ToArray()->AppendElement(current);
}

View File

@ -558,7 +558,8 @@ nsPresContext::GetFontPrefsForLang(nsIAtom *aLanguage) const
&prefs->mDefaultCursiveFont,
&prefs->mDefaultFantasyFont
};
PR_STATIC_ASSERT(NS_ARRAY_LENGTH(fontTypes) == eDefaultFont_COUNT);
MOZ_STATIC_ASSERT(NS_ARRAY_LENGTH(fontTypes) == eDefaultFont_COUNT,
"FontTypes array count is not correct");
// Get attributes specific to each generic font. We do not get the user's
// generic-font-name-to-specific-family-name preferences because its the

View File

@ -377,8 +377,9 @@ GetStatesForPseudoClass(const nsAString& aStatePseudo)
nsEventStates(),
nsEventStates()
};
PR_STATIC_ASSERT(NS_ARRAY_LENGTH(sPseudoClassStates) ==
nsCSSPseudoClasses::ePseudoClass_NotPseudoClass + 1);
MOZ_STATIC_ASSERT(NS_ARRAY_LENGTH(sPseudoClassStates) ==
nsCSSPseudoClasses::ePseudoClass_NotPseudoClass + 1,
"Length of PseudoClassStates array is incorrect");
nsCOMPtr<nsIAtom> atom = do_GetAtom(aStatePseudo);

View File

@ -1652,12 +1652,11 @@ nsNSSComponent::InitializeNSS(bool showWarningBox)
PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, ("nsNSSComponent::InitializeNSS\n"));
// If we ever run into this assertion, we must update the values
// in nsINSSErrorsService.idl
PR_STATIC_ASSERT(nsINSSErrorsService::NSS_SEC_ERROR_BASE == SEC_ERROR_BASE
&& nsINSSErrorsService::NSS_SEC_ERROR_LIMIT == SEC_ERROR_LIMIT
&& nsINSSErrorsService::NSS_SSL_ERROR_BASE == SSL_ERROR_BASE
&& nsINSSErrorsService::NSS_SSL_ERROR_LIMIT == SSL_ERROR_LIMIT);
MOZ_STATIC_ASSERT(nsINSSErrorsService::NSS_SEC_ERROR_BASE == SEC_ERROR_BASE &&
nsINSSErrorsService::NSS_SEC_ERROR_LIMIT == SEC_ERROR_LIMIT &&
nsINSSErrorsService::NSS_SSL_ERROR_BASE == SSL_ERROR_BASE &&
nsINSSErrorsService::NSS_SSL_ERROR_LIMIT == SSL_ERROR_LIMIT,
"You must update the values in nsINSSErrorsService.idl");
// variables used for flow control within this function

View File

@ -228,9 +228,10 @@ struct TelemetryHistogram {
// that if people add incorrect histogram definitions, they get compiler
// errors.
#define HISTOGRAM(id, min, max, bucket_count, histogram_type, b) \
PR_STATIC_ASSERT(nsITelemetry::HISTOGRAM_ ## histogram_type == nsITelemetry::HISTOGRAM_BOOLEAN || \
nsITelemetry::HISTOGRAM_ ## histogram_type == nsITelemetry::HISTOGRAM_FLAG || \
(min < max && bucket_count > 2 && min >= 1));
MOZ_STATIC_ASSERT(nsITelemetry::HISTOGRAM_ ## histogram_type == nsITelemetry::HISTOGRAM_BOOLEAN || \
nsITelemetry::HISTOGRAM_ ## histogram_type == nsITelemetry::HISTOGRAM_FLAG || \
(min < max && bucket_count > 2 && min >= 1), \
"Incorrect histogram definitions were found");
#include "TelemetryHistograms.h"

View File

@ -763,8 +763,9 @@ nsXULAppInfo::GetWidgetToolkit(nsACString& aResult)
// is synchronized with the const unsigned longs defined in
// xpcom/system/nsIXULRuntime.idl.
#define SYNC_ENUMS(a,b) \
PR_STATIC_ASSERT(nsIXULRuntime::PROCESS_TYPE_ ## a == \
static_cast<int>(GeckoProcessType_ ## b));
MOZ_STATIC_ASSERT(nsIXULRuntime::PROCESS_TYPE_ ## a == \
static_cast<int>(GeckoProcessType_ ## b), \
"GeckoProcessType in nsXULAppAPI.h not synchronized with nsIXULRuntime.idl");
SYNC_ENUMS(DEFAULT, Default)
SYNC_ENUMS(PLUGIN, Plugin)
@ -772,7 +773,8 @@ SYNC_ENUMS(CONTENT, Content)
SYNC_ENUMS(IPDLUNITTEST, IPDLUnitTest)
// .. and ensure that that is all of them:
PR_STATIC_ASSERT(GeckoProcessType_IPDLUnitTest + 1 == GeckoProcessType_End);
MOZ_STATIC_ASSERT(GeckoProcessType_IPDLUnitTest + 1 == GeckoProcessType_End,
"Did not find the final GeckoProcessType");
NS_IMETHODIMP
nsXULAppInfo::GetProcessType(PRUint32* aResult)

View File

@ -301,8 +301,10 @@ MapsReporter::ParseMapping(
{
// We need to use native types in order to get good warnings from fscanf, so
// let's make sure that the native types have the sizes we expect.
PR_STATIC_ASSERT(sizeof(long long) == sizeof(PRInt64));
PR_STATIC_ASSERT(sizeof(int) == sizeof(PRInt32));
MOZ_STATIC_ASSERT(sizeof(long long) == sizeof(PRInt64),
"size of (long long) is expected to match (PRInt64)");
MOZ_STATIC_ASSERT(sizeof(int) == sizeof(PRInt32),
"size of (int) is expected to match (PRInt32)");
// Don't bail if FindLibxul fails. We can still gather meaningful stats
// here.
@ -482,7 +484,8 @@ MapsReporter::ParseMapBody(
nsISupports *aClosure,
CategoriesSeen *aCategoriesSeen)
{
PR_STATIC_ASSERT(sizeof(long long) == sizeof(PRInt64));
MOZ_STATIC_ASSERT(sizeof(long long) == sizeof(PRInt64),
"size of (long long) is expected to match (PRInt64)");
const int argCount = 2;

View File

@ -48,6 +48,8 @@
#include "prlog.h"
#include "nsXREAppData.h"
#include "mozilla/Assertions.h"
/**
* A directory service key which provides the platform-correct "application
* data" directory as follows, where $name and $vendor are as defined above and
@ -363,10 +365,12 @@ static const char* const kGeckoProcessTypeString[] = {
"ipdlunittest"
};
PR_STATIC_ASSERT(sizeof(kGeckoProcessTypeString) /
sizeof(kGeckoProcessTypeString[0]) ==
GeckoProcessType_End);
// Oddly, NS_ARRAY_LENGTH causes an internal compiler error with MSVC10, so
// compute the length manually.
MOZ_STATIC_ASSERT(sizeof(kGeckoProcessTypeString) /
sizeof(kGeckoProcessTypeString[0]) ==
GeckoProcessType_End,
"Array length mismatch");
XRE_API(const char*,
XRE_ChildProcessTypeToString, (GeckoProcessType aProcessType))

View File

@ -113,7 +113,8 @@ template <class T, PRUint32 K> class nsExpirationTracker {
nsExpirationTracker(PRUint32 aTimerPeriod)
: mTimerPeriod(aTimerPeriod), mNewestGeneration(0),
mInAgeOneGeneration(false) {
PR_STATIC_ASSERT(K >= 2 && K <= nsExpirationState::NOT_TRACKED);
MOZ_STATIC_ASSERT(K >= 2 && K <= nsExpirationState::NOT_TRACKED,
"Unsupported number of generations (must be 2 <= K <= 15)");
mObserver = new ExpirationTrackerObserver();
mObserver->Init(this);
}

View File

@ -1100,10 +1100,10 @@ private:
#if defined(HAVE_CPP_CHAR16_T) || defined(HAVE_CPP_2BYTE_WCHAR_T)
#if defined(HAVE_CPP_CHAR16_T)
PR_STATIC_ASSERT(sizeof(char16_t) == 2);
MOZ_STATIC_ASSERT(sizeof(char16_t) == 2, "size of char16_t must be 2");
#define NS_LL(s) u##s
#else
PR_STATIC_ASSERT(sizeof(wchar_t) == 2);
MOZ_STATIC_ASSERT(sizeof(wchar_t) == 2, "size of wchar_t must be 2");
#define NS_LL(s) L##s
#endif
#define NS_MULTILINE_LITERAL_STRING(s) nsDependentString(reinterpret_cast<const nsAString::char_type*>(s), PRUint32((sizeof(s)/2)-1))
@ -1119,7 +1119,7 @@ private:
#endif
/* Check that PRUnichar is unsigned */
PR_STATIC_ASSERT(PRUnichar(-1) > PRUnichar(0));
MOZ_STATIC_ASSERT(PRUnichar(-1) > PRUnichar(0), "PRUnichar is by definition an unsigned type");
/*
* Macro arguments used in concatenation or stringification won't be expanded.

View File

@ -344,4 +344,5 @@ nsStringBuffer::SizeOfIncludingThisIfUnshared(nsMallocSizeOfFun aMallocSizeOf) c
#include "prlog.h"
#include "nsXPCOMStrings.h"
PR_STATIC_ASSERT(sizeof(nsStringContainer_base) == sizeof(nsSubstring));
MOZ_STATIC_ASSERT(sizeof(nsStringContainer_base) == sizeof(nsSubstring),
"internal and external strings must have the same size");