Bug 345123: Remove nsGetterAddRefs<T>'s operator nsISupports**. r=bsmedberg

This commit is contained in:
Kyle Huey 2014-03-15 12:00:17 -07:00
parent 567b9398be
commit 68b608c95f
28 changed files with 141 additions and 60 deletions

View File

@ -493,18 +493,23 @@ nsPrincipal::GetBaseDomain(nsACString& aBaseDomain)
NS_IMETHODIMP
nsPrincipal::Read(nsIObjectInputStream* aStream)
{
nsCOMPtr<nsISupports> supports;
nsCOMPtr<nsIURI> codebase;
nsresult rv = NS_ReadOptionalObject(aStream, true, getter_AddRefs(codebase));
nsresult rv = NS_ReadOptionalObject(aStream, true, getter_AddRefs(supports));
if (NS_FAILED(rv)) {
return rv;
}
codebase = do_QueryInterface(supports);
nsCOMPtr<nsIURI> domain;
rv = NS_ReadOptionalObject(aStream, true, getter_AddRefs(domain));
rv = NS_ReadOptionalObject(aStream, true, getter_AddRefs(supports));
if (NS_FAILED(rv)) {
return rv;
}
domain = do_QueryInterface(supports);
uint32_t appId;
rv = aStream->Read32(&appId);
NS_ENSURE_SUCCESS(rv, rv);
@ -513,10 +518,12 @@ nsPrincipal::Read(nsIObjectInputStream* aStream)
rv = aStream->ReadBoolean(&inMozBrowser);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIContentSecurityPolicy> csp;
rv = NS_ReadOptionalObject(aStream, true, getter_AddRefs(csp));
rv = NS_ReadOptionalObject(aStream, true, getter_AddRefs(supports));
NS_ENSURE_SUCCESS(rv, rv);
// This may be null.
nsCOMPtr<nsIContentSecurityPolicy> csp = do_QueryInterface(supports, &rv);
rv = Init(codebase, appId, inMozBrowser);
NS_ENSURE_SUCCESS(rv, rv);

View File

@ -293,8 +293,10 @@ CSPService::AsyncOnChannelRedirect(nsIChannel *oldChannel,
if (!channelPolicy)
return NS_OK;
nsCOMPtr<nsISupports> supports;
nsCOMPtr<nsIContentSecurityPolicy> csp;
channelPolicy->GetContentSecurityPolicy(getter_AddRefs(csp));
channelPolicy->GetContentSecurityPolicy(getter_AddRefs(supports));
csp = do_QueryInterface(supports);
uint32_t loadType;
channelPolicy->GetLoadType(&loadType);

View File

@ -664,21 +664,30 @@ DragDataProducer::Produce(DataTransfer* aDataTransfer,
}
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsISupports> supports;
nsCOMPtr<nsISupportsString> data;
uint32_t dataSize;
rv = transferable->GetTransferData(kHTMLMime, getter_AddRefs(data), &dataSize);
rv = transferable->GetTransferData(kHTMLMime, getter_AddRefs(supports),
&dataSize);
data = do_QueryInterface(supports);
if (NS_SUCCEEDED(rv)) {
data->GetData(mHtmlString);
}
rv = transferable->GetTransferData(kHTMLContext, getter_AddRefs(data), &dataSize);
rv = transferable->GetTransferData(kHTMLContext, getter_AddRefs(supports),
&dataSize);
data = do_QueryInterface(supports);
if (NS_SUCCEEDED(rv)) {
data->GetData(mContextString);
}
rv = transferable->GetTransferData(kHTMLInfo, getter_AddRefs(data), &dataSize);
rv = transferable->GetTransferData(kHTMLInfo, getter_AddRefs(supports),
&dataSize);
data = do_QueryInterface(supports);
if (NS_SUCCEEDED(rv)) {
data->GetData(mInfoString);
}
rv = transferable->GetTransferData(kUnicodeMime, getter_AddRefs(data), &dataSize);
rv = transferable->GetTransferData(kUnicodeMime, getter_AddRefs(supports),
&dataSize);
data = do_QueryInterface(supports);
NS_ENSURE_SUCCESS(rv, rv); // require plain text at a minimum
data->GetData(mTitleString);
}

View File

@ -62,7 +62,12 @@ nsHostObjectURI::Read(nsIObjectInputStream* aStream)
nsresult rv = nsSimpleURI::Read(aStream);
NS_ENSURE_SUCCESS(rv, rv);
return NS_ReadOptionalObject(aStream, true, getter_AddRefs(mPrincipal));
nsCOMPtr<nsISupports> supports;
rv = NS_ReadOptionalObject(aStream, true, getter_AddRefs(supports));
NS_ENSURE_SUCCESS(rv, rv);
mPrincipal = do_QueryInterface(supports, &rv);
return rv;
}
NS_IMETHODIMP

