mirror of
https://github.com/rustwasm/wasm-bindgen.git
synced 2024-12-25 11:02:11 +03:00
Fix generation for a fn with two string args
This commit is contained in:
parent
d38a448f15
commit
eebe8b21a2
@ -169,7 +169,7 @@ fn bindgen(export_name: &syn::Lit,
|
||||
args.push(my_quote! { #ident: #i });
|
||||
}
|
||||
ast::Type::BorrowedStr => {
|
||||
malloc = !MALLOC_GENERATED.swap(true, Ordering::SeqCst);
|
||||
malloc = malloc || !MALLOC_GENERATED.swap(true, Ordering::SeqCst);
|
||||
let ptr = syn::Ident::from(format!("arg{}_ptr", i));
|
||||
let len = syn::Ident::from(format!("arg{}_len", i));
|
||||
args.push(my_quote! { #ptr: *const u8 });
|
||||
@ -182,7 +182,7 @@ fn bindgen(export_name: &syn::Lit,
|
||||
});
|
||||
}
|
||||
ast::Type::String => {
|
||||
malloc = !MALLOC_GENERATED.swap(true, Ordering::SeqCst);
|
||||
malloc = malloc || !MALLOC_GENERATED.swap(true, Ordering::SeqCst);
|
||||
let ptr = syn::Ident::from(format!("arg{}_ptr", i));
|
||||
let len = syn::Ident::from(format!("arg{}_len", i));
|
||||
args.push(my_quote! { #ptr: *mut u8 });
|
||||
|
@ -48,14 +48,14 @@ fn string_arguments() {
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
wasm_bindgen! {
|
||||
pub fn assert_foo(a: &str) {
|
||||
assert_eq!(a, "foo");
|
||||
}
|
||||
|
||||
pub fn assert_foo_and_bar(a: &str, b: &str) {
|
||||
assert_eq!(a, "foo2");
|
||||
assert_eq!(b, "bar");
|
||||
}
|
||||
|
||||
pub fn assert_foo(a: &str) {
|
||||
assert_eq!(a, "foo");
|
||||
}
|
||||
}
|
||||
"#)
|
||||
.file("test.js", r#"
|
||||
|
Loading…
Reference in New Issue
Block a user