organic/src/wasm/macros.rs

23 lines
764 B
Rust
Raw Normal View History

2023-12-24 13:18:06 -05:00
/// Write the implementation for the intermediate ast node.
///
/// This exists to make changing the type signature easier.
macro_rules! to_wasm {
2023-12-25 12:32:35 -05:00
($ostruct:ty, $istruct:ty, $original:ident, $wasm_context:ident, $standard_properties:ident, $fnbody:tt) => {
2023-12-24 15:48:33 -05:00
impl<'s> ToWasm for $istruct {
type Output = $ostruct;
fn to_wasm(
&self,
$wasm_context: crate::wasm::to_wasm::ToWasmContext<'_>,
) -> Result<Self::Output, crate::error::CustomError> {
2023-12-25 12:32:35 -05:00
let $original = self;
2023-12-25 12:55:48 -05:00
let $standard_properties =
self.to_wasm_standard_properties($wasm_context.clone())?;
2023-12-24 13:18:06 -05:00
$fnbody
}
}
};
}
pub(crate) use to_wasm;