mirror of
https://github.com/rustwasm/wasm-bindgen.git
synced 2024-11-24 06:33:33 +03:00
Don't convert boolean arguments going to wasm
The wasm spec defines boolean conversion when crossing to the wasm type i32 as 1 for `true` and 0 for `false`, so no need for us to do it ourselves!
This commit is contained in:
parent
a16b4dd9a4
commit
6093fd29d1
@ -401,7 +401,7 @@ impl<'a, 'b> Js2Rust<'a, 'b> {
|
||||
name = name
|
||||
));
|
||||
}
|
||||
self.rust_arguments.push(format!("{} ? 1 : 0", name));
|
||||
self.rust_arguments.push(format!("{}", name));
|
||||
}
|
||||
Descriptor::Char => {
|
||||
self.js_arguments.push((name.clone(), "string".to_string()));
|
||||
|
@ -489,7 +489,7 @@ impl<'a, 'b> Rust2Js<'a, 'b> {
|
||||
}
|
||||
|
||||
self.ret_expr = match *ty {
|
||||
Descriptor::Boolean => "return JS ? 1 : 0;".to_string(),
|
||||
Descriptor::Boolean => "return JS;".to_string(),
|
||||
Descriptor::Char => "return JS.codePointAt(0);".to_string(),
|
||||
_ => bail!(
|
||||
"unsupported return type for calling JS function from Rust: {:?}",
|
||||
|
Loading…
Reference in New Issue
Block a user