use crate::deterred_map::DFunctionMacroType;
use crate::function_map::FunctionMacroType;
#[derive(Clone)]
pub struct ExtMacroBuilder {
pub(crate) macro_name: String,
pub(crate) macro_type: ExtMacroType,
pub(crate) args: Vec<String>,
pub(crate) macro_body: Option<ExtMacroBody>,
pub(crate) macro_desc: Option<String>,
}
impl ExtMacroBuilder {
pub fn new(macro_name: &str) -> Self {
Self {
macro_name: macro_name.to_string(),
macro_type: ExtMacroType::Function,
args: vec![],
macro_body: None,
macro_desc: None,
}
}
pub fn function(mut self, func: FunctionMacroType) -> Self {
self.macro_type = ExtMacroType::Function;
self.macro_body = Some(ExtMacroBody::Function(func));
self
}
pub fn deterred(mut self, func: DFunctionMacroType) -> Self {
self.macro_type = ExtMacroType::Deterred;
self.macro_body = Some(ExtMacroBody::Deterred(func));
self
}
pub fn args(mut self, args: &[impl AsRef<str>]) -> Self {
self.args = args.iter().map(|a| a.as_ref().to_string()).collect();
self
}
pub fn desc(mut self, description: &str) -> Self {
self.macro_desc.replace(description.to_string());
self
}
}
#[derive(Clone)]
pub(crate) enum ExtMacroType {
Function,
Deterred,
}
#[derive(Clone)]
pub(crate) enum ExtMacroBody {
Function(FunctionMacroType),
Deterred(DFunctionMacroType),
}