Bug 947626 - Fix index types in nsCOMArray CC helpers and remove whitespace. r=froydnj

This commit is contained in:
Andrew McCreight 2013-12-08 08:56:00 -08:00
parent d206368243
commit 6e48581b17

View File

@ -38,10 +38,10 @@ protected:
typedef bool (* nsBaseArrayEnumFunc) typedef bool (* nsBaseArrayEnumFunc)
(void* aElement, void *aData); (void* aElement, void *aData);
// enumerate through the array with a callback. // enumerate through the array with a callback.
bool EnumerateForwards(nsBaseArrayEnumFunc aFunc, void* aData) const; bool EnumerateForwards(nsBaseArrayEnumFunc aFunc, void* aData) const;
bool EnumerateBackwards(nsBaseArrayEnumFunc aFunc, void* aData) const; bool EnumerateBackwards(nsBaseArrayEnumFunc aFunc, void* aData) const;
typedef int (* nsBaseArrayComparatorFunc) typedef int (* nsBaseArrayComparatorFunc)
@ -121,7 +121,7 @@ public:
nsISupports* ElementAt(uint32_t aIndex) const { nsISupports* ElementAt(uint32_t aIndex) const {
return mArray[aIndex]; return mArray[aIndex];
} }
nsISupports* SafeObjectAt(int32_t aIndex) const { nsISupports* SafeObjectAt(int32_t aIndex) const {
return mArray.SafeElementAt(aIndex, nullptr); return mArray.SafeElementAt(aIndex, nullptr);
} }
@ -172,7 +172,7 @@ public:
mozilla::MallocSizeOf aMallocSizeOf, void* aData = nullptr) const; mozilla::MallocSizeOf aMallocSizeOf, void* aData = nullptr) const;
private: private:
// the actual storage // the actual storage
nsTArray<nsISupports*> mArray; nsTArray<nsISupports*> mArray;
@ -193,8 +193,8 @@ ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback,
uint32_t aFlags = 0) uint32_t aFlags = 0)
{ {
aFlags |= CycleCollectionEdgeNameArrayFlag; aFlags |= CycleCollectionEdgeNameArrayFlag;
size_t length = aField.Count(); int32_t length = aField.Count();
for (size_t i = 0; i < length; ++i) { for (int32_t i = 0; i < length; ++i) {
CycleCollectionNoteChild(aCallback, aField[i], aName, aFlags); CycleCollectionNoteChild(aCallback, aField[i], aName, aFlags);
} }
} }
@ -226,7 +226,7 @@ class nsCOMArray : public nsCOMArray_base
explicit explicit
nsCOMArray(int32_t aCount) : nsCOMArray_base(aCount) {} nsCOMArray(int32_t aCount) : nsCOMArray_base(aCount) {}
explicit explicit
nsCOMArray(const nsCOMArray<T>& aOther) : nsCOMArray_base(aOther) { } nsCOMArray(const nsCOMArray<T>& aOther) : nsCOMArray_base(aOther) { }
@ -315,7 +315,7 @@ class nsCOMArray : public nsCOMArray_base
// bool enumerate(T* aElement, void* aData) // bool enumerate(T* aElement, void* aData)
typedef bool (* nsCOMArrayEnumFunc) typedef bool (* nsCOMArrayEnumFunc)
(T* aElement, void *aData); (T* aElement, void *aData);
// enumerate through the array with a callback. // enumerate through the array with a callback.
bool EnumerateForwards(nsCOMArrayEnumFunc aFunc, void* aData) { bool EnumerateForwards(nsCOMArrayEnumFunc aFunc, void* aData) {
return nsCOMArray_base::EnumerateForwards(nsBaseArrayEnumFunc(aFunc), return nsCOMArray_base::EnumerateForwards(nsBaseArrayEnumFunc(aFunc),
@ -326,10 +326,10 @@ class nsCOMArray : public nsCOMArray_base
return nsCOMArray_base::EnumerateBackwards(nsBaseArrayEnumFunc(aFunc), return nsCOMArray_base::EnumerateBackwards(nsBaseArrayEnumFunc(aFunc),
aData); aData);
} }
typedef int (* nsCOMArrayComparatorFunc) typedef int (* nsCOMArrayComparatorFunc)
(T* aElement1, T* aElement2, void* aData); (T* aElement1, T* aElement2, void* aData);
void Sort(nsCOMArrayComparatorFunc aFunc, void* aData) { void Sort(nsCOMArrayComparatorFunc aFunc, void* aData) {
nsCOMArray_base::Sort(nsBaseArrayComparatorFunc(aFunc), aData); nsCOMArray_base::Sort(nsBaseArrayComparatorFunc(aFunc), aData);
} }
@ -354,7 +354,7 @@ class nsCOMArray : public nsCOMArray_base
void AppendElements(T* const* aElements, uint32_t aCount) { void AppendElements(T* const* aElements, uint32_t aCount) {
InsertElementsAt(Length(), aElements, aCount); InsertElementsAt(Length(), aElements, aCount);
} }
// remove the first instance of the given object and shrink the // remove the first instance of the given object and shrink the
// array as necessary // array as necessary
// Warning: if you pass null here, it will remove the first null element // Warning: if you pass null here, it will remove the first null element
@ -378,7 +378,7 @@ class nsCOMArray : public nsCOMArray_base
// the memory taken by the T itself as well as anything it points to. // the memory taken by the T itself as well as anything it points to.
typedef size_t (* nsCOMArraySizeOfElementIncludingThisFunc) typedef size_t (* nsCOMArraySizeOfElementIncludingThisFunc)
(T* aElement, mozilla::MallocSizeOf aMallocSizeOf, void *aData); (T* aElement, mozilla::MallocSizeOf aMallocSizeOf, void *aData);
size_t SizeOfExcludingThis( size_t SizeOfExcludingThis(
nsCOMArraySizeOfElementIncludingThisFunc aSizeOfElementIncludingThis, nsCOMArraySizeOfElementIncludingThisFunc aSizeOfElementIncludingThis,
mozilla::MallocSizeOf aMallocSizeOf, void *aData = nullptr) const { mozilla::MallocSizeOf aMallocSizeOf, void *aData = nullptr) const {
@ -408,8 +408,8 @@ ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback,
uint32_t aFlags = 0) uint32_t aFlags = 0)
{ {
aFlags |= CycleCollectionEdgeNameArrayFlag; aFlags |= CycleCollectionEdgeNameArrayFlag;
size_t length = aField.Count(); int32_t length = aField.Count();
for (size_t i = 0; i < length; ++i) { for (int32_t i = 0; i < length; ++i) {
CycleCollectionNoteChild(aCallback, aField[i], aName, aFlags); CycleCollectionNoteChild(aCallback, aField[i], aName, aFlags);
} }
} }