#[macro_export]
macro_rules! derive_wasm_abi {
($type:ty) => {
impl wasm_bindgen::describe::WasmDescribe for $type {
fn describe() {
<js_sys::Object as wasm_bindgen::describe::WasmDescribe>::describe()
}
}
};
($type:ty, FromWasmAbi $(, $symbols:tt)*) => {
impl wasm_bindgen::convert::FromWasmAbi for $type {
type Abi = <js_sys::Object as wasm_bindgen::convert::IntoWasmAbi>::Abi;
#[inline]
unsafe fn from_abi(js: Self::Abi) -> Self {
let obj = js_sys::Object::from_abi(js);
use $crate::utils::JsValueSerdeExt;
JsValue::from(obj).into_serde_ext().unwrap()
}
}
derive_wasm_abi!($type $(, $symbols)*);
};
($type:ty, IntoWasmAbi $(, $symbols:tt)*) => {
impl wasm_bindgen::convert::IntoWasmAbi for $type {
type Abi = <js_sys::Object as wasm_bindgen::convert::IntoWasmAbi>::Abi;
#[inline]
fn into_abi(self) -> Self::Abi {
use wasm_bindgen::JsCast;
<wasm_bindgen::JsValue as $crate::utils::JsValueSerdeExt>::from_serde_ext(&self).unwrap().unchecked_into::<js_sys::Object>().into_abi()
}
}
derive_wasm_abi!($type $(, $symbols)*);
};
}