Bug 928741 - Stop using PR_STATIC_ASSERT in content; r=jst

This commit is contained in:
Ms2ger 2013-11-11 09:03:59 +01:00
parent 2d2f7fa030
commit 18114993ff
11 changed files with 60 additions and 30 deletions

View File

@ -170,7 +170,9 @@ enum {
};
// Make sure we have space for our bits
#define ASSERT_NODE_FLAGS_SPACE(n) PR_STATIC_ASSERT(WRAPPER_CACHE_FLAGS_BITS_USED + (n) <= 32)
#define ASSERT_NODE_FLAGS_SPACE(n) \
static_assert(WRAPPER_CACHE_FLAGS_BITS_USED + (n) <= 32, \
"Not enough space for our bits")
ASSERT_NODE_FLAGS_SPACE(NODE_TYPE_SPECIFIC_BITS_OFFSET);
/**
@ -1309,22 +1311,26 @@ private:
};
void SetBoolFlag(BooleanFlag name, bool value) {
PR_STATIC_ASSERT(BooleanFlagCount <= 8*sizeof(mBoolFlags));
static_assert(BooleanFlagCount <= 8*sizeof(mBoolFlags),
"Too many boolean flags");
mBoolFlags = (mBoolFlags & ~(1 << name)) | (value << name);
}
void SetBoolFlag(BooleanFlag name) {
PR_STATIC_ASSERT(BooleanFlagCount <= 8*sizeof(mBoolFlags));
static_assert(BooleanFlagCount <= 8*sizeof(mBoolFlags),
"Too many boolean flags");
mBoolFlags |= (1 << name);
}
void ClearBoolFlag(BooleanFlag name) {
PR_STATIC_ASSERT(BooleanFlagCount <= 8*sizeof(mBoolFlags));
static_assert(BooleanFlagCount <= 8*sizeof(mBoolFlags),
"Too many boolean flags");
mBoolFlags &= ~(1 << name);
}
bool GetBoolFlag(BooleanFlag name) const {
PR_STATIC_ASSERT(BooleanFlagCount <= 8*sizeof(mBoolFlags));
static_assert(BooleanFlagCount <= 8*sizeof(mBoolFlags),
"Too many boolean flags");
return mBoolFlags & (1 << name);
}

View File

@ -9038,7 +9038,8 @@ void
nsIDocument::WarnOnceAbout(DeprecatedOperations aOperation,
bool asError /* = false */)
{
PR_STATIC_ASSERT(eDeprecatedOperationCount <= 64);
static_assert(eDeprecatedOperationCount <= 64,
"Too many deprecated operations");
if (mWarnedAbout & (1ull << aOperation)) {
return;
}

View File

@ -1,4 +1,5 @@
/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
@ -167,10 +168,14 @@ nsDOMDataTransfer::SetEffectAllowed(const nsAString& aEffectAllowed)
return NS_OK;
}
PR_STATIC_ASSERT(nsIDragService::DRAGDROP_ACTION_NONE == 0);
PR_STATIC_ASSERT(nsIDragService::DRAGDROP_ACTION_COPY == 1);
PR_STATIC_ASSERT(nsIDragService::DRAGDROP_ACTION_MOVE == 2);
PR_STATIC_ASSERT(nsIDragService::DRAGDROP_ACTION_LINK == 4);
static_assert(nsIDragService::DRAGDROP_ACTION_NONE == 0,
"DRAGDROP_ACTION_NONE constant is wrong");
static_assert(nsIDragService::DRAGDROP_ACTION_COPY == 1,
"DRAGDROP_ACTION_COPY constant is wrong");
static_assert(nsIDragService::DRAGDROP_ACTION_MOVE == 2,
"DRAGDROP_ACTION_MOVE constant is wrong");
static_assert(nsIDragService::DRAGDROP_ACTION_LINK == 4,
"DRAGDROP_ACTION_LINK constant is wrong");
for (uint32_t e = 0; e < ArrayLength(sEffects); e++) {
if (aEffectAllowed.EqualsASCII(sEffects[e])) {

View File

@ -34,7 +34,7 @@ enum FormControlsTypes {
// Elements with different types, the value is used as a mask.
// Adding '_ELEMENT' because NS_FORM_INPUT is used for 'oninput' event.
// When changing the order, adding or removing elements, be sure to update
// the PR_STATIC_ASSERT checks accordingly.
// the static_assert checks accordingly.
NS_FORM_BUTTON_ELEMENT = 0x40, // 0b01000000
NS_FORM_INPUT_ELEMENT = 0x80 // 0b10000000
};
@ -69,9 +69,14 @@ enum InputElementTypes {
eInputElementTypesMax
};
PR_STATIC_ASSERT((uint32_t)eFormControlsWithoutSubTypesMax < (uint32_t)NS_FORM_BUTTON_ELEMENT);
PR_STATIC_ASSERT((uint32_t)eButtonElementTypesMax < (uint32_t)NS_FORM_INPUT_ELEMENT);
PR_STATIC_ASSERT((uint32_t)eInputElementTypesMax < 1<<8);
static_assert(static_cast<uint32_t>(eFormControlsWithoutSubTypesMax) <
static_cast<uint32_t>(NS_FORM_BUTTON_ELEMENT),
"Too many FormControlsTypes without sub-types");
static_assert(static_cast<uint32_t>(eButtonElementTypesMax) <
static_cast<uint32_t>(NS_FORM_INPUT_ELEMENT),
"Too many ButtonElementTypes");
static_assert(static_cast<uint32_t>(eInputElementTypesMax) < 1<<8,
"Too many form control types");
#define NS_IFORMCONTROL_IID \
{ 0x4b89980c, 0x4dcd, 0x428f, \

View File

@ -223,7 +223,8 @@ HTMLFrameSetElement::ParseRowCol(const nsAString & aValue,
spec.Trim(",");
// Count the commas. Don't count more than X commas (bug 576447).
PR_STATIC_ASSERT(NS_MAX_FRAMESET_SPEC_COUNT * sizeof(nsFramesetSpec) < (1 << 30));
static_assert(NS_MAX_FRAMESET_SPEC_COUNT * sizeof(nsFramesetSpec) < (1 << 30),
"Too many frameset specs allowed to allocate");
int32_t commaX = spec.FindChar(sComma);
int32_t count = 1;
while (commaX != kNotFound && count < NS_MAX_FRAMESET_SPEC_COUNT) {

View File

@ -24,9 +24,12 @@ using layers::PlanarYCbCrData;
// Verify these values are sane. Once we've checked the frame sizes, we then
// can do less integer overflow checking.
PR_STATIC_ASSERT(MAX_VIDEO_WIDTH < PlanarYCbCrImage::MAX_DIMENSION);
PR_STATIC_ASSERT(MAX_VIDEO_HEIGHT < PlanarYCbCrImage::MAX_DIMENSION);
PR_STATIC_ASSERT(PlanarYCbCrImage::MAX_DIMENSION < UINT32_MAX / PlanarYCbCrImage::MAX_DIMENSION);
static_assert(MAX_VIDEO_WIDTH < PlanarYCbCrImage::MAX_DIMENSION,
"MAX_VIDEO_WIDTH is too large");
static_assert(MAX_VIDEO_HEIGHT < PlanarYCbCrImage::MAX_DIMENSION,
"MAX_VIDEO_HEIGHT is too large");
static_assert(PlanarYCbCrImage::MAX_DIMENSION < UINT32_MAX / PlanarYCbCrImage::MAX_DIMENSION,
"MAX_DIMENSION*MAX_DIMENSION doesn't fit in 32 bits");
// Un-comment to enable logging of seek bisections.
//#define SEEK_LOGGING

View File

@ -89,7 +89,8 @@ static const int64_t LOW_DATA_THRESHOLD_USECS = 5000000;
// LOW_DATA_THRESHOLD_USECS needs to be greater than AMPLE_AUDIO_USECS, otherwise
// the skip-to-keyframe logic can activate when we're running low on data.
PR_STATIC_ASSERT(LOW_DATA_THRESHOLD_USECS > AMPLE_AUDIO_USECS);
static_assert(LOW_DATA_THRESHOLD_USECS > AMPLE_AUDIO_USECS,
"LOW_DATA_THRESHOLD_USECS is too small");
// Amount of excess usecs of data to add in to the "should we buffer" calculation.
static const uint32_t EXHAUSTED_DATA_MARGIN_USECS = 60000;
@ -113,7 +114,8 @@ static const uint32_t QUICK_BUFFERING_LOW_DATA_USECS = 1000000;
// quick buffering in a timely fashion, as the decode pauses when it
// reaches AMPLE_AUDIO_USECS decoded data, and thus we'll never reach
// QUICK_BUFFERING_LOW_DATA_USECS.
PR_STATIC_ASSERT(QUICK_BUFFERING_LOW_DATA_USECS <= AMPLE_AUDIO_USECS);
static_assert(QUICK_BUFFERING_LOW_DATA_USECS <= AMPLE_AUDIO_USECS,
"QUICK_BUFFERING_LOW_DATA_USECS is too large");
// This value has been chosen empirically.
static const uint32_t AUDIOSTREAM_MIN_WRITE_BEFORE_START_USECS = 200000;

View File

@ -6,6 +6,7 @@
#include "SVGPathSegUtils.h"
#include "gfx2DGlue.h"
#include "mozilla/Util.h" // MOZ_ARRAY_LENGTH
#include "nsSVGPathDataParser.h"
#include "nsTextFormatter.h"
@ -20,9 +21,11 @@ static const uint32_t MAX_RECURSION = 10;
SVGPathSegUtils::GetValueAsString(const float* aSeg, nsAString& aValue)
{
// Adding new seg type? Is the formatting below acceptable for the new types?
PR_STATIC_ASSERT(NS_SVG_PATH_SEG_LAST_VALID_TYPE ==
PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL);
PR_STATIC_ASSERT(NS_SVG_PATH_SEG_MAX_ARGS == 7);
static_assert(NS_SVG_PATH_SEG_LAST_VALID_TYPE ==
PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL,
"Update GetValueAsString for the new value.");
static_assert(NS_SVG_PATH_SEG_MAX_ARGS == 7,
"Add another case to the switch below.");
uint32_t type = DecodeType(aSeg[0]);
PRUnichar typeAsChar = GetPathSegTypeAsLetter(type);
@ -439,8 +442,9 @@ static TraverseFunc gTraverseFuncTable[NS_SVG_PATH_SEG_TYPE_COUNT] = {
SVGPathSegUtils::TraversePathSegment(const float* aData,
SVGPathTraversalState& aState)
{
PR_STATIC_ASSERT(NS_ARRAY_LENGTH(gTraverseFuncTable) ==
NS_SVG_PATH_SEG_TYPE_COUNT);
static_assert(MOZ_ARRAY_LENGTH(gTraverseFuncTable) ==
NS_SVG_PATH_SEG_TYPE_COUNT,
"gTraverseFuncTable is out of date");
uint32_t type = DecodeType(aData[0]);
gTraverseFuncTable[type](aData + 1, aState);
}

View File

@ -186,8 +186,9 @@ nsSVGAnimatedTransformList::SMILAnimatedTransformList::ParseValue(
{
NS_ABORT_IF_FALSE(aResult.IsNull(), "Unexpected type for SMIL value");
// nsSVGSMILTransform constructor should be expecting array with 3 params
PR_STATIC_ASSERT(SVGTransformSMILData::NUM_SIMPLE_PARAMS == 3);
static_assert(SVGTransformSMILData::NUM_SIMPLE_PARAMS == 3,
"nsSVGSMILTransform constructor should be expecting array "
"with 3 params");
float params[3] = { 0.f };
int32_t numParsed = ParseParameterList(aSpec, params, 3);

View File

@ -57,7 +57,8 @@ using namespace mozilla::dom;
// vararg-list methods in this file:
// nsSVGElement::GetAnimated{Length,Number,Integer}Values
// See bug 547964 for details:
PR_STATIC_ASSERT(sizeof(void*) == sizeof(nullptr));
static_assert(sizeof(void*) == sizeof(nullptr),
"nullptr should be the correct size");
nsresult
NS_NewSVGElement(nsIContent **aResult, already_AddRefed<nsINodeInfo> aNodeInfo)

View File

@ -73,7 +73,8 @@ typedef uint8_t XBLBindingSerializeDetails;
// are no more attributes.
#define XBLBinding_Serialize_NoMoreAttributes 0xFF
PR_STATIC_ASSERT(XBLBinding_Serialize_CustomNamespace >= kNameSpaceID_LastBuiltin);
static_assert(XBLBinding_Serialize_CustomNamespace >= kNameSpaceID_LastBuiltin,
"The custom namespace should not be in use as a real namespace");
nsresult
XBL_SerializeFunction(nsIObjectOutputStream* aStream,