Bug 793314 - Remove PtrBits; r=mounir,roc

This commit is contained in:
Ms2ger
2012-10-02 10:24:11 +02:00
parent 0f227cd68c
commit f8c108d2d8
15 changed files with 47 additions and 58 deletions

View File

@@ -897,7 +897,7 @@ public:
} }
#endif #endif
bool HasFlag(PtrBits aFlag) const bool HasFlag(uintptr_t aFlag) const
{ {
return !!(GetFlags() & aFlag); return !!(GetFlags() & aFlag);
} }

View File

@@ -16,8 +16,6 @@
#include "nsIAtom.h" #include "nsIAtom.h"
#include "nsDOMString.h" #include "nsDOMString.h"
typedef uintptr_t PtrBits;
#define NS_ATTRNAME_NODEINFO_BIT 1 #define NS_ATTRNAME_NODEINFO_BIT 1
class nsAttrName class nsAttrName
{ {
@@ -29,7 +27,7 @@ public:
} }
explicit nsAttrName(nsIAtom* aAtom) explicit nsAttrName(nsIAtom* aAtom)
: mBits(reinterpret_cast<PtrBits>(aAtom)) : mBits(reinterpret_cast<uintptr_t>(aAtom))
{ {
NS_ASSERTION(aAtom, "null atom-name in nsAttrName"); NS_ASSERTION(aAtom, "null atom-name in nsAttrName");
NS_ADDREF(aAtom); NS_ADDREF(aAtom);
@@ -39,11 +37,11 @@ public:
{ {
NS_ASSERTION(aNodeInfo, "null nodeinfo-name in nsAttrName"); NS_ASSERTION(aNodeInfo, "null nodeinfo-name in nsAttrName");
if (aNodeInfo->NamespaceEquals(kNameSpaceID_None)) { if (aNodeInfo->NamespaceEquals(kNameSpaceID_None)) {
mBits = reinterpret_cast<PtrBits>(aNodeInfo->NameAtom()); mBits = reinterpret_cast<uintptr_t>(aNodeInfo->NameAtom());
NS_ADDREF(aNodeInfo->NameAtom()); NS_ADDREF(aNodeInfo->NameAtom());
} }
else { else {
mBits = reinterpret_cast<PtrBits>(aNodeInfo) | mBits = reinterpret_cast<uintptr_t>(aNodeInfo) |
NS_ATTRNAME_NODEINFO_BIT; NS_ATTRNAME_NODEINFO_BIT;
NS_ADDREF(aNodeInfo); NS_ADDREF(aNodeInfo);
} }
@@ -60,11 +58,11 @@ public:
ReleaseInternalName(); ReleaseInternalName();
if (aNodeInfo->NamespaceEquals(kNameSpaceID_None)) { if (aNodeInfo->NamespaceEquals(kNameSpaceID_None)) {
mBits = reinterpret_cast<PtrBits>(aNodeInfo->NameAtom()); mBits = reinterpret_cast<uintptr_t>(aNodeInfo->NameAtom());
NS_ADDREF(aNodeInfo->NameAtom()); NS_ADDREF(aNodeInfo->NameAtom());
} }
else { else {
mBits = reinterpret_cast<PtrBits>(aNodeInfo) | mBits = reinterpret_cast<uintptr_t>(aNodeInfo) |
NS_ATTRNAME_NODEINFO_BIT; NS_ATTRNAME_NODEINFO_BIT;
NS_ADDREF(aNodeInfo); NS_ADDREF(aNodeInfo);
} }
@@ -75,7 +73,7 @@ public:
NS_ASSERTION(aAtom, "null atom-name in nsAttrName"); NS_ASSERTION(aAtom, "null atom-name in nsAttrName");
ReleaseInternalName(); ReleaseInternalName();
mBits = reinterpret_cast<PtrBits>(aAtom); mBits = reinterpret_cast<uintptr_t>(aAtom);
NS_ADDREF(aAtom); NS_ADDREF(aAtom);
} }
@@ -104,7 +102,7 @@ public:
// Faster comparison in the case we know the namespace is null // Faster comparison in the case we know the namespace is null
bool Equals(nsIAtom* aAtom) const bool Equals(nsIAtom* aAtom) const
{ {
return reinterpret_cast<PtrBits>(aAtom) == mBits; return reinterpret_cast<uintptr_t>(aAtom) == mBits;
} }
bool Equals(nsIAtom* aLocalName, int32_t aNamespaceID) const bool Equals(nsIAtom* aLocalName, int32_t aNamespaceID) const
@@ -180,7 +178,7 @@ public:
bool IsSmaller(nsIAtom* aOther) const bool IsSmaller(nsIAtom* aOther) const
{ {
return mBits < reinterpret_cast<PtrBits>(aOther); return mBits < reinterpret_cast<uintptr_t>(aOther);
} }
private: private:
@@ -205,7 +203,7 @@ private:
NS_RELEASE(name); NS_RELEASE(name);
} }
PtrBits mBits; uintptr_t mBits;
}; };
#endif #endif

