more work on bug 162115 - use "friend" to allow nsCOMArray<T>'s copy constructor to be protected, but still usable from nsArray

not part of build


git-svn-id: svn://10.0.0.236/trunk@131008 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
alecf%netscape.com
2002-10-02 18:54:12 +00:00
parent 315031c98b
commit 8c7efaf56b
3 changed files with 21 additions and 7 deletions

View File

@@ -48,6 +48,7 @@
// work of this class in the XPCOM dll
class NS_COM nsCOMArray_base
{
friend class nsArray;
protected:
nsCOMArray_base() {}
nsCOMArray_base(PRInt32 aCount) : mArray(aCount) {}
@@ -61,6 +62,10 @@ protected:
return mArray.EnumerateForwards(aFunc, aData);
}
PRBool EnumerateBackwards(nsVoidArrayEnumFunc aFunc, void* aData) {
return mArray.EnumerateBackwards(aFunc, aData);
}
// any method which is not a direct forward to mArray should
// avoid inline bodies, so that the compiler doesn't inline them
// all over the place
@@ -120,7 +125,9 @@ class nsCOMArray : public nsCOMArray_base
nsCOMArray() {}
nsCOMArray(PRInt32 aCount) : nsCOMArray_base(aCount) {}
nsCOMArray(const nsCOMArray_base& aOther) : nsCOMArray_base(aOther) { }
// only to be used by trusted classes who are going to pass us the
// right type!
nsCOMArray(const nsCOMArray<T>& aOther) : nsCOMArray_base(aOther) { }
~nsCOMArray() {}
@@ -176,6 +183,11 @@ class nsCOMArray : public nsCOMArray_base
aData);
}
PRBool EnumerateBackwards(nsCOMArrayEnumFunc aFunc, void* aData) {
return nsCOMArray_base::EnumerateBackwards(nsVoidArrayEnumFunc(aFunc),
aData);
}
// append an object, growing the array as necessary
PRBool AppendObject(T *aObject) {
return nsCOMArray_base::AppendObject(aObject);
@@ -194,10 +206,9 @@ class nsCOMArray : public nsCOMArray_base
return nsCOMArray_base::RemoveObjectAt(aIndex);
}
private:
private:
// don't implement these!
nsCOMArray(const nsCOMArray& other);
nsCOMArray& operator=(const nsCOMArray& other);
};