Implement support for WebIDL Callback types

This commit adds support for the WebIDL `Callback` type by translating all
callbacks to the `js_sys::Function` type. This will enable passing raw JS values
into callbacks as well as Rust valus using the `Closure` type.

This commit doesn't currently implement "callback interfaces" in WebIDL, that's
left for a follow-up commit.
This commit is contained in:
Alex Crichton
2018-09-06 16:18:24 -07:00
parent 1cd2229c66
commit 457efc0f31
9 changed files with 176 additions and 38 deletions

View File

@@ -146,3 +146,13 @@ global.MixinFoo = class MixinFoo {
global.Overloads = class {
foo() {}
};
global.InvokeCallback = class {
invoke(f) { f(); }
callAdd(f) {
return f(1, 2);
}
callRepeat(f) {
return f('ab', 4);
}
};