Open Bug 1639123 Opened 5 years ago Updated 5 years ago

XPIDL: Improve integration with mozilla::Result in generated C++ code

Categories

(Core :: XPCOM, task)

task

Tracking

()

People

(Reporter: sg, Unassigned)

References

Details

Bug 1637605 added a generic function template ToResultInvoke which adapts a XPCOM-style function with a nsresult return value and an output parameter at the end of the parameter list. Using this generic function is rather brittle, a slightly nicer use requires a macro. This could be further simplified by either

  • generating a generic non-virtual, non-static member function template in every C++ interface that implicitly binds to the instance and calls the existing ToResultInvoke to adapt to mozilla::Result, or
  • generating non-virtual, non-static member functions for each function that calls the existing ToResultInvoke with the corresponding virtual member function to adapt to mozilla::Result,
  • generating non-virtual, non-static member functions for each function that contains custom code to call the corresponding virtual member function to adapt to mozilla::Result.

The latter could also support functions with multiple output parameters more easily than extending ToResultInvoke to support this case.

Note that in the meantime, a pair of macros (MOZ_TO_RESULT_INVOKE and MOZ_TO_RESULT_INVOKE_TYPED) has been added to make the use a bit more concise. Until now, there are ca. 180 uses of these macros (https://searchfox.org/mozilla-central/search?q=MOZ_TO_RESULT_INVOKE&path=). Solving this bug would allow returning to a more standard C++ syntax.

You need to log in before you can comment on or make changes to this bug.