mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-22 17:21:35 +00:00
@ -125,6 +125,10 @@ impl<'a, 'b> Rust2Js<'a, 'b> {
|
|||||||
self.cx.expose_take_object();
|
self.cx.expose_take_object();
|
||||||
self.js_arguments.push(format!("takeObject({})", abi));
|
self.js_arguments.push(format!("takeObject({})", abi));
|
||||||
return Ok(())
|
return Ok(())
|
||||||
|
} else if arg.is_ref_anyref() {
|
||||||
|
self.cx.expose_get_object();
|
||||||
|
self.js_arguments.push(format!("getObject({})", abi));
|
||||||
|
return Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
if optional {
|
if optional {
|
||||||
@ -253,10 +257,6 @@ impl<'a, 'b> Rust2Js<'a, 'b> {
|
|||||||
ref d if d.is_number() => abi,
|
ref d if d.is_number() => abi,
|
||||||
Descriptor::Boolean => format!("{} !== 0", abi),
|
Descriptor::Boolean => format!("{} !== 0", abi),
|
||||||
Descriptor::Char => format!("String.fromCodePoint({})", abi),
|
Descriptor::Char => format!("String.fromCodePoint({})", abi),
|
||||||
ref d if d.is_ref_anyref() => {
|
|
||||||
self.cx.expose_get_object();
|
|
||||||
format!("getObject({})", abi)
|
|
||||||
}
|
|
||||||
_ => bail!(
|
_ => bail!(
|
||||||
"unimplemented argument type in imported function: {:?}",
|
"unimplemented argument type in imported function: {:?}",
|
||||||
arg
|
arg
|
||||||
|
@ -13,6 +13,11 @@ extern {
|
|||||||
fn return_null_byval() -> Option<MyType>;
|
fn return_null_byval() -> Option<MyType>;
|
||||||
fn return_some_byval() -> Option<MyType>;
|
fn return_some_byval() -> Option<MyType>;
|
||||||
fn test_option_values();
|
fn test_option_values();
|
||||||
|
|
||||||
|
#[wasm_bindgen(js_name = take_none_byval)]
|
||||||
|
fn take_none_byref(t: Option<&MyType>);
|
||||||
|
#[wasm_bindgen(js_name = take_some_byval)]
|
||||||
|
fn take_some_byref(t: Option<&MyType>);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[wasm_bindgen_test]
|
#[wasm_bindgen_test]
|
||||||
@ -24,7 +29,6 @@ fn import_by_value() {
|
|||||||
assert!(return_some_byval().is_some());
|
assert!(return_some_byval().is_some());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[wasm_bindgen_test]
|
#[wasm_bindgen_test]
|
||||||
fn export_by_value() {
|
fn export_by_value() {
|
||||||
test_option_values();
|
test_option_values();
|
||||||
@ -49,3 +53,9 @@ pub fn rust_return_none_byval() -> Option<MyType> {
|
|||||||
pub fn rust_return_some_byval() -> Option<MyType> {
|
pub fn rust_return_some_byval() -> Option<MyType> {
|
||||||
Some(MyType::new())
|
Some(MyType::new())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[wasm_bindgen_test]
|
||||||
|
fn import_by_ref() {
|
||||||
|
take_none_byref(None);
|
||||||
|
take_some_byref(Some(&MyType::new()));
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user