use crate::host::Macroforge;
use crate::ts_syn::abi::MacroKind;
use serde::Serialize;
use std::sync::Arc;
pub const DYNAMIC_MODULE_MARKER: &str = "__DYNAMIC_MODULE__";
pub struct DerivedMacroDescriptor {
pub package: &'static str,
pub module: &'static str,
pub runtime: &'static [&'static str],
pub name: &'static str,
pub kind: MacroKind,
pub description: &'static str,
pub constructor: fn() -> Arc<dyn Macroforge>,
pub decorators: &'static [DecoratorDescriptor],
}
pub struct DecoratorDescriptor {
pub module: &'static str,
pub export: &'static str,
pub kind: DecoratorKind,
pub docs: &'static str,
}
#[derive(Debug, Clone, Copy, Serialize)]
#[serde(rename_all = "lowercase")]
pub enum DecoratorKind {
Class,
Property,
Method,
Accessor,
Parameter,
}
impl DecoratorKind {
pub fn ts_type(&self) -> &'static str {
match self {
DecoratorKind::Class => "ClassDecorator",
DecoratorKind::Property => "PropertyDecorator",
DecoratorKind::Method => "MethodDecorator",
DecoratorKind::Accessor => "MethodDecorator",
DecoratorKind::Parameter => "ParameterDecorator",
}
}
}
pub struct DerivedMacroRegistration {
pub descriptor: &'static DerivedMacroDescriptor,
}
#[derive(Debug, Clone, Serialize)]
pub struct DecoratorMetadata {
pub module: &'static str,
pub export: &'static str,
pub kind: DecoratorKind,
pub docs: &'static str,
}