View File

@@ -564,7 +564,7 @@ nsAttrValue::SetTo(const nsSVGViewBox& aValue, const nsAString* aSerialized)
void void
nsAttrValue::SwapValueWith(nsAttrValue& aOther) nsAttrValue::SwapValueWith(nsAttrValue& aOther)
{ {
PtrBits tmp = aOther.mBits; uintptr_t tmp = aOther.mBits;
aOther.mBits = mBits; aOther.mBits = mBits;
mBits = tmp; mBits = tmp;
} }
@@ -1536,7 +1536,7 @@ nsAttrValue::SetColorValue(nscolor aColor, const nsAString& aString)
cont->mType = eColor; cont->mType = eColor;
// Save the literal string we were passed for round-tripping. // Save the literal string we were passed for round-tripping.
cont->mStringBits = reinterpret_cast<PtrBits>(buf) | eStringBase; cont->mStringBits = reinterpret_cast<uintptr_t>(buf) | eStringBase;
} }
bool bool
@@ -1713,12 +1713,12 @@ nsAttrValue::SetMiscAtomOrString(const nsAString* aValue)
if (len <= NS_ATTRVALUE_MAX_STRINGLENGTH_ATOM) { if (len <= NS_ATTRVALUE_MAX_STRINGLENGTH_ATOM) {
nsIAtom* atom = NS_NewAtom(*aValue); nsIAtom* atom = NS_NewAtom(*aValue);
if (atom) { if (atom) {
cont->mStringBits = reinterpret_cast<PtrBits>(atom) | eAtomBase; cont->mStringBits = reinterpret_cast<uintptr_t>(atom) | eAtomBase;
} }
} else { } else {
nsStringBuffer* buf = GetStringBuffer(*aValue); nsStringBuffer* buf = GetStringBuffer(*aValue);
if (buf) { if (buf) {
cont->mStringBits = reinterpret_cast<PtrBits>(buf) | eStringBase; cont->mStringBits = reinterpret_cast<uintptr_t>(buf) | eStringBase;
} }
} }
} }

View File

