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