-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Support WebIDL callback functions #257
Comments
What's an |
Woops, yeah just meant that we have to give up ownership of anything the function closes over and move it into the function. |
@fitzgen Right, stdweb handles that by requiring callbacks to be |
For anything that needs |
I'm trying to get my head around this. Let's take a specific example ( Here's the relevant webidl callback Function = any(any... arguments);
[Throws]
long setTimeout(Function handler, optional long timeout = 0, any... arguments);
void clearTimeout(optional long handle = 0); And we want to generate the equivalent of #[wasm_bindgen]
extern {
fn setTimeout(handler: &Closure<FnMut()>, timeout: u32) -> f64;
fn clearTimeout(handle: f64);
}
So it looks like we don't actually generate anything for I'm just seeing if others agree this is the correct approach before I do any work. EDIT: Also we have to assume that the function will be called more than once, and we don't know when the function might be called, so we have to insist it is heap-allocated ( I think this feature is blocked on #503 because the current impl for variadic (assume one arg) is incompatible with this construct, we the default should probably be no args. |
For arguments to imported JS functions, I believe we want to use For returned values from imported JS functions/getters, I believe we want to use |
@fitzgen and I had a good talk about this today, and the conclusions were:
The actual method of acquiring a |
For context, the reason why it needs to be a Alternatively, we could move Let's get something working first and then think about it. Likely it won't matter since everyone will be using |
I've added support for this in #796 |
https://heycam.github.io/webidl/#idl-callback-functions
Example:
Should probably translate these intoFnMove(...) -> ...
since we can't be sure about the way the interfaces might use the callbacks.The text was updated successfully, but these errors were encountered: