Closed Bug 1097731 Opened 5 years ago Closed 5 years ago

inherit infallible wrapper method

Categories

(Core :: XPCOM, defect)

defect
Not set

Tracking

()

RESOLVED FIXED
mozilla36

People

(Reporter: tromey, Assigned: tromey)

Details

Attachments

(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);
    MOZ_ASSERT(NS_SUCCEEDED(rv));
    return result;
  }

However, as you can see from
https://bugzilla.mozilla.org/show_bug.cgi?id=1050774#c38
... 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
https://hg.mozilla.org/mozilla-central/rev/60c584a2bfa1
Status: NEW → RESOLVED
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.