Benjamin Smedberg wrote:

On 3/26/2013 10:16 AM, Neil wrote:

Why does getter_AddRefs<T> have an operator nsISupports**? So far most of the uses I've found appear to be people enumerating an nsISimpleEnumerator directly into an nsCOMPtr<T> type, although the documented idl return value is nsISupports. Is this an acceptable paradigm?

No, I'll assert that it is not acceptable. If you're going to make assumptions about the types coming out of a nsISimpleEnumerator, you should at least have to write a static_cast<> so that the assumption is explicit. And unless both pieces of code are in C++, it's unlikely that this code would be correct and the static_cast is usually not safe.

If I've read the code correctly, it will at least assert in debug builds if the implicit cast was incorrect.

I think I tried to remove the nsISupports** operator before and ran into trouble with some weird edge cases, but I fully support us trying to do it again.

The cases I found:
23 nsISimpleEnumerator::GetNext
10 nsObjectInputStream::ReadObject
4 nsITransferable::GetTransferData (this was a Windows build; other widgets may or may not be affected)
3 NS_ReadOptionalObject
3 nsISupportsInterfacePointer::GetData
1 nsIChannelPolicy::GetContentSecurityPolicy
1 nsHttpChannel::GetCacheToken (yes it's a concrete class...)
1 nsIXULTemplateResult::GetBindingObjectFor
1 nsSupportsHashtable::Remove (should be an nsInterfaceHashtable)

--
Warning: May contain traces of nuts.
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to