зеркало из https://github.com/mozilla/pjs.git
Added QueryElementAt() which combines GetElementAt() and QueryInterface(). Rationale: combining operations saves a call to AddRef/Release, since it's done by QI. Approved by dp.
This commit is contained in:
Родитель
8554135704
Коммит
85da0d0df7
|
@ -56,6 +56,9 @@ public:
|
|||
NS_IMETHOD GetElementAt(PRUint32 i, nsISupports* *result) {
|
||||
return mSubFolders->GetElementAt(i, result);
|
||||
}
|
||||
NS_IMETHOD QueryElementAt(PRUint32 i, const nsIID & iid, void * *result) {
|
||||
return mSubFolders->QueryElementAt(i, iid, result);
|
||||
}
|
||||
NS_IMETHOD SetElementAt(PRUint32 i, nsISupports* value) {
|
||||
return mSubFolders->SetElementAt(i, value);
|
||||
}
|
||||
|
|
|
@ -25,6 +25,8 @@ interface nsICollection : nsISupports
|
|||
|
||||
PRUint32 Count();
|
||||
nsISupports GetElementAt(in PRUint32 index);
|
||||
void QueryElementAt(in PRUint32 index, in nsIIDRef uuid,
|
||||
[iid_is(uuid),retval] out nsQIResult result);
|
||||
void SetElementAt(in PRUint32 index, in nsISupports item);
|
||||
void AppendElement(in nsISupports item);
|
||||
void RemoveElement(in nsISupports item);
|
||||
|
|
|
@ -39,6 +39,14 @@ public:
|
|||
*result = ElementAt(aIndex);
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHOD QueryElementAt(PRUint32 aIndex, const nsIID & aIID, void * *aResult) {
|
||||
if (aIndex < mCount) {
|
||||
nsISupports* element = mArray[aIndex];
|
||||
if (nsnull != element)
|
||||
return element->QueryInterface(aIID, aResult);
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
NS_IMETHOD SetElementAt(PRUint32 aIndex, nsISupports* value) {
|
||||
PRBool ok = ReplaceElementAt(value, aIndex);
|
||||
return ok ? NS_OK : NS_ERROR_FAILURE;
|
||||
|
|
Загрузка…
Ссылка в новой задаче