use tectonic_errors::prelude::*;
use super::{Command, CommandArgument, CommandBehavior, CommandPrimitive};
use crate::{format::Format, symbols::SymbolTable, FormatVersion};
macro_rules! declare {
($typename:ident) => {
#[derive(Debug)]
pub struct $typename {}
impl CommandBehavior for $typename {
fn build(_version: FormatVersion, _symbols: &mut SymbolTable) -> Result<Self> {
Ok($typename {})
}
}
impl Command for $typename {
fn describe(&self, arg: CommandArgument) -> String {
format!("[{:?} {}]", self, arg)
}
fn primitives(&self) -> Vec<CommandPrimitive> {
Vec::new()
}
}
};
}
declare! { AssignToks }
declare! { AssignInt }
declare! { AssignDimen }
declare! { AssignGlue }
declare! { AssignMuGlue }
declare! { SetShape }
macro_rules! declare_call {
($typename:ident) => {
#[derive(Debug)]
pub struct $typename {}
impl CommandBehavior for $typename {
fn build(_version: FormatVersion, _symbols: &mut SymbolTable) -> Result<Self> {
Ok($typename {})
}
}
impl Command for $typename {
fn describe(&self, arg: CommandArgument) -> String {
format!("[{:?} {}]", self, arg)
}
fn primitives(&self) -> Vec<CommandPrimitive> {
Vec::new()
}
fn extended_info(&self, arg: CommandArgument, format: &Format) -> Option<String> {
Some(format.fmt_toklist(arg, true))
}
}
};
}
declare_call! { Call }
declare_call! { LongCall }
declare_call! { OuterCall }
declare_call! { LongOuterCall }
declare! { CharGiven }
declare! { MathGiven }
declare! { XetexMathGiven }
declare! { EndV }
declare! { UndefinedCs }
declare! { EndTemplate }
declare! { DontExpand }
declare! { GlueRef }
declare! { ShapeRef }
declare! { BoxRef }
declare! { Data }