2023-10-31 19:14:36 -04:00
|
|
|
/// Write the implementation for the render ast node.
|
|
|
|
|
///
|
|
|
|
|
/// This exists to make changing the type signature easier.
|
|
|
|
|
macro_rules! render {
|
2023-12-19 15:42:37 -05:00
|
|
|
($rstruct:ident, $istruct:ident, $original:ident, $render_context:ident, $fnbody:tt) => {
|
2023-10-31 19:14:36 -04:00
|
|
|
impl $rstruct {
|
|
|
|
|
pub(crate) fn new(
|
2023-12-19 17:31:50 -05:00
|
|
|
$render_context: RenderContext<'_>,
|
|
|
|
|
$original: &$istruct,
|
2023-10-31 19:14:36 -04:00
|
|
|
) -> Result<$rstruct, CustomError> {
|
|
|
|
|
$fnbody
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub(crate) use render;
|
|
|
|
|
|
|
|
|
|
/// Write the implementation for a render ast node that has no fields.
|
|
|
|
|
///
|
|
|
|
|
/// This exists to make changing the type signature easier.
|
|
|
|
|
macro_rules! rnoop {
|
|
|
|
|
($rstruct:ident, $istruct:ident) => {
|
|
|
|
|
impl $rstruct {
|
|
|
|
|
pub(crate) fn new(
|
2023-12-19 15:42:37 -05:00
|
|
|
_render_context: RenderContext<'_>,
|
2023-12-21 14:56:58 -05:00
|
|
|
original: &$istruct,
|
2023-10-31 19:14:36 -04:00
|
|
|
) -> Result<$rstruct, CustomError> {
|
2023-12-21 14:56:58 -05:00
|
|
|
Ok($rstruct {
|
|
|
|
|
post_blank: original.post_blank,
|
|
|
|
|
})
|
2023-10-31 19:14:36 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub(crate) use rnoop;
|
2025-02-08 18:13:55 -05:00
|
|
|
|
|
|
|
|
/// Push a file onto the render DependencyManager's file stack while inside the code block.
|
|
|
|
|
macro_rules! push_file {
|
|
|
|
|
($render_context:ident, $path:expr, $body:tt) => {{
|
|
|
|
|
$render_context
|
|
|
|
|
.dependency_manager
|
|
|
|
|
.lock()
|
|
|
|
|
.unwrap()
|
|
|
|
|
.push_file($path)?;
|
|
|
|
|
let ret = (|| $body)();
|
|
|
|
|
$render_context
|
|
|
|
|
.dependency_manager
|
|
|
|
|
.lock()
|
|
|
|
|
.unwrap()
|
|
|
|
|
.pop_file()?;
|
|
|
|
|
ret
|
|
|
|
|
}};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub(crate) use push_file;
|