Closed Bug 1259706 Opened 4 years ago Closed 4 years ago

Add NS_INLINE_DECL_THREADSAFE_REFCOUNTING macro equivalent that declare AddRef and Release as virtual

Categories

(Core :: XPCOM, defect)

defect
Not set

Tracking

()

RESOLVED FIXED
mozilla48
Tracking Status
firefox48 --- fixed

People

(Reporter: jya, Assigned: jya)

Details

Attachments

(1 file)

It would be useful to be able to declare the AddRef and Release method as virtual so that they can be overridden in inheriting class.

Something like NS_INLINE_IDECL_THREADSAFE_REFCOUNTING

I think it would be much better if NS_INLINE_DECL_THREADSAFE_REFCOUNTING simply declared those functions as virtual all the time, but seeing it's been like this for over a decade it's probably preferred as it is.
Assignee: nobody → jyavenard
Blocks: 1259274
No longer blocks: 1259274
Attachment #8734703 - Flags: review?(nfroyd) → review+
Comment on attachment 8734703 [details]
MozReview Request: Bug 1259706: Add NS_INLINE_DECL_THREADSAFE_VIRTUAL_REFCOUNTING macro. r=froydnj

https://reviewboard.mozilla.org/r/42455/#review39623

r=me with the change below.  I think the name should feature `VIRTUAL` in it, but am happy to hear other suggestions for naming.

::: xpcom/glue/nsISupportsImpl.h:568
(Diff revision 1)
> +
> +/**
> + * Like NS_INLINE_DECL_THREADSAFE_REFCOUNTING with AddRef & Release declared
> + * virtual.
> + */
> +#define NS_INLINE_IDECL_THREADSAFE_REFCOUNTING(_class, ...)                   \

I think the `I` here is a little hard to miss.  Let's name it sort-of-consistently with the patches for bug 1184283.  Perhaps `NS_INLINE_DECL_THREADSAFE_VIRTUAL_REFCOUNTING`?
Sounds good to me with virtual.
I had used the "I" because the other addRef/Release declaration that are virtuals only differs by the letter I (NS_METHOD vs NS_IMETHOD)
Comment on attachment 8734703 [details]
MozReview Request: Bug 1259706: Add NS_INLINE_DECL_THREADSAFE_VIRTUAL_REFCOUNTING macro. r=froydnj

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/42455/diff/1-2/
Attachment #8734703 - Attachment description: MozReview Request: Bug 1259706: Add NS_INLINE_IDECL_THREADSAFE_REFCOUNTING macro. r?froydnj → MozReview Request: Bug 1259706: Add NS_INLINE_DECL_THREADSAFE_VIRTUAL_REFCOUNTING macro. r=froydnj
https://hg.mozilla.org/mozilla-central/rev/1e79766a6162
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla48
You need to log in before you can comment on or make changes to this bug.