mirror of
https://codeberg.org/unspeaker/tengri.git
synced 2025-12-06 03:36:42 +01:00
input, proc: add full paths in macros
This commit is contained in:
parent
20ccff13de
commit
fe8ecf8a98
2 changed files with 8 additions and 6 deletions
|
|
@ -18,15 +18,17 @@ pub trait Input: Send + Sync + Sized {
|
||||||
/// Implement the [Handle] trait.
|
/// Implement the [Handle] trait.
|
||||||
#[macro_export] macro_rules! handle {
|
#[macro_export] macro_rules! handle {
|
||||||
(|$self:ident:$Struct:ty,$input:ident|$handler:expr) => {
|
(|$self:ident:$Struct:ty,$input:ident|$handler:expr) => {
|
||||||
impl<E: Engine> Handle<E> for $Struct {
|
impl<E: Engine> ::tengri::input::Handle<E> for $Struct {
|
||||||
fn handle (&mut $self, $input: &E) -> Perhaps<E::Handled> {
|
fn handle (&mut $self, $input: &E) -> Perhaps<E::Handled> {
|
||||||
$handler
|
$handler
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
($E:ty: |$self:ident:$Struct:ty,$input:ident|$handler:expr) => {
|
($E:ty: |$self:ident:$Struct:ty,$input:ident|$handler:expr) => {
|
||||||
impl Handle<$E> for $Struct {
|
impl ::tengri::input::Handle<$E> for $Struct {
|
||||||
fn handle (&mut $self, $input: &$E) -> Perhaps<<$E as Input>::Handled> {
|
fn handle (&mut $self, $input: &$E) ->
|
||||||
|
Perhaps<<$E as ::tengri::input::Input>::Handled>
|
||||||
|
{
|
||||||
$handler
|
$handler
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,7 @@ impl ToTokens for CommandDef {
|
||||||
}
|
}
|
||||||
#block
|
#block
|
||||||
/// Generated by [tengri_proc].
|
/// Generated by [tengri_proc].
|
||||||
impl<'state> TryFromDsl<'state, #target> for #enumeration {
|
impl<'state> ::tengri::dsl::TryFromDsl<'state, #target> for #enumeration {
|
||||||
fn try_from_expr <'source: 'state> (
|
fn try_from_expr <'source: 'state> (
|
||||||
state: &'state #target, iter: &mut ::tengri::dsl::TokenIter<'source>
|
state: &'state #target, iter: &mut ::tengri::dsl::TokenIter<'source>
|
||||||
) -> Option<Self> {
|
) -> Option<Self> {
|
||||||
|
|
@ -88,7 +88,7 @@ impl ToTokens for CommandDef {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// Generated by [tengri_proc].
|
/// Generated by [tengri_proc].
|
||||||
impl Command<#target> for #enumeration {
|
impl ::tengri::input::Command<#target> for #enumeration {
|
||||||
fn execute (self, state: &mut #target) -> Perhaps<Self> {
|
fn execute (self, state: &mut #target) -> Perhaps<Self> {
|
||||||
match self {
|
match self {
|
||||||
#(#implementations)*
|
#(#implementations)*
|
||||||
|
|
@ -160,7 +160,7 @@ impl CommandArm {
|
||||||
let give_err = LitStr::new(&format!("{}: missing value for \"{}\" ({})",
|
let give_err = LitStr::new(&format!("{}: missing value for \"{}\" ({})",
|
||||||
quote!{#ident}, quote!{#arg}, quote!{#ty}), Span::call_site());
|
quote!{#ident}, quote!{#arg}, quote!{#ty}), Span::call_site());
|
||||||
write_quote_to(&mut out, quote! {
|
write_quote_to(&mut out, quote! {
|
||||||
#arg: Context::get(state, &mut iter).expect(#give_err),
|
#arg: ::tengri::dsl::Context::get(state, &mut iter).expect(#give_err),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
out
|
out
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue