mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-03-31 01:11:06 +00:00
Clean up a bit of duplication in codegen
This commit is contained in:
parent
7880545b3b
commit
9bc2718943
@ -415,33 +415,29 @@ impl ToTokens for ast::ImportFunction {
|
|||||||
abi_arguments.push(my_quote! {
|
abi_arguments.push(my_quote! {
|
||||||
#name: <#t as ::wasm_bindgen::convert::WasmBoundary>::Abi
|
#name: <#t as ::wasm_bindgen::convert::WasmBoundary>::Abi
|
||||||
});
|
});
|
||||||
if i == 0 && is_method {
|
let var = if i == 0 && is_method {
|
||||||
arg_conversions.push(my_quote! {
|
quote! { self }
|
||||||
let #name = <#t as ::wasm_bindgen::convert::WasmBoundary>
|
|
||||||
::into_abi(self, &mut __stack);
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
arg_conversions.push(my_quote! {
|
quote! { #name }
|
||||||
let #name = <#t as ::wasm_bindgen::convert::WasmBoundary>
|
};
|
||||||
::into_abi(#name, &mut __stack);
|
arg_conversions.push(my_quote! {
|
||||||
});
|
let #name = <#t as ::wasm_bindgen::convert::WasmBoundary>
|
||||||
}
|
::into_abi(#name, &mut __stack);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
ast::Type::ByMutRef(_) => panic!("urgh mut"),
|
ast::Type::ByMutRef(_) => panic!("urgh mut"),
|
||||||
ast::Type::ByRef(ref t) => {
|
ast::Type::ByRef(ref t) => {
|
||||||
abi_argument_names.push(name);
|
abi_argument_names.push(name);
|
||||||
abi_arguments.push(my_quote! { #name: u32 });
|
abi_arguments.push(my_quote! { #name: u32 });
|
||||||
if i == 0 && is_method {
|
let var = if i == 0 && is_method {
|
||||||
arg_conversions.push(my_quote! {
|
quote! { self }
|
||||||
let #name = <#t as ::wasm_bindgen::convert::ToRefWasmBoundary>
|
|
||||||
::to_abi_ref(self, &mut __stack);
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
arg_conversions.push(my_quote! {
|
quote! { #name }
|
||||||
let #name = <#t as ::wasm_bindgen::convert::ToRefWasmBoundary>
|
};
|
||||||
::to_abi_ref(#name, &mut __stack);
|
arg_conversions.push(my_quote! {
|
||||||
});
|
let #name = <#t as ::wasm_bindgen::convert::ToRefWasmBoundary>
|
||||||
}
|
::to_abi_ref(#var, &mut __stack);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user