diff --git a/mozilla/xpcom/base/nsISupportsBase.h b/mozilla/xpcom/base/nsISupportsBase.h index 708321bdc76..1d6806bb813 100644 --- a/mozilla/xpcom/base/nsISupportsBase.h +++ b/mozilla/xpcom/base/nsISupportsBase.h @@ -66,8 +66,6 @@ class NS_NO_VTABLE nsISupports { public: - NS_DECLARE_STATIC_IID_ACCESSOR(NS_ISUPPORTS_IID) - /** * @name Methods */ @@ -103,9 +101,5 @@ public: //@} }; - -NS_DEFINE_STATIC_IID_ACCESSOR(nsISupports, NS_ISUPPORTS_IID) - /*@}*/ - #endif diff --git a/mozilla/xpcom/glue/nsID.h b/mozilla/xpcom/glue/nsID.h index 1251148f47d..8b6820570bd 100644 --- a/mozilla/xpcom/glue/nsID.h +++ b/mozilla/xpcom/glue/nsID.h @@ -134,23 +134,13 @@ typedef nsID nsIID; const nsIID _name = _iidspec /** - * 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". + * A macro to build the static const IID accessor method */ #define NS_DECLARE_STATIC_IID_ACCESSOR(the_iid) \ - template \ - struct COMTypeInfo \ - { \ - static const nsIID kIID NS_HIDDEN; \ - }; \ - static const nsIID& GetIID() {return COMTypeInfo::kIID;} + static const nsIID& GetIID() {static const nsIID iid = the_iid; return iid;} -#define NS_DEFINE_STATIC_IID_ACCESSOR(the_interface, the_iid) \ - template \ - const nsIID the_interface::COMTypeInfo::kIID NS_HIDDEN = the_iid; +#define NS_DEFINE_STATIC_IID_ACCESSOR(the_interface, the_iid) /** * A macro to build the static const CID accessor method @@ -159,7 +149,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) nsCOMTypeInfo::GetIID() +#define NS_GET_TEMPLATE_IID(T) NS_GET_IID(T) #endif diff --git a/mozilla/xpcom/glue/nsISupportsUtils.h b/mozilla/xpcom/glue/nsISupportsUtils.h index a3f564b25cb..40a9590b29b 100644 --- a/mozilla/xpcom/glue/nsISupportsUtils.h +++ b/mozilla/xpcom/glue/nsISupportsUtils.h @@ -190,6 +190,26 @@ ns_if_addref( T expr ) #define NS_ISUPPORTS_CAST(__unambiguousBase, __expr) \ NS_STATIC_CAST(nsISupports*, NS_STATIC_CAST(__unambiguousBase, __expr)) +extern "C++" { +// ...because some one is accidentally including this file inside +// an |extern "C"| + +class nsISupports; + +template +struct nsCOMTypeInfo +{ + static const nsIID& GetIID() { return T::GetIID(); } +}; + +NS_SPECIALIZE_TEMPLATE +struct nsCOMTypeInfo +{ + static const nsIID& GetIID() { + static const nsIID iid_NS_ISUPPORTS_IID = NS_ISUPPORTS_IID; return iid_NS_ISUPPORTS_IID; + } +}; + // a type-safe shortcut for calling the |QueryInterface()| member function template inline @@ -203,4 +223,6 @@ CallQueryInterface( T* aSource, DestinationType** aDestination ) NS_REINTERPRET_CAST(void**, aDestination)); } +} // extern "C++" + #endif /* __nsISupportsUtils_h */