mirror of
https://codeberg.org/unspeaker/tengri.git
synced 2025-12-06 19:56:44 +01:00
This commit is contained in:
parent
7c1cddc759
commit
455d6d00d5
14 changed files with 252 additions and 286 deletions
|
|
@ -84,7 +84,7 @@ impl ToTokens for CommandDef {
|
|||
let mut out = TokenStream2::new();
|
||||
for (arg, ty) in arm.args() {
|
||||
write_quote_to(&mut out, quote! {
|
||||
#arg: Dsl::take_or_fail(self, words)?,
|
||||
#arg: FromDsl::take_from_or_fail(self, words)?,
|
||||
});
|
||||
}
|
||||
out
|
||||
|
|
@ -137,17 +137,22 @@ impl ToTokens for CommandDef {
|
|||
#[derive(Clone, Debug)] pub enum #command_enum { #(#variants)* }
|
||||
/// Not generated by [tengri_proc].
|
||||
#block
|
||||
/// Generated by [tengri_proc].
|
||||
/// Generated by [tengri_proc::command].
|
||||
///
|
||||
/// Means [#command_enum] is now a [Command] over [#state].
|
||||
/// Instances of [#command_enum] can be consumed by a
|
||||
/// mutable pointer to [#state], invoking predefined operations
|
||||
/// and optionally returning undo history data.
|
||||
impl ::tengri::input::Command<#state> for #command_enum {
|
||||
fn execute (self, state: &mut #state) -> Perhaps<Self> {
|
||||
match self { #(#implementations)* }
|
||||
}
|
||||
}
|
||||
/// Generated by [tengri_proc].
|
||||
impl ::tengri::dsl::FromDsl<#state> for #command_enum {
|
||||
fn take_from <'state, 'source: 'state> (
|
||||
/// Generated by [tengri_proc::command].
|
||||
impl<'source> ::tengri::dsl::FromDsl<'source, #state> for #command_enum {
|
||||
fn take_from <'state> (
|
||||
state: &'state #state,
|
||||
words: &mut TokenIter<'source>,
|
||||
words: &mut ::tengri::dsl::TokenIter<'source>
|
||||
) -> Perhaps<Self> {
|
||||
let mut words = words.clone();
|
||||
let token = words.next();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue