mirror of
https://codeberg.org/unspeaker/tengri.git
synced 2025-12-06 03:36:42 +01:00
input: sexpr defcom
This commit is contained in:
parent
61fd07bffd
commit
fa5ff90be6
1 changed files with 11 additions and 1 deletions
|
|
@ -1,6 +1,16 @@
|
||||||
use crate::*;
|
use crate::*;
|
||||||
|
|
||||||
#[macro_export] macro_rules! defcom {
|
#[macro_export] macro_rules! defcom {
|
||||||
|
([$self:ident, $app:ident:$App:ty] $(($Command:ident $((
|
||||||
|
$Variant:ident [$($($param:ident: $Param:ty),+)?] $expr:expr
|
||||||
|
))*))*) => {
|
||||||
|
$(#[derive(Clone, Debug)] pub enum $Command {
|
||||||
|
$($Variant $(($($Param),+))?),*
|
||||||
|
})*
|
||||||
|
$(command!(|$self: $Command, $app: $App|match $self {
|
||||||
|
$($Command::$Variant $(($($param),+))? => $expr),*
|
||||||
|
});)*
|
||||||
|
};
|
||||||
(|$self:ident, $app:ident:$App:ty| $($Command:ident { $(
|
(|$self:ident, $app:ident:$App:ty| $($Command:ident { $(
|
||||||
$Variant:ident $(($($param:ident: $Param:ty),+))? => $expr:expr
|
$Variant:ident $(($($param:ident: $Param:ty),+))? => $expr:expr
|
||||||
)* $(,)? })*) => {
|
)* $(,)? })*) => {
|
||||||
|
|
@ -10,7 +20,7 @@ use crate::*;
|
||||||
$(command!(|$self: $Command, $app: $App|match $self {
|
$(command!(|$self: $Command, $app: $App|match $self {
|
||||||
$($Command::$Variant $(($($param),+))? => $expr),*
|
$($Command::$Variant $(($($param),+))? => $expr),*
|
||||||
});)*
|
});)*
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#[macro_export] macro_rules! command {
|
#[macro_export] macro_rules! command {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue