зеркало из https://github.com/mozilla/pjs.git
Bug 313309 - Table-driven QI part 3 - use weak statics for interface IDs, r=shaver. This will break VC6 and gcc2.9x, which is ok
This commit is contained in:
Родитель
1922f0a162
Коммит
4543c02b83
|
@ -66,6 +66,8 @@
|
|||
class NS_NO_VTABLE nsISupports {
|
||||
public:
|
||||
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ISUPPORTS_IID)
|
||||
|
||||
/**
|
||||
* @name Methods
|
||||
*/
|
||||
|
@ -101,5 +103,9 @@ public:
|
|||
|
||||
//@}
|
||||
};
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(nsISupports, NS_ISUPPORTS_IID)
|
||||
|
||||
/*@}*/
|
||||
|
||||
#endif
|
||||
|
|
|
@ -134,13 +134,23 @@ typedef nsID nsIID;
|
|||
const nsIID _name = _iidspec
|
||||
|
||||
/**
|
||||
* A macro to build the static const IID accessor method
|
||||
* 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".
|
||||
*/
|
||||
|
||||
#define NS_DECLARE_STATIC_IID_ACCESSOR(the_iid) \
|
||||
static const nsIID& GetIID() {static const nsIID iid = the_iid; return iid;}
|
||||
template <class Dummy> \
|
||||
struct COMTypeInfo \
|
||||
{ \
|
||||
static const nsIID kIID NS_HIDDEN; \
|
||||
}; \
|
||||
static const nsIID& GetIID() {return COMTypeInfo<int>::kIID;}
|
||||
|
||||
#define NS_DEFINE_STATIC_IID_ACCESSOR(the_interface, the_iid)
|
||||
#define NS_DEFINE_STATIC_IID_ACCESSOR(the_interface, the_iid) \
|
||||
template <class Dummy> \
|
||||
const nsIID the_interface::COMTypeInfo<Dummy>::kIID NS_HIDDEN = the_iid;
|
||||
|
||||
/**
|
||||
* A macro to build the static const CID accessor method
|
||||
|
@ -149,7 +159,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) nsCOMTypeInfo<T>::GetIID()
|
||||
#define NS_GET_TEMPLATE_IID(T) NS_GET_IID(T)
|
||||
#define NS_GET_IID(T) (::T::COMTypeInfo<int>::kIID)
|
||||
#define NS_GET_TEMPLATE_IID(T) (T::template COMTypeInfo<int>::kIID)
|
||||
|
||||
#endif
|
||||
|
|
|
@ -190,26 +190,6 @@ 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 <class T>
|
||||
struct nsCOMTypeInfo
|
||||
{
|
||||
static const nsIID& GetIID() { return T::GetIID(); }
|
||||
};
|
||||
|
||||
NS_SPECIALIZE_TEMPLATE
|
||||
struct nsCOMTypeInfo<nsISupports>
|
||||
{
|
||||
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 <class T, class DestinationType>
|
||||
inline
|
||||
|
@ -223,6 +203,4 @@ CallQueryInterface( T* aSource, DestinationType** aDestination )
|
|||
NS_REINTERPRET_CAST(void**, aDestination));
|
||||
}
|
||||
|
||||
} // extern "C++"
|
||||
|
||||
#endif /* __nsISupportsUtils_h */
|
||||
|
|
Загрузка…
Ссылка в новой задаче