@@ -20,7 +20,6 @@
#include "nsCOMPtr.h" #include "nsCOMPtr.h"
#include "SVGAttrValueWrapper.h" #include "SVGAttrValueWrapper.h"
typedef uintptr_t PtrBits;
class nsAString; class nsAString;
class nsIAtom; class nsIAtom;
class nsIDocument; class nsIDocument;
@@ -39,11 +38,11 @@ struct ImageValue;
#define NS_ATTRVALUE_MAX_STRINGLENGTH_ATOM 12 #define NS_ATTRVALUE_MAX_STRINGLENGTH_ATOM 12
#define NS_ATTRVALUE_BASETYPE_MASK (PtrBits(3)) #define NS_ATTRVALUE_BASETYPE_MASK (uintptr_t(3))
#define NS_ATTRVALUE_POINTERVALUE_MASK (~NS_ATTRVALUE_BASETYPE_MASK) #define NS_ATTRVALUE_POINTERVALUE_MASK (~NS_ATTRVALUE_BASETYPE_MASK)
#define NS_ATTRVALUE_INTEGERTYPE_BITS 4 #define NS_ATTRVALUE_INTEGERTYPE_BITS 4
#define NS_ATTRVALUE_INTEGERTYPE_MASK (PtrBits((1 << NS_ATTRVALUE_INTEGERTYPE_BITS) - 1)) #define NS_ATTRVALUE_INTEGERTYPE_MASK (uintptr_t((1 << NS_ATTRVALUE_INTEGERTYPE_BITS) - 1))
#define NS_ATTRVALUE_INTEGERTYPE_MULTIPLIER (1 << NS_ATTRVALUE_INTEGERTYPE_BITS) #define NS_ATTRVALUE_INTEGERTYPE_MULTIPLIER (1 << NS_ATTRVALUE_INTEGERTYPE_BITS)
#define NS_ATTRVALUE_INTEGERTYPE_MAXVALUE ((1 << (31 - NS_ATTRVALUE_INTEGERTYPE_BITS)) - 1) #define NS_ATTRVALUE_INTEGERTYPE_MAXVALUE ((1 << (31 - NS_ATTRVALUE_INTEGERTYPE_BITS)) - 1)
#define NS_ATTRVALUE_INTEGERTYPE_MINVALUE (-NS_ATTRVALUE_INTEGERTYPE_MAXVALUE - 1) #define NS_ATTRVALUE_INTEGERTYPE_MINVALUE (-NS_ATTRVALUE_INTEGERTYPE_MAXVALUE - 1)
@@ -52,7 +51,7 @@ struct ImageValue;
#define NS_ATTRVALUE_ENUMTABLE_VALUE_NEEDS_TO_UPPER (1 << (NS_ATTRVALUE_ENUMTABLEINDEX_BITS - 1)) #define NS_ATTRVALUE_ENUMTABLE_VALUE_NEEDS_TO_UPPER (1 << (NS_ATTRVALUE_ENUMTABLEINDEX_BITS - 1))
#define NS_ATTRVALUE_ENUMTABLEINDEX_MAXVALUE (NS_ATTRVALUE_ENUMTABLE_VALUE_NEEDS_TO_UPPER - 1) #define NS_ATTRVALUE_ENUMTABLEINDEX_MAXVALUE (NS_ATTRVALUE_ENUMTABLE_VALUE_NEEDS_TO_UPPER - 1)
#define NS_ATTRVALUE_ENUMTABLEINDEX_MASK \ #define NS_ATTRVALUE_ENUMTABLEINDEX_MASK \
(PtrBits((((1 << NS_ATTRVALUE_ENUMTABLEINDEX_BITS) - 1) &~ NS_ATTRVALUE_ENUMTABLE_VALUE_NEEDS_TO_UPPER))) (uintptr_t((((1 << NS_ATTRVALUE_ENUMTABLEINDEX_BITS) - 1) &~ NS_ATTRVALUE_ENUMTABLE_VALUE_NEEDS_TO_UPPER)))
/** /**
* A class used to construct a nsString from a nsStringBuffer (we might * A class used to construct a nsString from a nsStringBuffer (we might
@@ -428,7 +427,7 @@ private:
static nsTArray<const EnumTable*, nsTArrayDefaultAllocator>* sEnumTableArray; static nsTArray<const EnumTable*, nsTArrayDefaultAllocator>* sEnumTableArray;
PtrBits mBits; uintptr_t mBits;
}; };
inline const nsAttrValue& inline const nsAttrValue&

View File

@@ -57,8 +57,6 @@ class nsDOMTokenList;
class ContentUnbinder; class ContentUnbinder;
struct nsRect; struct nsRect;
typedef uintptr_t PtrBits;
/** /**
* A generic base class for DOM elements, implementing many nsIContent, * A generic base class for DOM elements, implementing many nsIContent,
* nsIDOMNode and nsIDOMElement methods. * nsIDOMNode and nsIDOMElement methods.

View File

@@ -1123,11 +1123,11 @@ nsINode::Trace(nsINode *tmp, TraceCallback cb, void *closure)
bool bool
nsINode::UnoptimizableCCNode() const nsINode::UnoptimizableCCNode() const
{ {
const PtrBits problematicFlags = (NODE_IS_ANONYMOUS | const uintptr_t problematicFlags = (NODE_IS_ANONYMOUS |
NODE_IS_IN_ANONYMOUS_SUBTREE | NODE_IS_IN_ANONYMOUS_SUBTREE |
NODE_IS_NATIVE_ANONYMOUS_ROOT | NODE_IS_NATIVE_ANONYMOUS_ROOT |
NODE_MAY_BE_IN_BINDING_MNGR | NODE_MAY_BE_IN_BINDING_MNGR |
NODE_IS_INSERTION_PARENT); NODE_IS_INSERTION_PARENT);
return HasFlag(problematicFlags) || return HasFlag(problematicFlags) ||
NodeType() == nsIDOMNode::ATTRIBUTE_NODE || NodeType() == nsIDOMNode::ATTRIBUTE_NODE ||
// For strange cases like xbl:content/xbl:children // For strange cases like xbl:content/xbl:children

View File

@@ -27,7 +27,6 @@
#include "prtypes.h" #include "prtypes.h"
class nsIAtom; class nsIAtom;
typedef uintptr_t PtrBits;
typedef void typedef void
(*NSPropertyFunc)(void *aObject, (*NSPropertyFunc)(void *aObject,

View File

@@ -2434,9 +2434,9 @@ nsDOMClassInfo::Init()
{ {
/* Errors that can trigger early returns are done first, /* Errors that can trigger early returns are done first,
otherwise nsDOMClassInfo is left in a half inited state. */ otherwise nsDOMClassInfo is left in a half inited state. */
NS_ASSERTION(sizeof(PtrBits) == sizeof(void*), MOZ_STATIC_ASSERT(sizeof(uintptr_t) == sizeof(void*),
"BAD! You'll need to adjust the size of PtrBits to the size " "BAD! You'll need to adjust the size of uintptr_t to the "
"of a pointer on your platform."); "size of a pointer on your platform.");
NS_ENSURE_TRUE(!sIsInitialized, NS_ERROR_ALREADY_INITIALIZED); NS_ENSURE_TRUE(!sIsInitialized, NS_ERROR_ALREADY_INITIALIZED);

