diff --git a/mozilla/xpcom/base/nsISupportsUtils.h b/mozilla/xpcom/base/nsISupportsUtils.h index 95a9a39bda4..f7190a7d492 100644 --- a/mozilla/xpcom/base/nsISupportsUtils.h +++ b/mozilla/xpcom/base/nsISupportsUtils.h @@ -554,4 +554,18 @@ NS_IMETHODIMP _class::QueryInterface(REFNSIID aIID, void** aInstancePtr) \ //////////////////////////////////////////////////////////////////////////////// +// A type-safe interface for calling |QueryInterface()|. A similar implementation +// exists in "nsCOMPtr.h" for use with |nsCOMPtr|s. + +template +inline +nsresult +CallQueryInterface( nsISupports* aSource, T** aDestination ) + // a type-safe shortcut for calling the |QueryInterface()| member function + { + NS_PRECONDITION(aSource, "null parameter"); + + return aSource->QueryInterface(T::GetIID(), aDestination); + } + #endif /* __nsISupportsUtils_h */ diff --git a/mozilla/xpcom/glue/nsISupportsUtils.h b/mozilla/xpcom/glue/nsISupportsUtils.h index 95a9a39bda4..f7190a7d492 100644 --- a/mozilla/xpcom/glue/nsISupportsUtils.h +++ b/mozilla/xpcom/glue/nsISupportsUtils.h @@ -554,4 +554,18 @@ NS_IMETHODIMP _class::QueryInterface(REFNSIID aIID, void** aInstancePtr) \ //////////////////////////////////////////////////////////////////////////////// +// A type-safe interface for calling |QueryInterface()|. A similar implementation +// exists in "nsCOMPtr.h" for use with |nsCOMPtr|s. + +template +inline +nsresult +CallQueryInterface( nsISupports* aSource, T** aDestination ) + // a type-safe shortcut for calling the |QueryInterface()| member function + { + NS_PRECONDITION(aSource, "null parameter"); + + return aSource->QueryInterface(T::GetIID(), aDestination); + } + #endif /* __nsISupportsUtils_h */ diff --git a/mozilla/xpcom/public/nsISupportsUtils.h b/mozilla/xpcom/public/nsISupportsUtils.h index 95a9a39bda4..f7190a7d492 100644 --- a/mozilla/xpcom/public/nsISupportsUtils.h +++ b/mozilla/xpcom/public/nsISupportsUtils.h @@ -554,4 +554,18 @@ NS_IMETHODIMP _class::QueryInterface(REFNSIID aIID, void** aInstancePtr) \ //////////////////////////////////////////////////////////////////////////////// +// A type-safe interface for calling |QueryInterface()|. A similar implementation +// exists in "nsCOMPtr.h" for use with |nsCOMPtr|s. + +template +inline +nsresult +CallQueryInterface( nsISupports* aSource, T** aDestination ) + // a type-safe shortcut for calling the |QueryInterface()| member function + { + NS_PRECONDITION(aSource, "null parameter"); + + return aSource->QueryInterface(T::GetIID(), aDestination); + } + #endif /* __nsISupportsUtils_h */