Closed Bug 1097731 Opened 5 years ago Closed 5 years ago

inherit infallible wrapper method


(Core :: XPCOM, defect)

Not set





(Reporter: tromey, Assigned: tromey)



(1 file)

Currently the IDL-to-C++ translator will generate convenience wrappers
for infallible attributes, like:

  inline bool GetRecordProfileTimelineMarkers()
    bool result;
    mozilla::DebugOnly<nsresult> rv = GetRecordProfileTimelineMarkers(&result);
    return result;

However, as you can see from
... it can be hard to use these wrappers.  What happened there
is that the concrete class implemented the "ordinary" getter,
and this implementation shadowed the convenience wrapper.

It looked simple to change the translator to emit a "using"
declaration for the convenience method as well.  This makes it
straightforward to use the wrapper.
This patch adds "using" declarations so that infallible wrapper
methods are available on a class implementing the interface.

I have only tested this by rebuilding (and by hacking in a use of the
new wrapper), as I wasn't sure it was a worthwhile enough idea to push
through try.

This patch adds the using declaration to the NS_DECL_ and NS_FORWARD_
macros, but not the NS_FORWARD_SAFE_ macro.  The latter was omitted
because it seemed incorrect to me -- in that case the method can fail
if passed a NULL "to_".
Assignee: nobody → ttromey
Attachment #8521473 - Flags: review?(benjamin)
Attachment #8521473 - Flags: review?(benjamin) → review?(nfroyd)
Comment on attachment 8521473 [details] [diff] [review]
emit using declarations for infallible convenience methods

Review of attachment 8521473 [details] [diff] [review]:

This C++ behavior seems inconsistently weird to me, but...
Attachment #8521473 - Flags: review?(nfroyd) → review+
Keywords: checkin-needed
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla36
You need to log in before you can comment on or make changes to this bug.