mirror of
https://github.com/rustwasm/wasm-bindgen.git
synced 2024-12-26 11:34:22 +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 });
|
args.push(my_quote! { #ident: #i });
|
||||||
}
|
}
|
||||||
ast::Type::BorrowedStr => {
|
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 ptr = syn::Ident::from(format!("arg{}_ptr", i));
|
||||||
let len = syn::Ident::from(format!("arg{}_len", i));
|
let len = syn::Ident::from(format!("arg{}_len", i));
|
||||||
args.push(my_quote! { #ptr: *const u8 });
|
args.push(my_quote! { #ptr: *const u8 });
|
||||||
@ -182,7 +182,7 @@ fn bindgen(export_name: &syn::Lit,
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
ast::Type::String => {
|
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 ptr = syn::Ident::from(format!("arg{}_ptr", i));
|
||||||
let len = syn::Ident::from(format!("arg{}_len", i));
|
let len = syn::Ident::from(format!("arg{}_len", i));
|
||||||
args.push(my_quote! { #ptr: *mut u8 });
|
args.push(my_quote! { #ptr: *mut u8 });
|
||||||
|
@ -48,14 +48,14 @@ fn string_arguments() {
|
|||||||
use wasm_bindgen::prelude::*;
|
use wasm_bindgen::prelude::*;
|
||||||
|
|
||||||
wasm_bindgen! {
|
wasm_bindgen! {
|
||||||
pub fn assert_foo(a: &str) {
|
|
||||||
assert_eq!(a, "foo");
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn assert_foo_and_bar(a: &str, b: &str) {
|
pub fn assert_foo_and_bar(a: &str, b: &str) {
|
||||||
assert_eq!(a, "foo2");
|
assert_eq!(a, "foo2");
|
||||||
assert_eq!(b, "bar");
|
assert_eq!(b, "bar");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn assert_foo(a: &str) {
|
||||||
|
assert_eq!(a, "foo");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
"#)
|
"#)
|
||||||
.file("test.js", r#"
|
.file("test.js", r#"
|
||||||
|
Loading…
Reference in New Issue
Block a user