-
-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wrap generic return values #108
Conversation
case "Promise": { | ||
str += ` | ||
const res = ${callOn}.${implFunc}(${argsSpread}); | ||
return res && res.then ? res.then(utils.tryWrapperForImpl) : res; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's make the code stricter. Only check res
is null if the return type is nullable, and if it's not null (or the return type is not nullable) just do res.then(utils.tryWrapperForImpl)
.
if (returnType.nullable) {
str += `
if (res === null) {
return res;
} else {
`;
}
str += `return res.then(utils.tryWrapperForImpl);`
if (returnType.nullable) {
str += "}";
}
Ditto for the two blocks below.
@@ -13,6 +13,7 @@ class Operation { | |||
this.idls = [idl]; | |||
this.name = idl.name; | |||
this.static = idl.static; | |||
this.generic = idl.idlType.generic; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This assumes that the return type of all potential overloads are the same. (That's why this.idls
is an array – all overloaded operations with the same name are grouped into the same Operation
object.)
* remove m postfix * add test normalize \r\n to \n on the test runner + make line-comment absorb \r\n correctly.
Resurrecting this would be helpful for the Streams Standard reference implementation, which has a |
Fixes wrapping of implementation classes for
Promise
,sequence
, andrecord
return types.Currently, when a operation returns a promise, array, or object, the generated output will be
which does not accomplish the goal of wrapping the implementation class for the objects contained inside.
Using promises as an example, the output should instead be: