The more |QueryInterface()| implementations I look at, the more I see that suck in one way or another. I need to look at writing a couple of macros to make the process of writing one easier in the cases that aren't covered by NS_IMPL_QUERYINTERFACE from nsISupportsUtils.h (and use that macro where possible as it isn't as widely used in the tree as it could be).
Thanks for filing this one and looking into better/more macros. But this bug shouldn't cause just email@example.com to sweep up after others. How about filing bugs against the individuals whose QI implementations suck, with pointers to http://www.mozilla.org/projects/xpcom/ docs that show to fix them using your macros? cc'ing scc, dp, and warren, who are the first among many XPCOM owners. /be
I've thought for some time that it would be nice to define a few more flavors of the NS_IMPL_ISUPPORTS macro. The problem with the current macro is that if you want to implement more than one interface, you can't use it. It would be nice to have: #define NS_IMPL_ISUPPORTS2(clazz, intf1, intf2) ... #define NS_IMPL_ISUPPORTS3(clazz, intf1, intf2, intf3) ... ... which would probably take care of 99% of the QI cases, making sure that QI got done right when the macros were used.
I had been thinking of doing this ... and then for those where a QI still had to be manually written, providing a couple of building-block macros, like the part that compares the IID and does the static cast. This sound acceptable? How many variants do we want to provide? Up to 6 interfaces? I haven't looked through the tree enough yet to see what classes might be out there implementing tons of interfaces.
Up to 6 would be good. There are ones that have more than that. But that number is like five rather than 100. So I think thats ok.
I think if you provided NS_IMPL_ISUPPORTS macros that handled up to 3 interfaces you'd cover most of the cases. I don't know if I'd add the more complicated building block ones though. In my experience people don't take the time to learn how to use complicated sets of macros. If it doesn't do exactly what they want and is completely obvious, they'll just write it from scratch.
I think most of these ended up getting done? Getting off of beta radar.
This was done by someone long long ago.
Status: ASSIGNED → RESOLVED
Last Resolved: 18 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.