forked from mirrors/gecko-dev
Bug 1484496: Part 4b - Add intrinsic type information to most nsSimpleEnumerators. r=froydnj
This allows JS callers to automatically get the correct types during interation, without having to explicitly specify them. Differential Revision: https://phabricator.services.mozilla.com/D3728 --HG-- extra : rebase_source : b708f382d8ea571d199c669bfed5b5a7ca9ffac4 extra : histedit_source : 7df6feb82088c8a5ca45dc28fe4d2b852c177fee
This commit is contained in:
parent
c943b2a5c4
commit
2dee0aae3c
43 changed files with 163 additions and 48 deletions
|
|
@ -140,7 +140,7 @@ DirectoryProvider::GetFiles(const char *aKey, nsISimpleEnumerator* *aResult)
|
|||
nsCOMArray<nsIFile> distroFiles;
|
||||
AppendDistroSearchDirs(dirSvc, distroFiles);
|
||||
|
||||
return NS_NewArrayEnumerator(aResult, distroFiles);
|
||||
return NS_NewArrayEnumerator(aResult, distroFiles, NS_GET_IID(nsIFile));
|
||||
}
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
|
|
|
|||
|
|
@ -19,6 +19,11 @@ public:
|
|||
|
||||
nsIEHistoryEnumerator();
|
||||
|
||||
const nsID& DefaultInterface() override
|
||||
{
|
||||
return NS_GET_IID(nsIWritablePropertyBag2);
|
||||
}
|
||||
|
||||
private:
|
||||
~nsIEHistoryEnumerator() override;
|
||||
|
||||
|
|
|
|||
|
|
@ -46,6 +46,8 @@ public:
|
|||
// nsISimpleEnumerator
|
||||
NS_DECL_NSISIMPLEENUMERATOR
|
||||
|
||||
const nsID& DefaultInterface() override { return NS_GET_IID(nsIDocShell); }
|
||||
|
||||
public:
|
||||
nsresult GetEnumerationRootItem(nsIDocShellTreeItem** aEnumerationRootItem);
|
||||
nsresult SetEnumerationRootItem(nsIDocShellTreeItem* aEnumerationRootItem);
|
||||
|
|
|
|||
|
|
@ -2938,7 +2938,13 @@ NS_IMETHODIMP nsJSArgArray::IndexOf(uint32_t startIndex, nsISupports *element, u
|
|||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsJSArgArray::Enumerate(nsISimpleEnumerator **_retval)
|
||||
NS_IMETHODIMP nsJSArgArray::ScriptedEnumerate(nsIJSIID* aElemIID, uint8_t aArgc,
|
||||
nsISimpleEnumerator** aResult)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsJSArgArray::EnumerateImpl(const nsID& aEntryIID, nsISimpleEnumerator **_retval)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,6 +23,11 @@ public:
|
|||
|
||||
NS_DECL_NSISIMPLEENUMERATOR
|
||||
|
||||
const nsID& DefaultInterface() override
|
||||
{
|
||||
return NS_GET_IID(nsISupportsCString);
|
||||
}
|
||||
|
||||
protected:
|
||||
~nsGroupsEnumerator() override;
|
||||
|
||||
|
|
@ -128,6 +133,11 @@ public:
|
|||
|
||||
NS_DECL_NSISIMPLEENUMERATOR
|
||||
|
||||
const nsID& DefaultInterface() override
|
||||
{
|
||||
return NS_GET_IID(nsISupportsCString);
|
||||
}
|
||||
|
||||
protected:
|
||||
~nsNamedGroupEnumerator() override;
|
||||
|
||||
|
|
|
|||
|
|
@ -25,6 +25,12 @@ public:
|
|||
PaymentRequestEnumerator()
|
||||
: mIndex(0)
|
||||
{}
|
||||
|
||||
const nsID& DefaultInterface() override
|
||||
{
|
||||
return NS_GET_IID(nsIPaymentRequest);
|
||||
}
|
||||
|
||||
private:
|
||||
~PaymentRequestEnumerator() override = default;
|
||||
uint32_t mIndex;
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ nsPluginDirServiceProvider::GetPLIDDirectories(nsISimpleEnumerator **aEnumerator
|
|||
GetPLIDDirectoriesWithRootKey(nsIWindowsRegKey::ROOT_KEY_CURRENT_USER, dirs);
|
||||
GetPLIDDirectoriesWithRootKey(nsIWindowsRegKey::ROOT_KEY_LOCAL_MACHINE, dirs);
|
||||
|
||||
return NS_NewArrayEnumerator(aEnumerator, dirs);
|
||||
return NS_NewArrayEnumerator(aEnumerator, dirs, NS_GET_IID(nsIFile));
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
|
|
|||
|
|
@ -90,6 +90,11 @@ public:
|
|||
|
||||
NS_DECL_NSISIMPLEENUMERATOR
|
||||
|
||||
const nsID& DefaultInterface() override
|
||||
{
|
||||
return NS_GET_IID(nsIWorkerDebugger);
|
||||
}
|
||||
|
||||
private:
|
||||
~WorkerDebuggerEnumerator() override = default;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -2611,7 +2611,7 @@ NS_IMETHODIMP nsPermissionManager::GetEnumerator(nsISimpleEnumerator **aEnum)
|
|||
}
|
||||
}
|
||||
|
||||
return NS_NewArrayEnumerator(aEnum, array);
|
||||
return NS_NewArrayEnumerator(aEnum, array, NS_GET_IID(nsIPermission));
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsPermissionManager::GetAllForURI(nsIURI* aURI, nsISimpleEnumerator **aEnum)
|
||||
|
|
@ -2660,7 +2660,7 @@ nsPermissionManager::GetAllForPrincipal(nsIPrincipal* aPrincipal,
|
|||
}
|
||||
}
|
||||
|
||||
return NS_NewArrayEnumerator(aEnum, array);
|
||||
return NS_NewArrayEnumerator(aEnum, array, NS_GET_IID(nsIPermission));
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsPermissionManager::Observe(nsISupports *aSubject, const char *aTopic, const char16_t *someData)
|
||||
|
|
|
|||
|
|
@ -271,6 +271,11 @@ public:
|
|||
: mStringMap(aStringMap)
|
||||
{}
|
||||
|
||||
const nsID& DefaultInterface() override
|
||||
{
|
||||
return NS_GET_IID(nsIPropertyElement);
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual ~StringMapEnumerator() = default;
|
||||
|
||||
|
|
|
|||
|
|
@ -1513,7 +1513,7 @@ XPCShellDirProvider::GetFiles(const char* prop, nsISimpleEnumerator* *result)
|
|||
if (NS_SUCCEEDED(rv))
|
||||
dirs.AppendObject(file);
|
||||
|
||||
return NS_NewArrayEnumerator(result, dirs);
|
||||
return NS_NewArrayEnumerator(result, dirs, NS_GET_IID(nsIFile));
|
||||
} else if (!strcmp(prop, NS_APP_PREFS_DEFAULTS_DIR_LIST)) {
|
||||
nsCOMArray<nsIFile> dirs;
|
||||
nsCOMPtr<nsIFile> appDir;
|
||||
|
|
@ -1524,7 +1524,7 @@ XPCShellDirProvider::GetFiles(const char* prop, nsISimpleEnumerator* *result)
|
|||
NS_SUCCEEDED(appDir->AppendNative(NS_LITERAL_CSTRING("preferences"))) &&
|
||||
NS_SUCCEEDED(appDir->Exists(&exists)) && exists) {
|
||||
dirs.AppendObject(appDir);
|
||||
return NS_NewArrayEnumerator(result, dirs);
|
||||
return NS_NewArrayEnumerator(result, dirs, NS_GET_IID(nsIFile));
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
} else if (!strcmp(prop, NS_APP_PLUGINS_DIR_LIST)) {
|
||||
|
|
@ -1549,7 +1549,7 @@ XPCShellDirProvider::GetFiles(const char* prop, nsISimpleEnumerator* *result)
|
|||
}
|
||||
}
|
||||
}
|
||||
return NS_NewArrayEnumerator(result, dirs);
|
||||
return NS_NewArrayEnumerator(result, dirs, NS_GET_IID(nsIFile));
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -398,7 +398,7 @@ nsXPCWrappedJSClass::BuildPropertyEnumerator(XPCCallContext& ccx,
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return NS_NewArrayEnumerator(aEnumerate, propertyArray);
|
||||
return NS_NewArrayEnumerator(aEnumerate, propertyArray, NS_GET_IID(nsIProperty));
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
|
|
|
|||
|
|
@ -654,7 +654,7 @@ nsLoadGroup::GetRequests(nsISimpleEnumerator * *aRequests)
|
|||
requests.AppendObject(e->mKey);
|
||||
}
|
||||
|
||||
return NS_NewArrayEnumerator(aRequests, requests);
|
||||
return NS_NewArrayEnumerator(aRequests, requests, NS_GET_IID(nsIRequest));
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
|
|
|||
|
|
@ -2493,7 +2493,7 @@ nsCookieService::GetEnumerator(nsISimpleEnumerator **aEnumerator)
|
|||
}
|
||||
}
|
||||
|
||||
return NS_NewArrayEnumerator(aEnumerator, cookieList);
|
||||
return NS_NewArrayEnumerator(aEnumerator, cookieList, NS_GET_IID(nsICookie2));
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
|
@ -2518,7 +2518,7 @@ nsCookieService::GetSessionEnumerator(nsISimpleEnumerator **aEnumerator)
|
|||
}
|
||||
}
|
||||
|
||||
return NS_NewArrayEnumerator(aEnumerator, cookieList);
|
||||
return NS_NewArrayEnumerator(aEnumerator, cookieList, NS_GET_IID(nsICookie2));
|
||||
}
|
||||
|
||||
static nsresult
|
||||
|
|
@ -4928,7 +4928,7 @@ nsCookieService::GetCookiesFromHost(const nsACString &aHost,
|
|||
cookieList.AppendObject(cookies[i]);
|
||||
}
|
||||
|
||||
return NS_NewArrayEnumerator(aEnumerator, cookieList);
|
||||
return NS_NewArrayEnumerator(aEnumerator, cookieList, NS_GET_IID(nsICookie2));
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
|
@ -4987,7 +4987,7 @@ nsCookieService::GetCookiesWithOriginAttributes(
|
|||
}
|
||||
}
|
||||
|
||||
return NS_NewArrayEnumerator(aEnumerator, cookies);
|
||||
return NS_NewArrayEnumerator(aEnumerator, cookies, NS_GET_IID(nsICookie2));
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
|
|
|||
|
|
@ -192,7 +192,7 @@ PKCS11ModuleDB::ListModules(nsISimpleEnumerator** _retval)
|
|||
}
|
||||
}
|
||||
|
||||
return array->Enumerate(_retval);
|
||||
return array->Enumerate(_retval, NS_GET_IID(nsIPKCS11Module));
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
|
|
|||
|
|
@ -128,6 +128,8 @@ class nsNSSCertListEnumerator : public nsSimpleEnumerator
|
|||
public:
|
||||
NS_DECL_NSISIMPLEENUMERATOR
|
||||
|
||||
const nsID& DefaultInterface() override { return NS_GET_IID(nsIX509Cert); }
|
||||
|
||||
explicit nsNSSCertListEnumerator(const mozilla::UniqueCERTCertList& certList);
|
||||
private:
|
||||
virtual ~nsNSSCertListEnumerator() {}
|
||||
|
|
|
|||
|
|
@ -290,5 +290,5 @@ nsPKCS11Module::ListSlots(nsISimpleEnumerator** _retval)
|
|||
}
|
||||
}
|
||||
|
||||
return array->Enumerate(_retval);
|
||||
return array->Enumerate(_retval, NS_GET_IID(nsIPKCS11Slot));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -473,7 +473,7 @@ SiteHPKPState::GetSha256Keys(nsISimpleEnumerator** aSha256Keys)
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
return NS_NewArrayEnumerator(aSha256Keys, keys);
|
||||
return NS_NewArrayEnumerator(aSha256Keys, keys, NS_GET_IID(nsIVariant));
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
|
@ -1895,7 +1895,7 @@ nsSiteSecurityService::Enumerate(uint32_t aType,
|
|||
states.AppendObject(state);
|
||||
}
|
||||
|
||||
NS_NewArrayEnumerator(aEnumerator, states);
|
||||
NS_NewArrayEnumerator(aEnumerator, states, NS_GET_IID(nsISiteSecurityState));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -149,6 +149,11 @@ private:
|
|||
public:
|
||||
NS_DECL_NSISIMPLEENUMERATOR
|
||||
|
||||
const nsID& DefaultInterface() override
|
||||
{
|
||||
return NS_GET_IID(nsIToolkitProfile);
|
||||
}
|
||||
|
||||
explicit ProfileEnumerator(nsToolkitProfile *first)
|
||||
{ mCurrent = first; }
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -854,7 +854,7 @@ nsXREDirProvider::GetFilesInternal(const char* aProperty,
|
|||
LoadDirsIntoArray(mAppBundleDirectories,
|
||||
kAppendNothing, directories);
|
||||
|
||||
rv = NS_NewArrayEnumerator(aResult, directories);
|
||||
rv = NS_NewArrayEnumerator(aResult, directories, NS_GET_IID(nsIFile));
|
||||
}
|
||||
else if (!strcmp(aProperty, NS_APP_PREFS_DEFAULTS_DIR_LIST)) {
|
||||
nsCOMArray<nsIFile> directories;
|
||||
|
|
@ -863,7 +863,7 @@ nsXREDirProvider::GetFilesInternal(const char* aProperty,
|
|||
LoadDirsIntoArray(mAppBundleDirectories,
|
||||
kAppendPrefDir, directories);
|
||||
|
||||
rv = NS_NewArrayEnumerator(aResult, directories);
|
||||
rv = NS_NewArrayEnumerator(aResult, directories, NS_GET_IID(nsIFile));
|
||||
}
|
||||
else if (!strcmp(aProperty, NS_APP_CHROME_DIR_LIST)) {
|
||||
// NS_APP_CHROME_DIR_LIST is only used to get default (native) icons
|
||||
|
|
@ -878,7 +878,7 @@ nsXREDirProvider::GetFilesInternal(const char* aProperty,
|
|||
kAppendChromeDir,
|
||||
directories);
|
||||
|
||||
rv = NS_NewArrayEnumerator(aResult, directories);
|
||||
rv = NS_NewArrayEnumerator(aResult, directories, NS_GET_IID(nsIFile));
|
||||
}
|
||||
else if (!strcmp(aProperty, NS_APP_PLUGINS_DIR_LIST)) {
|
||||
nsCOMArray<nsIFile> directories;
|
||||
|
|
@ -908,7 +908,7 @@ nsXREDirProvider::GetFilesInternal(const char* aProperty,
|
|||
directories);
|
||||
}
|
||||
|
||||
rv = NS_NewArrayEnumerator(aResult, directories);
|
||||
rv = NS_NewArrayEnumerator(aResult, directories, NS_GET_IID(nsIFile));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = NS_SUCCESS_AGGREGATE_RESULT;
|
||||
|
|
|
|||
|
|
@ -217,7 +217,7 @@ HandlerService.prototype = {
|
|||
);
|
||||
handlers.appendElement(handler);
|
||||
}
|
||||
return handlers.enumerate();
|
||||
return handlers.enumerate(Ci.nsIHandlerInfo);
|
||||
},
|
||||
|
||||
// nsIHandlerService
|
||||
|
|
|
|||
|
|
@ -167,7 +167,7 @@ nsMIMEInfoWin::GetEnumerator(nsISimpleEnumerator* *_retval)
|
|||
if (variant)
|
||||
properties.AppendObject(variant);
|
||||
|
||||
return NS_NewArrayEnumerator(_retval, properties);
|
||||
return NS_NewArrayEnumerator(_retval, properties, NS_GET_IID(nsIVariant));
|
||||
}
|
||||
|
||||
static nsresult GetIconURLVariant(nsIFile* aApplication, nsIVariant* *_retval)
|
||||
|
|
|
|||
|
|
@ -346,7 +346,7 @@ nsFilePicker::GetFiles(nsISimpleEnumerator **aFiles)
|
|||
NS_ENSURE_ARG_POINTER(aFiles);
|
||||
|
||||
if (mMode == nsIFilePicker::modeOpenMultiple) {
|
||||
return NS_NewArrayEnumerator(aFiles, mFiles);
|
||||
return NS_NewArrayEnumerator(aFiles, mFiles, NS_GET_IID(nsIFile));
|
||||
}
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
|
|
|
|||
|
|
@ -112,6 +112,8 @@ public:
|
|||
, mMode(aMode)
|
||||
{}
|
||||
|
||||
const nsID& DefaultInterface() override { return NS_GET_IID(nsIFile); }
|
||||
|
||||
NS_IMETHOD
|
||||
GetNext(nsISupports** aResult) override
|
||||
{
|
||||
|
|
@ -283,7 +285,7 @@ NS_IMETHODIMP nsBaseFilePicker::GetFiles(nsISimpleEnumerator **aFiles)
|
|||
|
||||
files.AppendObject(file);
|
||||
|
||||
return NS_NewArrayEnumerator(aFiles, files);
|
||||
return NS_NewArrayEnumerator(aFiles, files, NS_GET_IID(nsIFile));
|
||||
}
|
||||
|
||||
// Set the display directory
|
||||
|
|
|
|||
|
|
@ -688,7 +688,7 @@ NS_IMETHODIMP
|
|||
nsFilePicker::GetFiles(nsISimpleEnumerator **aFiles)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aFiles);
|
||||
return NS_NewArrayEnumerator(aFiles, mFiles);
|
||||
return NS_NewArrayEnumerator(aFiles, mFiles, NS_GET_IID(nsIFile));
|
||||
}
|
||||
|
||||
// Get the file + path
|
||||
|
|
|
|||
|
|
@ -59,6 +59,11 @@ public:
|
|||
NS_DECL_NSISIMPLEENUMERATOR
|
||||
NS_DECL_NSIUTF8STRINGENUMERATOR
|
||||
|
||||
const nsID& DefaultInterface() override
|
||||
{
|
||||
return NS_GET_IID(nsISupportsCString);
|
||||
}
|
||||
|
||||
protected:
|
||||
// Callback function for NS_QuickSort to sort mArray
|
||||
static int SortCallback(const void*, const void*, void*);
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
#include "nsArray.h"
|
||||
#include "nsArrayEnumerator.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "xpcjsid.h"
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(nsArray)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIArray)
|
||||
|
|
@ -79,11 +80,22 @@ nsArrayBase::IndexOf(uint32_t aStartIndex, nsISupports* aElement,
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsArrayBase::Enumerate(nsISimpleEnumerator** aResult)
|
||||
nsArrayBase::ScriptedEnumerate(nsIJSIID* aElemIID, uint8_t aArgc,
|
||||
nsISimpleEnumerator** aResult)
|
||||
{
|
||||
if (aArgc > 0 && aElemIID) {
|
||||
return NS_NewArrayEnumerator(aResult, static_cast<nsIArray*>(this), *aElemIID->GetID());
|
||||
}
|
||||
return NS_NewArrayEnumerator(aResult, static_cast<nsIArray*>(this));
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsArrayBase::EnumerateImpl(const nsID& aElemIID, nsISimpleEnumerator** aResult)
|
||||
{
|
||||
return NS_NewArrayEnumerator(aResult, static_cast<nsIArray*>(this), aElemIID);
|
||||
}
|
||||
|
||||
// nsIMutableArray implementation
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
|
|
|||
|
|
@ -23,17 +23,21 @@ public:
|
|||
NS_DECL_NSISIMPLEENUMERATOR
|
||||
|
||||
// nsSimpleArrayEnumerator methods
|
||||
explicit nsSimpleArrayEnumerator(nsIArray* aValueArray)
|
||||
explicit nsSimpleArrayEnumerator(nsIArray* aValueArray, const nsID& aEntryIID)
|
||||
: mValueArray(aValueArray)
|
||||
, mEntryIID(aEntryIID)
|
||||
, mIndex(0)
|
||||
{
|
||||
}
|
||||
|
||||
const nsID& DefaultInterface() override { return mEntryIID; }
|
||||
|
||||
private:
|
||||
~nsSimpleArrayEnumerator() override = default;
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsIArray> mValueArray;
|
||||
const nsID mEntryIID;
|
||||
uint32_t mIndex;
|
||||
};
|
||||
|
||||
|
|
@ -86,9 +90,10 @@ nsSimpleArrayEnumerator::GetNext(nsISupports** aResult)
|
|||
}
|
||||
|
||||
nsresult
|
||||
NS_NewArrayEnumerator(nsISimpleEnumerator** aResult, nsIArray* aArray)
|
||||
NS_NewArrayEnumerator(nsISimpleEnumerator** aResult, nsIArray* aArray,
|
||||
const nsID& aEntryIID)
|
||||
{
|
||||
RefPtr<nsSimpleArrayEnumerator> enumer = new nsSimpleArrayEnumerator(aArray);
|
||||
RefPtr<nsSimpleArrayEnumerator> enumer = new nsSimpleArrayEnumerator(aArray, aEntryIID);
|
||||
enumer.forget(aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
@ -106,16 +111,19 @@ public:
|
|||
NS_DECL_NSISIMPLEENUMERATOR
|
||||
|
||||
// Use this instead of `new`.
|
||||
static nsCOMArrayEnumerator* Allocate(const nsCOMArray_base& aArray);
|
||||
static nsCOMArrayEnumerator* Allocate(const nsCOMArray_base& aArray, const nsID& aEntryIID);
|
||||
|
||||
// specialized operator to make sure we make room for mValues
|
||||
void operator delete(void* aPtr) { free(aPtr); }
|
||||
|
||||
const nsID& DefaultInterface() override { return mEntryIID; }
|
||||
|
||||
private:
|
||||
// nsSimpleArrayEnumerator methods
|
||||
nsCOMArrayEnumerator()
|
||||
explicit nsCOMArrayEnumerator(const nsID& aEntryIID)
|
||||
: mIndex(0)
|
||||
, mArraySize(0)
|
||||
, mEntryIID(aEntryIID)
|
||||
{
|
||||
mValueArray[0] = nullptr;
|
||||
}
|
||||
|
|
@ -126,6 +134,8 @@ protected:
|
|||
uint32_t mIndex; // current position
|
||||
uint32_t mArraySize; // size of the array
|
||||
|
||||
const nsID& mEntryIID;
|
||||
|
||||
// this is actually bigger
|
||||
nsISupports* mValueArray[1];
|
||||
};
|
||||
|
|
@ -175,7 +185,7 @@ nsCOMArrayEnumerator::GetNext(nsISupports** aResult)
|
|||
}
|
||||
|
||||
nsCOMArrayEnumerator*
|
||||
nsCOMArrayEnumerator::Allocate(const nsCOMArray_base& aArray)
|
||||
nsCOMArrayEnumerator::Allocate(const nsCOMArray_base& aArray, const nsID& aEntryIID)
|
||||
{
|
||||
// create enough space such that mValueArray points to a large
|
||||
// enough value. Note that the initial value of aSize gives us
|
||||
|
|
@ -191,7 +201,7 @@ nsCOMArrayEnumerator::Allocate(const nsCOMArray_base& aArray)
|
|||
|
||||
// Allocate a buffer large enough to contain our object and its array.
|
||||
void* mem = moz_xmalloc(size);
|
||||
auto result = new (mozilla::KnownNotNull, mem) nsCOMArrayEnumerator();
|
||||
auto result = new (mozilla::KnownNotNull, mem) nsCOMArrayEnumerator(aEntryIID);
|
||||
|
||||
result->mArraySize = count;
|
||||
|
||||
|
|
@ -209,9 +219,10 @@ nsCOMArrayEnumerator::Allocate(const nsCOMArray_base& aArray)
|
|||
|
||||
nsresult
|
||||
NS_NewArrayEnumerator(nsISimpleEnumerator** aResult,
|
||||
const nsCOMArray_base& aArray)
|
||||
const nsCOMArray_base& aArray,
|
||||
const nsID& aEntryIID)
|
||||
{
|
||||
RefPtr<nsCOMArrayEnumerator> enumerator = nsCOMArrayEnumerator::Allocate(aArray);
|
||||
RefPtr<nsCOMArrayEnumerator> enumerator = nsCOMArrayEnumerator::Allocate(aArray, aEntryIID);
|
||||
enumerator.forget(aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
// enumerator implementation for nsIArray
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsISupports.h"
|
||||
|
||||
class nsISimpleEnumerator;
|
||||
class nsIArray;
|
||||
|
|
@ -19,7 +19,8 @@ class nsCOMArray_base;
|
|||
// The enumerator holds an owning reference to the array.
|
||||
nsresult
|
||||
NS_NewArrayEnumerator(nsISimpleEnumerator** aResult,
|
||||
nsIArray* aArray);
|
||||
nsIArray* aArray,
|
||||
const nsID& aEntryIID = NS_GET_IID(nsISupports));
|
||||
|
||||
// create an enumerator for an existing nsCOMArray<T> implementation
|
||||
// The enumerator will hold an owning reference to each ELEMENT in
|
||||
|
|
@ -27,6 +28,7 @@ NS_NewArrayEnumerator(nsISimpleEnumerator** aResult,
|
|||
// without its objects going away.
|
||||
nsresult
|
||||
NS_NewArrayEnumerator(nsISimpleEnumerator** aResult,
|
||||
const nsCOMArray_base& aArray);
|
||||
const nsCOMArray_base& aArray,
|
||||
const nsID& aEntryIID = NS_GET_IID(nsISupports));
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -120,7 +120,8 @@ nsHashPropertyBagBase::GetEnumerator(nsISimpleEnumerator** aResult)
|
|||
propertyArray->AppendElement(sprop);
|
||||
}
|
||||
|
||||
return NS_NewArrayEnumerator(aResult, propertyArray);
|
||||
return NS_NewArrayEnumerator(aResult, propertyArray,
|
||||
NS_GET_IID(nsIProperty));
|
||||
}
|
||||
|
||||
#define IMPL_GETSETPROPERTY_AS(Name, Type) \
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIJSIID;
|
||||
interface nsISimpleEnumerator;
|
||||
|
||||
/**
|
||||
|
|
@ -31,7 +32,7 @@ interface nsISimpleEnumerator;
|
|||
* null is a valid entry in the array, and as such any nsISupports
|
||||
* parameters may be null, except where noted.
|
||||
*/
|
||||
[scriptable, uuid(114744d9-c369-456e-b55a-52fe52880d2d)]
|
||||
[scriptable, builtinclass, uuid(114744d9-c369-456e-b55a-52fe52880d2d)]
|
||||
interface nsIArray : nsISupports
|
||||
{
|
||||
/**
|
||||
|
|
@ -87,5 +88,17 @@ interface nsIArray : nsISupports
|
|||
* @throws NS_ERROR_FAILURE if the array is empty (to make it easy
|
||||
* to detect errors), or NS_ERROR_OUT_OF_MEMORY if out of memory.
|
||||
*/
|
||||
nsISimpleEnumerator enumerate();
|
||||
[binaryname(ScriptedEnumerate), optional_argc]
|
||||
nsISimpleEnumerator enumerate([optional] in nsIJSIID aElemIID);
|
||||
|
||||
[noscript]
|
||||
nsISimpleEnumerator enumerateImpl(in nsIDRef aElemIID);
|
||||
|
||||
%{C++
|
||||
nsresult
|
||||
Enumerate(nsISimpleEnumerator** aRetVal, const nsID& aElemIID = NS_GET_IID(nsISupports))
|
||||
{
|
||||
return EnumerateImpl(aElemIID, aRetVal);
|
||||
}
|
||||
%}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
* itself, possibly getting rid of the Count() method, as it duplicates
|
||||
* nsIArray functionality.
|
||||
*/
|
||||
[scriptable, uuid(261d442e-050c-453d-8aaa-b3f23bcc528b)]
|
||||
[scriptable, builtinclass, uuid(261d442e-050c-453d-8aaa-b3f23bcc528b)]
|
||||
interface nsIArrayExtensions : nsIArray
|
||||
{
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
* Any of these methods may throw NS_ERROR_OUT_OF_MEMORY when the
|
||||
* array must grow to complete the call, but the allocation fails.
|
||||
*/
|
||||
[scriptable, uuid(af059da0-c85b-40ec-af07-ae4bfdc192cc)]
|
||||
[scriptable, builtinclass, uuid(af059da0-c85b-40ec-af07-ae4bfdc192cc)]
|
||||
interface nsIMutableArray : nsIArrayExtensions
|
||||
{
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -31,7 +31,8 @@ interface nsIJSEnumerator : nsISupports {
|
|||
interface nsISimpleEnumeratorBase : nsISupports {
|
||||
/**
|
||||
* Returns a JavaScript iterator for all remaining entries in the enumerator.
|
||||
* Each entry is queried only to nsISupports.
|
||||
* Each entry is typically queried to the appropriate interface for the
|
||||
* enumerator.
|
||||
*/
|
||||
[symbol]
|
||||
nsIJSEnumerator iterator();
|
||||
|
|
|
|||
|
|
@ -82,6 +82,8 @@ public:
|
|||
|
||||
explicit nsObserverEnumerator(nsObserverList* aObserverList);
|
||||
|
||||
const nsID& DefaultInterface() override { return NS_GET_IID(nsIObserver); }
|
||||
|
||||
private:
|
||||
~nsObserverEnumerator() override = default;
|
||||
|
||||
|
|
|
|||
|
|
@ -570,7 +570,7 @@ nsPersistentProperties::Enumerate(nsISimpleEnumerator** aResult)
|
|||
}
|
||||
}
|
||||
|
||||
return NS_NewArrayEnumerator(aResult, props);
|
||||
return NS_NewArrayEnumerator(aResult, props, NS_GET_IID(nsIPropertyElement));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ NS_IMPL_ISUPPORTS(JSEnumerator, nsIJSEnumerator)
|
|||
nsresult
|
||||
nsSimpleEnumerator::Iterator(nsIJSEnumerator **aResult)
|
||||
{
|
||||
auto result = MakeRefPtr<JSEnumerator>(this, NS_GET_IID(nsISupports));
|
||||
auto result = MakeRefPtr<JSEnumerator>(this, DefaultInterface());
|
||||
result.forget(aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@ class nsSimpleEnumerator : public nsISimpleEnumerator
|
|||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSISIMPLEENUMERATORBASE
|
||||
|
||||
virtual const nsID& DefaultInterface() { return NS_GET_IID(nsISupports); }
|
||||
|
||||
protected:
|
||||
virtual ~nsSimpleEnumerator() = default;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -59,6 +59,14 @@ public:
|
|||
NS_IMETHOD GetNext(nsAString& aResult) override;
|
||||
NS_DECL_NSISIMPLEENUMERATOR
|
||||
|
||||
const nsID& DefaultInterface() override
|
||||
{
|
||||
if (mIsUnicode) {
|
||||
return NS_GET_IID(nsISupportsString);
|
||||
}
|
||||
return NS_GET_IID(nsISupportsCString);
|
||||
}
|
||||
|
||||
private:
|
||||
~nsStringEnumerator()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -390,6 +390,8 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
const nsID& DefaultInterface() override { return NS_GET_IID(nsIFile); }
|
||||
|
||||
NS_IMETHOD HasMoreElements(bool* aResult) override
|
||||
{
|
||||
while (!mNext && *mCurrentKey) {
|
||||
|
|
|
|||
|
|
@ -110,6 +110,8 @@ public:
|
|||
|
||||
NS_FORWARD_NSISIMPLEENUMERATORBASE(nsSimpleEnumerator::)
|
||||
|
||||
const nsID& DefaultInterface() override { return NS_GET_IID(nsIFile); }
|
||||
|
||||
private:
|
||||
~nsDirEnumeratorUnix() override;
|
||||
|
||||
|
|
|
|||
|
|
@ -241,6 +241,8 @@ public:
|
|||
NS_FORWARD_NSISIMPLEENUMERATORBASE(nsSimpleEnumerator::)
|
||||
nsresult Init();
|
||||
|
||||
const nsID& DefaultInterface() override { return NS_GET_IID(nsIFile); }
|
||||
|
||||
NS_IMETHOD GetNextFile(nsIFile** aResult) override
|
||||
{
|
||||
bool hasMore = false;
|
||||
|
|
@ -701,6 +703,8 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
const nsID& DefaultInterface() override { return NS_GET_IID(nsIFile); }
|
||||
|
||||
nsresult Init(nsIFile* aParent)
|
||||
{
|
||||
nsAutoString filepath;
|
||||
|
|
|
|||
|
|
@ -83,6 +83,8 @@ public:
|
|||
nsWindowMediator& inMediator);
|
||||
virtual ~nsASXULWindowEnumerator();
|
||||
NS_IMETHOD GetNext(nsISupports **retval) override;
|
||||
|
||||
const nsID& DefaultInterface() override { return NS_GET_IID(nsIXULWindow); }
|
||||
};
|
||||
|
||||
//
|
||||
|
|
|
|||
Loading…
Reference in a new issue