Closed Bug 1312319 Opened 8 years ago Closed 8 years ago

Add a NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING macro for pure virtual AddRef/Release functions

Categories

(Core :: XPCOM, defect)

52 Branch
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla54
Tracking Status
firefox52 --- wontfix
firefox54 --- fixed

People

(Reporter: kats, Assigned: kats)

Details

Attachments

(1 file)

What appears to be a common pattern in the code [1] 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. [1] See how many of the results in e.g. http://searchfox.org/mozilla-central/search?q=NS_IMETHOD_(MozExternalRefCountType)&case=false&regexp=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 [1]: NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING [1] 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 kgupta@mozilla.com: 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
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla54
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: