|QueryInterface()| and macros




20 years ago
14 years ago


(Reporter: bruce, Assigned: bruce)



Firefox Tracking Flags

(Not tracked)




20 years ago
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).


20 years ago
Target Milestone: M10

Comment 1

20 years ago
Thanks for filing this one and looking into better/more macros.  But this bug
shouldn't cause just bruce@cybersight.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

cc'ing scc, dp, and warren, who are the first among many XPCOM owners.


Comment 2

20 years ago
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.

Comment 3

20 years ago
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.

Comment 5

20 years ago
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.


20 years ago
Target Milestone: M10 → M15

Comment 6

20 years ago
I think most of these ended up getting done?  Getting off of beta radar.

Comment 7

19 years ago
This was done by someone long long ago.
Last Resolved: 19 years ago
Resolution: --- → FIXED


14 years ago
Component: XP Miscellany → XPCOM
You need to log in before you can comment on or make changes to this bug.