Fix generation for a fn with two string args

This commit is contained in:
Alex Crichton 2017-12-18 16:13:37 -08:00
parent d38a448f15
commit eebe8b21a2
2 changed files with 6 additions and 6 deletions

View File

@ -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 });

View File

@ -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#"