mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-14 05:21:24 +00:00
Add support for mutable stack closures
This commit adds support for passing `&mut FnMut(..)` to JS via imports. These closures cannot be invoked recursively in JS (they invalidate themselves while they're being invoked) and otherwise work the same as `&Fn(..)` closures. Closes #123
This commit is contained in:
@ -495,7 +495,14 @@ impl ToTokens for ast::ImportFunction {
|
||||
::into_abi(#var, &mut __stack);
|
||||
});
|
||||
}
|
||||
ast::TypeKind::ByMutRef => panic!("urgh mut"),
|
||||
ast::TypeKind::ByMutRef => {
|
||||
abi_argument_names.push(name);
|
||||
abi_arguments.push(quote! { #name: u32 });
|
||||
arg_conversions.push(quote! {
|
||||
let #name = <#t as ::wasm_bindgen::convert::ToRefMutWasmBoundary>
|
||||
::to_abi_ref_mut(#name, &mut __stack);
|
||||
});
|
||||
}
|
||||
ast::TypeKind::ByRef => {
|
||||
abi_argument_names.push(name);
|
||||
abi_arguments.push(quote! { #name: u32 });
|
||||
|
Reference in New Issue
Block a user