Consider supporting [infallible] on XPCOM methods
Categories
(Core :: XPCOM, enhancement)
Tracking
()
Tracking | Status | |
---|---|---|
firefox82 | --- | fixed |
People
(Reporter: nika, Assigned: emilio)
Details
Attachments
(1 file, 1 obsolete file)
The [infallible]
method is currently supported on xpidl attributes, and causes a non-virtual overload which directly returns the value. It is only supported for builtinclass types, due to JS always being fallible.
It may be nice to also support this attribute on xpidl methods.
Comment 1•4 years ago
|
||
To be clear, we'd just return the return value directly, rather than through an outparam?
Comment 2•4 years ago
|
||
Yes. Nika and I were thinking of effectively desugaring something like this:
[infallible] returnType method(args);
into:
// For C++ callers
[notxpcom,nostdcall,binaryName="Method"] returnType binaryMethod(args);
// For JS callers
[binaryName="ScriptableMethod"] returnType method(args);
where the latter can be skipped if the interface or method is noscript. Not literally desugaring, since we'd need to implement at least part of this in the code generator; see below.
If the latter is not skipped, the codegen would spit out something like this for it in the interface's .h file:
NS_IMETHOD ScriptableMethod(args, returnType* aOut) final {
*aOut = BinaryMethod(args);
return NS_OK;
}
Modulo complications here around what happens if the returnType leads to a reference param, not a pointer, of course.
Assignee | ||
Comment 3•4 years ago
|
||
I've wanted to use this recently for a couple things. This uses the
same scheme and even templates we use for attributes, so it's mostly
moving code around...
Inverting the code generation so that the implementation is infallible,
and we actually generate the NS_IMETHOD goop inline somehow could be
potentially desirable, though that causes an extra virtual call for
non-C++ callers I guess, so maybe it's not such a great trade-off. Plus
it seems more complicated...
Explicitly forbid mixing infallible with notxpcom (as it doesn't make
sense), and similarly forbid infallible + returning void (as C++ doesn't
allow us to overload a function that differs only on its return type).
Updated•4 years ago
|
Assignee | ||
Comment 4•4 years ago
|
||
Updated•4 years ago
|
Pushed by ealvarez@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/f0615307a2f9 Support infallible xpcom methods, and use it for nsIURI.schemeIs. r=nika,xpcom-reviewers
Comment 6•4 years ago
|
||
bugherder |
Description
•