View File

@ -536,10 +536,13 @@ nsPicoService::Init()
MonitorAutoLock autoLock(mVoicesMonitor);
while (hasMoreElements && NS_SUCCEEDED(rv)) {
nsCOMPtr<nsIFile> voiceFile;
rv = dirIterator->GetNext(getter_AddRefs(voiceFile));
nsCOMPtr<nsISupports> supports;
rv = dirIterator->GetNext(getter_AddRefs(supports));
MOZ_ASSERT(NS_SUCCEEDED(rv));
nsCOMPtr<nsIFile> voiceFile = do_QueryInterface(supports);
MOZ_ASSERT(voiceFile);
nsAutoCString leafName;
voiceFile->GetNativeLeafName(leafName);

View File

@ -2247,7 +2247,9 @@ nsXULPrototypeElement::Deserialize(nsIObjectInputStream* aStream,
rv = tmp;
}
} else {
tmp = aStream->ReadObject(true, getter_AddRefs(script->mSrcURI));
nsCOMPtr<nsISupports> supports;
tmp = aStream->ReadObject(true, getter_AddRefs(supports));
script->mSrcURI = do_QueryInterface(supports);
if (NS_FAILED(tmp)) {
rv = tmp;
}

View File

@ -229,7 +229,9 @@ nsXULPrototypeDocument::Read(nsIObjectInputStream* aStream)
{
nsresult rv;
rv = aStream->ReadObject(true, getter_AddRefs(mURI));
nsCOMPtr<nsISupports> supports;
rv = aStream->ReadObject(true, getter_AddRefs(supports));
mURI = do_QueryInterface(supports);
uint32_t count, i;
nsCOMPtr<nsIURI> styleOverlayURI;
@ -243,17 +245,19 @@ nsXULPrototypeDocument::Read(nsIObjectInputStream* aStream)
}
for (i = 0; i < count; ++i) {
tmp = aStream->ReadObject(true, getter_AddRefs(styleOverlayURI));
tmp = aStream->ReadObject(true, getter_AddRefs(supports));
if (NS_FAILED(tmp)) {
rv = tmp;
}
styleOverlayURI = do_QueryInterface(supports);
mStyleSheetReferences.AppendObject(styleOverlayURI);
}
// nsIPrincipal mNodeInfoManager->mPrincipal
nsCOMPtr<nsIPrincipal> principal;
tmp = aStream->ReadObject(true, getter_AddRefs(principal));
tmp = aStream->ReadObject(true, getter_AddRefs(supports));
principal = do_QueryInterface(supports);
if (NS_FAILED(tmp)) {
rv = tmp;
}

View File

@ -316,10 +316,12 @@ nsXULTemplateQueryProcessorXML::GenerateResults(nsISupports* aDatasource,
if (!xmlquery)
return NS_ERROR_INVALID_ARG;
nsCOMPtr<nsISupports> supports;
nsCOMPtr<nsIDOMNode> context;
if (aRef)
aRef->GetBindingObjectFor(xmlquery->GetMemberVariable(),
getter_AddRefs(context));
getter_AddRefs(supports));
context = do_QueryInterface(supports);
if (!context)
context = mRoot;

View File

@ -139,10 +139,12 @@ FilePickerParent::Done(int16_t aResult)
nsCOMPtr<nsISimpleEnumerator> iter;
NS_ENSURE_SUCCESS_VOID(mFilePicker->GetFiles(getter_AddRefs(iter)));
nsCOMPtr<nsISupports> supports;
nsCOMPtr<nsIFile> file;
bool loop = true;
while (NS_SUCCEEDED(iter->HasMoreElements(&loop)) && loop) {
iter->GetNext(getter_AddRefs(file));
iter->GetNext(getter_AddRefs(supports));
file = do_QueryInterface(supports);
nsCOMPtr<nsIDOMFile> domfile = new nsDOMFileFile(file);
domfiles.AppendElement(domfile);
}

View File

@ -1293,8 +1293,10 @@ nsJSURI::Read(nsIObjectInputStream* aStream)
if (NS_FAILED(rv)) return rv;
if (haveBase) {
rv = aStream->ReadObject(true, getter_AddRefs(mBaseURI));
nsCOMPtr<nsISupports> supports;
rv = aStream->ReadObject(true, getter_AddRefs(supports));
if (NS_FAILED(rv)) return rv;
mBaseURI = do_QueryInterface(supports);
}
return NS_OK;

View File

@ -1423,18 +1423,22 @@ ReadScriptOrFunction(nsIObjectInputStream *stream, JSContext *cx,
nsJSPrincipals* principal = nullptr;
nsCOMPtr<nsIPrincipal> readPrincipal;
if (flags & HAS_PRINCIPALS_FLAG) {
rv = stream->ReadObject(true, getter_AddRefs(readPrincipal));
nsCOMPtr<nsISupports> supports;
rv = stream->ReadObject(true, getter_AddRefs(supports));
if (NS_FAILED(rv))
return rv;
readPrincipal = do_QueryInterface(supports);
principal = nsJSPrincipals::get(readPrincipal);
}
nsJSPrincipals* originPrincipal = nullptr;
nsCOMPtr<nsIPrincipal> readOriginPrincipal;
if (flags & HAS_ORIGIN_PRINCIPALS_FLAG) {
rv = stream->ReadObject(true, getter_AddRefs(readOriginPrincipal));
nsCOMPtr<nsISupports> supports;
rv = stream->ReadObject(true, getter_AddRefs(supports));
if (NS_FAILED(rv))
return rv;
readOriginPrincipal = do_QueryInterface(supports);
originPrincipal = nsJSPrincipals::get(readOriginPrincipal);
}

View File

@ -238,8 +238,10 @@ InitOperators(void)
nsAutoCString name;
nsAutoString attributes;
while ((NS_SUCCEEDED(iterator->HasMoreElements(&more))) && more) {
nsCOMPtr<nsISupports> supports;
nsCOMPtr<nsIPropertyElement> element;
if (NS_SUCCEEDED(iterator->GetNext(getter_AddRefs(element)))) {
if (NS_SUCCEEDED(iterator->GetNext(getter_AddRefs(supports)))) {
element = do_QueryInterface(supports);
if (NS_SUCCEEDED(element->GetKey(name)) &&
NS_SUCCEEDED(element->GetValue(attributes))) {
// expected key: operator.\uNNNN.{infix,postfix,prefix}

View File

@ -120,10 +120,17 @@ nsJARURI::Read(nsIObjectInputStream* aInputStream)
{
nsresult rv;
rv = aInputStream->ReadObject(true, getter_AddRefs(mJARFile));
nsCOMPtr<nsISupports> supports;
rv = aInputStream->ReadObject(true, getter_AddRefs(supports));
NS_ENSURE_SUCCESS(rv, rv);
rv = aInputStream->ReadObject(true, getter_AddRefs(mJAREntry));
mJARFile = do_QueryInterface(supports, &rv);
NS_ENSURE_SUCCESS(rv, rv);
rv = aInputStream->ReadObject(true, getter_AddRefs(supports));
NS_ENSURE_SUCCESS(rv, rv);
mJAREntry = do_QueryInterface(supports);
NS_ENSURE_SUCCESS(rv, rv);
rv = aInputStream->ReadCString(mCharsetHint);

View File

@ -1049,7 +1049,9 @@ pref_LoadPrefsInDir(nsIFile* aDir, char const *const *aSpecialFiles, uint32_t aS
while (hasMoreElements && NS_SUCCEEDED(rv)) {
nsAutoCString leafName;
rv = dirIterator->GetNext(getter_AddRefs(prefFile));
nsCOMPtr<nsISupports> supports;
rv = dirIterator->GetNext(getter_AddRefs(supports));
prefFile = do_QueryInterface(supports);
if (NS_FAILED(rv)) {
break;
}

View File

@ -29,7 +29,11 @@ nsSimpleNestedURI::Read(nsIObjectInputStream* aStream)
NS_ASSERTION(!mMutable, "How did that happen?");
rv = aStream->ReadObject(true, getter_AddRefs(mInnerURI));
nsCOMPtr<nsISupports> supports;
rv = aStream->ReadObject(true, getter_AddRefs(supports));
if (NS_FAILED(rv)) return rv;
mInnerURI = do_QueryInterface(supports, &rv);
if (NS_FAILED(rv)) return rv;
NS_TryToSetImmutable(mInnerURI);

View File

@ -4066,10 +4066,13 @@ nsCookieService::RemoveCookiesForApp(uint32_t aAppId, bool aOnlyBrowserElement)
bool hasMore;
while (NS_SUCCEEDED(enumerator->HasMoreElements(&hasMore)) && hasMore) {
nsCOMPtr<nsISupports> supports;
nsCOMPtr<nsICookie> cookie;
rv = enumerator->GetNext(getter_AddRefs(cookie));
rv = enumerator->GetNext(getter_AddRefs(supports));
NS_ENSURE_SUCCESS(rv, rv);
cookie = do_QueryInterface(supports);
nsAutoCString host;
cookie->GetHost(host);

View File

@ -125,9 +125,11 @@ nsStreamConverterService::BuildGraph() {
if (NS_FAILED(rv)) return rv;
// go through each entry to build the graph
nsCOMPtr<nsISupports> supports;
nsCOMPtr<nsISupportsCString> entry;
rv = entries->GetNext(getter_AddRefs(entry));
rv = entries->GetNext(getter_AddRefs(supports));
while (NS_SUCCEEDED(rv)) {
entry = do_QueryInterface(supports);
// get the entry string
nsAutoCString entryString;
@ -142,7 +144,7 @@ nsStreamConverterService::BuildGraph() {
rv = AddAdjacency(contractID.get());
if (NS_FAILED(rv)) return rv;
rv = entries->GetNext(getter_AddRefs(entry));
rv = entries->GetNext(getter_AddRefs(supports));
}
return NS_OK;

View File

@ -583,8 +583,11 @@ PendingLookup::ParseCertificates(
NS_ENSURE_SUCCESS(rv, rv);
while (hasMoreChains) {
nsCOMPtr<nsIX509CertList> certList = nullptr;
rv = chains->GetNext(getter_AddRefs(certList));
nsCOMPtr<nsISupports> supports;
rv = chains->GetNext(getter_AddRefs(supports));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIX509CertList> certList = do_QueryInterface(supports, &rv);
NS_ENSURE_SUCCESS(rv, rv);
safe_browsing::ClientDownloadRequest_CertificateChain* certChain =
@ -597,8 +600,11 @@ PendingLookup::ParseCertificates(
bool hasMoreCerts = false;
rv = chainElt->HasMoreElements(&hasMoreCerts);
while (hasMoreCerts) {
nsCOMPtr<nsIX509Cert> cert = nullptr;
rv = chainElt->GetNext(getter_AddRefs(cert));
nsCOMPtr<nsISupports> supports;
rv = chainElt->GetNext(getter_AddRefs(supports));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIX509Cert> cert = do_QueryInterface(supports, &rv);
NS_ENSURE_SUCCESS(rv, rv);
uint8_t* data = nullptr;

View File

@ -554,8 +554,9 @@ nsresult nsCharsetMenu::RefreshMaileditMenu()
NS_ENSURE_SUCCESS(res, res);
// clear the menu
nsCOMPtr<nsIRDFNode> node;
while (NS_SUCCEEDED(enumerator->GetNext(getter_AddRefs(node)))) {
nsCOMPtr<nsISupports> supports;
while (NS_SUCCEEDED(enumerator->GetNext(getter_AddRefs(supports)))) {
nsCOMPtr<nsIRDFNode> node = do_QueryInterface(supports);
res = mInner->Unassert(kNC_MaileditCharsetMenuRoot, kNC_Name, node);
NS_ENSURE_SUCCESS(res, res);

View File

@ -1974,8 +1974,9 @@ Database::Observe(nsISupports *aSubject,
getter_AddRefs(e))) && e) {
bool hasMore = false;
while (NS_SUCCEEDED(e->HasMoreElements(&hasMore)) && hasMore) {
nsCOMPtr<nsIObserver> observer;
if (NS_SUCCEEDED(e->GetNext(getter_AddRefs(observer)))) {
nsCOMPtr<nsISupports> supports;
if (NS_SUCCEEDED(e->GetNext(getter_AddRefs(supports)))) {
nsCOMPtr<nsIObserver> observer = do_QueryInterface(supports);
(void)observer->Observe(observer, TOPIC_PLACES_INIT_COMPLETE, nullptr);
}
}

View File

@ -414,10 +414,12 @@ Classifier::ScanStoreDir(nsTArray<nsCString>& aTables)
bool hasMore;
while (NS_SUCCEEDED(rv = entries->HasMoreElements(&hasMore)) && hasMore) {
nsCOMPtr<nsIFile> file;
rv = entries->GetNext(getter_AddRefs(file));
nsCOMPtr<nsISupports> supports;
rv = entries->GetNext(getter_AddRefs(supports));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIFile> file = do_QueryInterface(supports);
nsCString leafName;
rv = file->GetNativeLeafName(leafName);
NS_ENSURE_SUCCESS(rv, rv);

View File

@ -1977,9 +1977,10 @@ SetCurrentProfileAsDefault(nsIToolkitProfileService* aProfileSvc,
return rv;
bool foundMatchingProfile = false;
nsCOMPtr<nsIToolkitProfile> profile;
rv = profiles->GetNext(getter_AddRefs(profile));
nsCOMPtr<nsISupports> supports;
rv = profiles->GetNext(getter_AddRefs(supports));
while (NS_SUCCEEDED(rv)) {
nsCOMPtr<nsIToolkitProfile> profile = do_QueryInterface(supports);
nsCOMPtr<nsIFile> profileRoot;
profile->GetRootDir(getter_AddRefs(profileRoot));
profileRoot->Equals(aCurrentProfileRoot, &foundMatchingProfile);
@ -1989,7 +1990,7 @@ SetCurrentProfileAsDefault(nsIToolkitProfileService* aProfileSvc,
rv = aProfileSvc->Flush();
return rv;
}
rv = profiles->GetNext(getter_AddRefs(profile));
rv = profiles->GetNext(getter_AddRefs(supports));
}
return rv;
}

View File

@ -812,8 +812,11 @@ nsDataObj::GetDib(const nsACString& inFlavor,
// This might not be necessary any more, but could be useful for backwards
// compatibility.
nsCOMPtr<nsISupportsInterfacePointer> ptr(do_QueryInterface(genericDataWrapper));
if ( ptr )
ptr->GetData(getter_AddRefs(image));
if ( ptr ) {
nsCOMPtr<nsISupports> supports;
ptr->GetData(getter_AddRefs(supports));
image = do_QueryInterface(supports);
}
}
if ( image ) {
@ -1359,8 +1362,11 @@ HRESULT nsDataObj::DropFile(FORMATETC& aFE, STGMEDIUM& aSTG)
if (!file)
{
nsCOMPtr<nsISupportsInterfacePointer> ptr(do_QueryInterface(genericDataWrapper));
if (ptr)
ptr->GetData(getter_AddRefs(file));
if (ptr) {
nsCOMPtr<nsISupports> supports;
ptr->GetData(getter_AddRefs(supports));
file = do_QueryInterface(supports);
}
}
if (!file)
@ -1423,8 +1429,11 @@ HRESULT nsDataObj::DropImage(FORMATETC& aFE, STGMEDIUM& aSTG)
// This might not be necessary any more, but could be useful for backwards
// compatibility.
nsCOMPtr<nsISupportsInterfacePointer> ptr(do_QueryInterface(genericDataWrapper));
if (ptr)
ptr->GetData(getter_AddRefs(image));
if (ptr) {
nsCOMPtr<nsISupports> supports;
ptr->GetData(getter_AddRefs(supports));
image = do_QueryInterface(supports);
}
}
if (!image)

View File

@ -156,11 +156,13 @@ nsMemoryImpl::RunFlushers(const char16_t* aReason)
while (NS_SUCCEEDED(e->HasMoreElements(&loop)) && loop)
{
e->GetNext(getter_AddRefs(observer));
nsCOMPtr<nsISupports> supports;
e->GetNext(getter_AddRefs(supports));
if (!observer)
if (!supports)
continue;
observer = do_QueryInterface(supports);
observer->Observe(observer, "memory-pressure", aReason);
}
}

View File

@ -1411,12 +1411,6 @@ class nsGetterAddRefs
{
return reinterpret_cast<void**>(mTargetSmartPtr.StartAssignment());
}
operator nsISupports**()
{
return reinterpret_cast<nsISupports**>(mTargetSmartPtr.StartAssignment());
}
operator T**()
{
return mTargetSmartPtr.StartAssignment();

View File

@ -673,9 +673,11 @@ nsLocalFile::CopyDirectoryTo(nsIFile *newParent)
bool hasMore = false;
while (dirIterator->HasMoreElements(&hasMore), hasMore) {
nsCOMPtr<nsISupports> supports;
nsCOMPtr<nsIFile> entry;
rv = dirIterator->GetNext((nsISupports**)getter_AddRefs(entry));
if (NS_FAILED(rv))
rv = dirIterator->GetNext(getter_AddRefs(supports));
entry = do_QueryInterface(supports);
if (NS_FAILED(rv) || !entry)
continue;
if (NS_FAILED(rv = entry->IsSymlink(&isSymlink)))
return rv;

View File

@ -543,7 +543,6 @@ main()
AnIFooPtrPtrContext( getter_AddRefs(fooP) );
AVoidPtrPtrContext( getter_AddRefs(fooP) );
AnISupportsPtrPtrContext( getter_AddRefs(fooP) );
}

View File

@ -120,7 +120,9 @@ int main(int argc, char *argv[])
bool loop = true;
while( NS_SUCCEEDED(e->HasMoreElements(&loop)) && loop)
{
e->GetNext(getter_AddRefs(observer));
nsCOMPtr<nsISupports> supports;
e->GetNext(getter_AddRefs(supports));
observer = do_QueryInterface(supports);
printf("Calling observe on enumerated observer ");
printString(reinterpret_cast<TestObserver*>
(reinterpret_cast<void*>(observer.get()))->mName);