mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-03-28 07:51:07 +00: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
|
name = name
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
self.rust_arguments.push(format!("{} ? 1 : 0", name));
|
self.rust_arguments.push(format!("{}", name));
|
||||||
}
|
}
|
||||||
Descriptor::Char => {
|
Descriptor::Char => {
|
||||||
self.js_arguments.push((name.clone(), "string".to_string()));
|
self.js_arguments.push((name.clone(), "string".to_string()));
|
||||||
|
@ -489,7 +489,7 @@ impl<'a, 'b> Rust2Js<'a, 'b> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
self.ret_expr = match *ty {
|
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(),
|
Descriptor::Char => "return JS.codePointAt(0);".to_string(),
|
||||||
_ => bail!(
|
_ => bail!(
|
||||||
"unsupported return type for calling JS function from Rust: {:?}",
|
"unsupported return type for calling JS function from Rust: {:?}",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user