Open Bug 1721361 Opened 3 years ago Updated 2 years ago

xpidl: Trailing optional in arguments to void methods should generate default arguments in C++ header files

Categories

(Core :: XPCOM, enhancement)

Desktop
All
enhancement

Tracking

()

Tracking Status
firefox92 --- affected

People

(Reporter: Gijs, Unassigned)

References

(Blocks 1 open bug)

Details

We currently allow IDL files to specify [optional,default(foo)], but without the default() bit the resulting generated .h file doesn't specify a default, so C++ consumers have to provide the optional argument, which is unnecessarily verbose.

Where the default(x) annotation is not provided, we should create one for the relevant argument -- false for bool, 0 for uint, nullptr for interfaces/objects and jsval.

There's less of a point doing this for non-void methods, as the resulting header will have a non-optional final _retval argument without a default value.

Trivial searching suggests there are at least 16 methods that would benefit: https://searchfox.org/mozilla-central/search?q=void+.*+%5C%5Boptional&path=idl&case=false&regexp=true

Blocks: xpidl-warts
Type: defect → enhancement
You need to log in before you can comment on or make changes to this bug.