View File

@@ -82,14 +82,12 @@ struct nsExternalDOMClassInfoData : public nsDOMClassInfoData
}; };
typedef uintptr_t PtrBits;
// To be used with the nsDOMClassInfoData::mCachedClassInfo pointer. // To be used with the nsDOMClassInfoData::mCachedClassInfo pointer.
// The low bit is set when we created a generic helper for an external // The low bit is set when we created a generic helper for an external
// (which holds on to the nsDOMClassInfoData). // (which holds on to the nsDOMClassInfoData).
#define GET_CLEAN_CI_PTR(_ptr) (nsIClassInfo*)(PtrBits(_ptr) & ~0x1) #define GET_CLEAN_CI_PTR(_ptr) (nsIClassInfo*)(uintptr_t(_ptr) & ~0x1)
#define MARK_EXTERNAL(_ptr) (nsIClassInfo*)(PtrBits(_ptr) | 0x1) #define MARK_EXTERNAL(_ptr) (nsIClassInfo*)(uintptr_t(_ptr) | 0x1)
#define IS_EXTERNAL(_ptr) (PtrBits(_ptr) & 0x1) #define IS_EXTERNAL(_ptr) (uintptr_t(_ptr) & 0x1)
class nsDOMClassInfo : public nsXPCClassInfo class nsDOMClassInfo : public nsXPCClassInfo

View File

