change |CallQueryInterface| to handle situations where |nsISupports| is ambiguous.

This commit is contained in:
scc%netscape.com 1999-05-04 12:40:52 +00:00
parent a04bdb34e3
commit 470c0f17ac
6 changed files with 21 additions and 18 deletions

View File

@ -531,16 +531,16 @@ getter_AddRefs( nsCOMPtr<T>& aSmartPtr )
template <class T>
template <class SourceType, class DestinationType>
inline
nsresult
CallQueryInterface( nsISupports* aSource, nsCOMPtr<T>* aDestination )
CallQueryInterface( SourceType* aSource, nsCOMPtr<DestinationType>* aDestination )
// a type-safe shortcut for calling the |QueryInterface()| member function
{
NS_PRECONDITION(aSource, "null parameter");
NS_PRECONDITION(aDestination, "null parameter");
return aSource->QueryInterface(T::GetIID(), getter_AddRefs(*aDestination));
return aSource->QueryInterface(DestinationType::GetIID(), getter_AddRefs(*aDestination));
}

View File

@ -558,18 +558,19 @@ NS_IMETHODIMP _class::QueryInterface(REFNSIID aIID, void** aInstancePtr) \
// exists in "nsCOMPtr.h" for use with |nsCOMPtr|s.
extern "C++" {
// ...because some one is accidentally including this file inside an |extern "C"|
class nsISupports;
template <class T>
template <class SourceType, class DestinationType>
inline
nsresult
CallQueryInterface( nsISupports* aSource, T** aDestination )
CallQueryInterface( SourceType* aSource, DestinationType** aDestination )
// a type-safe shortcut for calling the |QueryInterface()| member function
{
NS_PRECONDITION(aSource, "null parameter");
return aSource->QueryInterface(T::GetIID(), aDestination);
return aSource->QueryInterface(DestinationType::GetIID(), aDestination);
}
} // extern "C++"

View File

@ -531,16 +531,16 @@ getter_AddRefs( nsCOMPtr<T>& aSmartPtr )
template <class T>
template <class SourceType, class DestinationType>
inline
nsresult
CallQueryInterface( nsISupports* aSource, nsCOMPtr<T>* aDestination )
CallQueryInterface( SourceType* aSource, nsCOMPtr<DestinationType>* aDestination )
// a type-safe shortcut for calling the |QueryInterface()| member function
{
NS_PRECONDITION(aSource, "null parameter");
NS_PRECONDITION(aDestination, "null parameter");
return aSource->QueryInterface(T::GetIID(), getter_AddRefs(*aDestination));
return aSource->QueryInterface(DestinationType::GetIID(), getter_AddRefs(*aDestination));
}

View File

@ -558,18 +558,19 @@ NS_IMETHODIMP _class::QueryInterface(REFNSIID aIID, void** aInstancePtr) \
// exists in "nsCOMPtr.h" for use with |nsCOMPtr|s.
extern "C++" {
// ...because some one is accidentally including this file inside an |extern "C"|
class nsISupports;
template <class T>
template <class SourceType, class DestinationType>
inline
nsresult
CallQueryInterface( nsISupports* aSource, T** aDestination )
CallQueryInterface( SourceType* aSource, DestinationType** aDestination )
// a type-safe shortcut for calling the |QueryInterface()| member function
{
NS_PRECONDITION(aSource, "null parameter");
return aSource->QueryInterface(T::GetIID(), aDestination);
return aSource->QueryInterface(DestinationType::GetIID(), aDestination);
}
} // extern "C++"

View File

@ -531,16 +531,16 @@ getter_AddRefs( nsCOMPtr<T>& aSmartPtr )
template <class T>
template <class SourceType, class DestinationType>
inline
nsresult
CallQueryInterface( nsISupports* aSource, nsCOMPtr<T>* aDestination )
CallQueryInterface( SourceType* aSource, nsCOMPtr<DestinationType>* aDestination )
// a type-safe shortcut for calling the |QueryInterface()| member function
{
NS_PRECONDITION(aSource, "null parameter");
NS_PRECONDITION(aDestination, "null parameter");
return aSource->QueryInterface(T::GetIID(), getter_AddRefs(*aDestination));
return aSource->QueryInterface(DestinationType::GetIID(), getter_AddRefs(*aDestination));
}

View File

@ -558,18 +558,19 @@ NS_IMETHODIMP _class::QueryInterface(REFNSIID aIID, void** aInstancePtr) \
// exists in "nsCOMPtr.h" for use with |nsCOMPtr|s.
extern "C++" {
// ...because some one is accidentally including this file inside an |extern "C"|
class nsISupports;
template <class T>
template <class SourceType, class DestinationType>
inline
nsresult
CallQueryInterface( nsISupports* aSource, T** aDestination )
CallQueryInterface( SourceType* aSource, DestinationType** aDestination )
// a type-safe shortcut for calling the |QueryInterface()| member function
{
NS_PRECONDITION(aSource, "null parameter");
return aSource->QueryInterface(T::GetIID(), aDestination);
return aSource->QueryInterface(DestinationType::GetIID(), aDestination);
}
} // extern "C++"