Closed Bug 1312319 Opened 5 years ago Closed 5 years ago
Add a NS
_INLINE _DECL _PURE _VIRTUAL _REFCOUNTING macro for pure virtual Add Ref/Release functions
Bug 1312319 - Add a NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING macro and replace existing pure-virtual AddRef/Release declarations.
59 bytes, text/x-review-board-request
What appears to be a common pattern in the code  is to have an "interface" type of class (with pure virtual methods) and allow RefPtrs to this interface. That requires having pure virtual AddRef/Release functions on the interface. It would be nice to have a macro that expands to this: NS_IMETHOD_(MozExternalRefCountType) AddRef(void) = 0; NS_IMETHOD_(MozExternalRefCountType) Release(void) = 0; for use in such classes. Not sure if this belongs in MFBT or XPCOM glue. Classes that inherit from this interface can use one of the existing macros to provide an implementation of these functions, or can inherit the implementation from some other base class.  See how many of the results in e.g. http://searchfox.org/mozilla-central/search?q=NS_IMETHOD_(MozExternalRefCountType)&case=false®exp=false&path= have pure virtual functions.
Bump. I was just about to file this bug again but it looks like I already filed it :) Does anybody have objections to this?
There's even a name suggested at : NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING  http://searchfox.org/mozilla-central/rev/bf98cd4315b5efa1b28831001ad27d54df7bbb68/dom/flyweb/HttpServer.h#38
Assignee: nobody → bugmail
Summary: Add a macro for pure virtual AddRef/Release functions → Add a NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING macro for pure virtual AddRef/Release functions
No objection from me!
Comment on attachment 8830465 [details] Bug 1312319 - Add a NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING macro and replace existing pure-virtual AddRef/Release declarations. https://reviewboard.mozilla.org/r/107218/#review108616 Thanks for cleaning this up. Have to say that I'm kind of impressed that everybody declared it more-or-less the same way prior to this patch.
Attachment #8830465 - Flags: review?(nfroyd) → review+
Pushed by firstname.lastname@example.org: https://hg.mozilla.org/integration/autoland/rev/ff0000b808c5 Add a NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING macro and replace existing pure-virtual AddRef/Release declarations. r=froydnj
You need to log in before you can comment on or make changes to this bug.