From 5b3f3e053ae7296e89e1a010a120d5bd380bfdda Mon Sep 17 00:00:00 2001 From: Neil Rashbrook Date: Sun, 11 May 2014 10:47:11 +0100 Subject: [PATCH] Bug 514280 Only use nsCOMPtr for interfaces r=bsmedberg --- content/base/src/nsDocument.cpp | 7 +++++++ dom/ipc/ContentParent.cpp | 7 +++++++ dom/media/MediaManager.cpp | 12 +++++++++++ .../src/peerconnection/PeerConnectionImpl.cpp | 6 ++++++ .../android/nsAndroidHandlerApp.cpp | 7 +++++++ .../exthandler/android/nsMIMEInfoAndroid.cpp | 7 +++++++ xpcom/glue/nsID.h | 21 ++++++++++--------- xpcom/glue/nsISupportsImpl.h | 4 ++-- 8 files changed, 59 insertions(+), 12 deletions(-) diff --git a/content/base/src/nsDocument.cpp b/content/base/src/nsDocument.cpp index 4473504a24c4..f0b18ac9df54 100644 --- a/content/base/src/nsDocument.cpp +++ b/content/base/src/nsDocument.cpp @@ -315,6 +315,13 @@ struct FireChangeArgs { bool mHaveImageOverride; }; +// XXX Workaround for bug 980560 to maintain the existing broken semantics +template<> +struct nsIStyleRule::COMTypeInfo { + static const nsIID kIID NS_HIDDEN; +}; +const nsIID nsIStyleRule::COMTypeInfo::kIID = NS_ISTYLE_RULE_IID; + namespace mozilla { namespace dom { diff --git a/dom/ipc/ContentParent.cpp b/dom/ipc/ContentParent.cpp index ac9124820e3c..115d419377fa 100644 --- a/dom/ipc/ContentParent.cpp +++ b/dom/ipc/ContentParent.cpp @@ -298,6 +298,13 @@ MaybeTestPBackground() #endif } +// XXX Workaround for bug 986973 to maintain the existing broken semantics +template<> +struct nsIConsoleService::COMTypeInfo { + static const nsIID kIID NS_HIDDEN; +}; +const nsIID nsIConsoleService::COMTypeInfo::kIID = NS_ICONSOLESERVICE_IID; + namespace mozilla { namespace dom { diff --git a/dom/media/MediaManager.cpp b/dom/media/MediaManager.cpp index afe7f20b136e..0514a4f9a650 100644 --- a/dom/media/MediaManager.cpp +++ b/dom/media/MediaManager.cpp @@ -59,6 +59,18 @@ #undef GetCurrentTime #endif +// XXX Workaround for bug 986974 to maintain the existing broken semantics +template<> +struct nsIMediaDevice::COMTypeInfo { + static const nsIID kIID NS_HIDDEN; +}; +const nsIID nsIMediaDevice::COMTypeInfo::kIID = NS_IMEDIADEVICE_IID; +template<> +struct nsIMediaDevice::COMTypeInfo { + static const nsIID kIID NS_HIDDEN; +}; +const nsIID nsIMediaDevice::COMTypeInfo::kIID = NS_IMEDIADEVICE_IID; + namespace mozilla { #ifdef LOG diff --git a/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp b/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp index fdc29211a128..ace16ead0878 100644 --- a/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp +++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp @@ -148,6 +148,12 @@ PRLogModuleInfo *signalingLogInfo() { return logModuleInfo; } +// XXX Workaround for bug 998092 to maintain the existing broken semantics +template<> +struct nsISupportsWeakReference::COMTypeInfo { + static const nsIID kIID NS_HIDDEN; +}; +const nsIID nsISupportsWeakReference::COMTypeInfo::kIID = NS_ISUPPORTSWEAKREFERENCE_IID; namespace sipcc { diff --git a/uriloader/exthandler/android/nsAndroidHandlerApp.cpp b/uriloader/exthandler/android/nsAndroidHandlerApp.cpp index 8813275b781d..9885dab52051 100644 --- a/uriloader/exthandler/android/nsAndroidHandlerApp.cpp +++ b/uriloader/exthandler/android/nsAndroidHandlerApp.cpp @@ -55,6 +55,13 @@ nsAndroidHandlerApp::SetDetailedDescription(const nsAString & aDescription) return NS_OK; } +// XXX Workaround for bug 986975 to maintain the existing broken semantics +template<> +struct nsISharingHandlerApp::COMTypeInfo { + static const nsIID kIID NS_HIDDEN; +}; +const nsIID nsISharingHandlerApp::COMTypeInfo::kIID = NS_IHANDLERAPP_IID; + NS_IMETHODIMP nsAndroidHandlerApp::Equals(nsIHandlerApp *aHandlerApp, bool *aRetval) { diff --git a/uriloader/exthandler/android/nsMIMEInfoAndroid.cpp b/uriloader/exthandler/android/nsMIMEInfoAndroid.cpp index 88d149189e41..767f8f163bc6 100644 --- a/uriloader/exthandler/android/nsMIMEInfoAndroid.cpp +++ b/uriloader/exthandler/android/nsMIMEInfoAndroid.cpp @@ -402,6 +402,13 @@ nsMIMEInfoAndroid::SystemChooser::SetDetailedDescription(const nsAString&) { return NS_OK; } +// XXX Workaround for bug 986975 to maintain the existing broken semantics +template<> +struct nsIHandlerApp::COMTypeInfo { + static const nsIID kIID NS_HIDDEN; +}; +const nsIID nsIHandlerApp::COMTypeInfo::kIID = NS_IHANDLERAPP_IID; + nsresult nsMIMEInfoAndroid::SystemChooser::Equals(nsIHandlerApp *aHandlerApp, bool *aRetVal) { nsCOMPtr info = do_QueryInterface(aHandlerApp); diff --git a/xpcom/glue/nsID.h b/xpcom/glue/nsID.h index ba9dd526b738..dfeb4b67c122 100644 --- a/xpcom/glue/nsID.h +++ b/xpcom/glue/nsID.h @@ -113,19 +113,20 @@ typedef nsID nsIID; * A macro to build the static const IID accessor method. The Dummy * template parameter only exists so that the kIID symbol will be linked * properly (weak symbol on linux, gnu_linkonce on mac, multiple-definitions - * merged on windows). Dummy should always be instantiated as "int". + * merged on windows). Dummy should always be instantiated as "void". */ #define NS_DECLARE_STATIC_IID_ACCESSOR(the_iid) \ - template \ - struct COMTypeInfo \ - { \ - static const nsIID kIID NS_HIDDEN; \ - }; + template \ + struct COMTypeInfo; #define NS_DEFINE_STATIC_IID_ACCESSOR(the_interface, the_iid) \ - template \ - const nsIID the_interface::COMTypeInfo::kIID NS_HIDDEN = the_iid; + template \ + struct the_interface::COMTypeInfo { \ + static const nsIID kIID NS_HIDDEN; \ + }; \ + template \ + const nsIID the_interface::COMTypeInfo::kIID NS_HIDDEN = the_iid; /** * A macro to build the static const CID accessor method @@ -134,7 +135,7 @@ typedef nsID nsIID; #define NS_DEFINE_STATIC_CID_ACCESSOR(the_cid) \ static const nsID& GetCID() {static const nsID cid = the_cid; return cid;} -#define NS_GET_IID(T) (T::COMTypeInfo::kIID) -#define NS_GET_TEMPLATE_IID(T) (T::template COMTypeInfo::kIID) +#define NS_GET_IID(T) (T::COMTypeInfo::kIID) +#define NS_GET_TEMPLATE_IID(T) (T::template COMTypeInfo::kIID) #endif diff --git a/xpcom/glue/nsISupportsImpl.h b/xpcom/glue/nsISupportsImpl.h index 5cb66f8c28c1..a773065f428f 100644 --- a/xpcom/glue/nsISupportsImpl.h +++ b/xpcom/glue/nsISupportsImpl.h @@ -662,14 +662,14 @@ NS_IMETHODIMP _class::QueryInterface(REFNSIID aIID, void** aInstancePtr) \ static const QITableEntry table[] = { #define NS_INTERFACE_TABLE_ENTRY(_class, _interface) \ - { &_interface::COMTypeInfo::kIID, \ + { &NS_GET_IID(_interface), \ int32_t(reinterpret_cast( \ static_cast<_interface*>((_class*) 0x1000)) - \ reinterpret_cast((_class*) 0x1000)) \ }, #define NS_INTERFACE_TABLE_ENTRY_AMBIGUOUS(_class, _interface, _implClass) \ - { &_interface::COMTypeInfo::kIID, \ + { &NS_GET_IID(_interface), \ int32_t(reinterpret_cast( \ static_cast<_interface*>( \ static_cast<_implClass*>( \