#[derive(Debug, Clone)]
pub struct Class {
pub name: String,
pub supers: Vec<String>,
pub slots: Vec<Slot>,
}
#[derive(Debug, Clone)]
pub struct Slot {
pub name: String,
pub initarg: Option<String>,
pub accessor: Option<String>,
pub initform: Option<String>,
}
impl Class {
pub fn new(name: impl Into<String>) -> Self {
Self {
name: name.into(),
supers: Vec::new(),
slots: Vec::new(),
}
}
pub fn superclass(mut self, name: impl Into<String>) -> Self {
self.supers.push(name.into());
self
}
pub fn slot(mut self, slot: Slot) -> Self {
self.slots.push(slot);
self
}
}
impl Slot {
pub fn new(name: impl Into<String>) -> Self {
Self {
name: name.into(),
initarg: None,
accessor: None,
initform: None,
}
}
pub fn initarg(mut self, name: impl Into<String>) -> Self {
self.initarg = Some(name.into());
self
}
pub fn accessor(mut self, name: impl Into<String>) -> Self {
self.accessor = Some(name.into());
self
}
pub fn initform(mut self, form: impl Into<String>) -> Self {
self.initform = Some(form.into());
self
}
}