@@ -12,8 +12,6 @@ struct JSObject;
struct JSContext; struct JSContext;
class XPCWrappedNativeScope; class XPCWrappedNativeScope;
typedef uintptr_t PtrBits;
namespace mozilla { namespace mozilla {
namespace dom { namespace dom {
namespace workers { namespace workers {
@@ -183,7 +181,7 @@ private:
} }
void SetWrapperBits(void *aWrapper) void SetWrapperBits(void *aWrapper)
{ {
mWrapperPtrBits = reinterpret_cast<PtrBits>(aWrapper) | mWrapperPtrBits = reinterpret_cast<uintptr_t>(aWrapper) |
(mWrapperPtrBits & WRAPPER_IS_DOM_BINDING); (mWrapperPtrBits & WRAPPER_IS_DOM_BINDING);
} }
@@ -208,7 +206,7 @@ private:
enum { kWrapperBitMask = (WRAPPER_BIT_PRESERVED | WRAPPER_IS_DOM_BINDING) }; enum { kWrapperBitMask = (WRAPPER_BIT_PRESERVED | WRAPPER_IS_DOM_BINDING) };
PtrBits mWrapperPtrBits; uintptr_t mWrapperPtrBits;
}; };
NS_DEFINE_STATIC_IID_ACCESSOR(nsWrapperCache, NS_WRAPPERCACHE_IID) NS_DEFINE_STATIC_IID_ACCESSOR(nsWrapperCache, NS_WRAPPERCACHE_IID)

View File

@@ -89,7 +89,7 @@ DOMBindingBase::SetJSObject(JSObject* aObject)
// method. // method.
SetWrapper(aObject); SetWrapper(aObject);
PtrBits oldWrapperPtrBits = mWrapperPtrBits; uintptr_t oldWrapperPtrBits = mWrapperPtrBits;
SetWrapperBits(aObject); SetWrapperBits(aObject);

View File

@@ -3000,7 +3000,7 @@ gfxGlyphExtents::GlyphWidths::~GlyphWidths()
{ {
uint32_t i, count = mBlocks.Length(); uint32_t i, count = mBlocks.Length();
for (i = 0; i < count; ++i) { for (i = 0; i < count; ++i) {
PtrBits bits = mBlocks[i]; uintptr_t bits = mBlocks[i];
if (bits && !(bits & 0x1)) { if (bits && !(bits & 0x1)) {
delete[] reinterpret_cast<uint16_t *>(bits); delete[] reinterpret_cast<uint16_t *>(bits);
} }
@@ -3013,7 +3013,7 @@ gfxGlyphExtents::GlyphWidths::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeO
uint32_t i; uint32_t i;
uint32_t size = mBlocks.SizeOfExcludingThis(aMallocSizeOf); uint32_t size = mBlocks.SizeOfExcludingThis(aMallocSizeOf);
for (i = 0; i < mBlocks.Length(); ++i) { for (i = 0; i < mBlocks.Length(); ++i) {
PtrBits bits = mBlocks[i]; uintptr_t bits = mBlocks[i];
if (bits && !(bits & 0x1)) { if (bits && !(bits & 0x1)) {
size += aMallocSizeOf(reinterpret_cast<void*>(bits)); size += aMallocSizeOf(reinterpret_cast<void*>(bits));
} }
@@ -3027,13 +3027,13 @@ gfxGlyphExtents::GlyphWidths::Set(uint32_t aGlyphID, uint16_t aWidth)
uint32_t block = aGlyphID >> BLOCK_SIZE_BITS; uint32_t block = aGlyphID >> BLOCK_SIZE_BITS;
uint32_t len = mBlocks.Length(); uint32_t len = mBlocks.Length();
if (block >= len) { if (block >= len) {
PtrBits *elems = mBlocks.AppendElements(block + 1 - len); uintptr_t *elems = mBlocks.AppendElements(block + 1 - len);
if (!elems) if (!elems)
return; return;
memset(elems, 0, sizeof(PtrBits)*(block + 1 - len)); memset(elems, 0, sizeof(uintptr_t)*(block + 1 - len));
} }
PtrBits bits = mBlocks[block]; uintptr_t bits = mBlocks[block];
uint32_t glyphOffset = aGlyphID & (BLOCK_SIZE - 1); uint32_t glyphOffset = aGlyphID & (BLOCK_SIZE - 1);
if (!bits) { if (!bits) {
mBlocks[block] = MakeSingle(glyphOffset, aWidth); mBlocks[block] = MakeSingle(glyphOffset, aWidth);
@@ -3052,7 +3052,7 @@ gfxGlyphExtents::GlyphWidths::Set(uint32_t aGlyphID, uint16_t aWidth)
newBlock[i] = INVALID_WIDTH; newBlock[i] = INVALID_WIDTH;
} }
newBlock[GetGlyphOffset(bits)] = GetWidth(bits); newBlock[GetGlyphOffset(bits)] = GetWidth(bits);
mBlocks[block] = reinterpret_cast<PtrBits>(newBlock); mBlocks[block] = reinterpret_cast<uintptr_t>(newBlock);
} else { } else {
newBlock = reinterpret_cast<uint16_t *>(bits); newBlock = reinterpret_cast<uint16_t *>(bits);
} }

View File

@@ -1063,7 +1063,6 @@ private:
float x, y, width, height; float x, y, width, height;
}; };
typedef uintptr_t PtrBits;
enum { BLOCK_SIZE_BITS = 7, BLOCK_SIZE = 1 << BLOCK_SIZE_BITS }; // 128-glyph blocks enum { BLOCK_SIZE_BITS = 7, BLOCK_SIZE = 1 << BLOCK_SIZE_BITS }; // 128-glyph blocks
class GlyphWidths { class GlyphWidths {
@@ -1073,7 +1072,7 @@ private:
uint32_t block = aIndex >> BLOCK_SIZE_BITS; uint32_t block = aIndex >> BLOCK_SIZE_BITS;
if (block >= mBlocks.Length()) if (block >= mBlocks.Length())
return INVALID_WIDTH; return INVALID_WIDTH;
PtrBits bits = mBlocks[block]; uintptr_t bits = mBlocks[block];
if (!bits) if (!bits)
return INVALID_WIDTH; return INVALID_WIDTH;
uint32_t indexInBlock = aIndex & (BLOCK_SIZE - 1); uint32_t indexInBlock = aIndex & (BLOCK_SIZE - 1);
@@ -1091,19 +1090,19 @@ private:
~GlyphWidths(); ~GlyphWidths();
private: private:
static uint32_t GetGlyphOffset(PtrBits aBits) { static uint32_t GetGlyphOffset(uintptr_t aBits) {
NS_ASSERTION(aBits & 0x1, "This is really a pointer..."); NS_ASSERTION(aBits & 0x1, "This is really a pointer...");
return (aBits >> 1) & ((1 << BLOCK_SIZE_BITS) - 1); return (aBits >> 1) & ((1 << BLOCK_SIZE_BITS) - 1);
} }
static uint32_t GetWidth(PtrBits aBits) { static uint32_t GetWidth(uintptr_t aBits) {
NS_ASSERTION(aBits & 0x1, "This is really a pointer..."); NS_ASSERTION(aBits & 0x1, "This is really a pointer...");
return aBits >> (1 + BLOCK_SIZE_BITS); return aBits >> (1 + BLOCK_SIZE_BITS);
} }
static PtrBits MakeSingle(uint32_t aGlyphOffset, uint16_t aWidth) { static uintptr_t MakeSingle(uint32_t aGlyphOffset, uint16_t aWidth) {
return (aWidth << (1 + BLOCK_SIZE_BITS)) + (aGlyphOffset << 1) + 1; return (aWidth << (1 + BLOCK_SIZE_BITS)) + (aGlyphOffset << 1) + 1;
} }
nsTArray<PtrBits> mBlocks; nsTArray<uintptr_t> mBlocks;
}; };
GlyphWidths mContainedGlyphWidths; GlyphWidths mContainedGlyphWidths;

View File

@@ -3870,7 +3870,7 @@ nsCSSFrameConstructor::CreateAnonymousFrames(nsFrameConstructorState& aState,
} }
static void static void
SetFlagsOnSubtree(nsIContent *aNode, PtrBits aFlagsToSet) SetFlagsOnSubtree(nsIContent *aNode, uintptr_t aFlagsToSet)
{ {
#ifdef DEBUG #ifdef DEBUG
// Make sure that the node passed to us doesn't have any XBL children // Make sure that the node passed to us doesn't have any XBL children

View File

@@ -363,9 +363,9 @@ Initialize()
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
NS_ASSERTION(sizeof(PtrBits) == sizeof(void *), MOZ_STATIC_ASSERT(sizeof(uintptr_t) == sizeof(void*),
"Eeek! You'll need to adjust the size of PtrBits to the size " "Eeek! You'll need to adjust the size of uintptr_t to the "
"of a pointer on your platform."); "size of a pointer on your platform.");
gInitialized = true; gInitialized = true;