organic/src/wasm/macros.rs
2023-12-25 12:32:35 -05:00

22 lines
736 B
Rust

/// Write the implementation for the intermediate ast node.
///
/// This exists to make changing the type signature easier.
macro_rules! to_wasm {
($ostruct:ty, $istruct:ty, $original:ident, $wasm_context:ident, $standard_properties:ident, $fnbody:tt) => {
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> {
let $original = self;
let $standard_properties = self.to_wasm_standard_properties($wasm_context)?;
$fnbody
}
}
};
}
pub(crate) use to_wasm;