fix(input): sorting out event map

This commit is contained in:
🪞👃🪞 2025-07-19 19:53:02 +03:00
parent 238ac2e888
commit d72a3b5b8f
5 changed files with 155 additions and 316 deletions

View file

@ -60,10 +60,10 @@ impl ViewDef {
/// Makes [#self_ty] able to construct the [Render]able
/// which might correspond to a given [TokenStream],
/// while taking [#self_ty]'s state into consideration.
impl<'state> ::tengri::dsl::DslInto<
impl<'state> ::tengri::dsl::DslInto<'state,
Box<dyn ::tengri::output::Render<#output> + 'state>
> for #self_ty {
fn dsl_into (&self, dsl: &impl ::tengri::dsl::Dsl)
fn dsl_into (&'state self, dsl: &impl ::tengri::dsl::Dsl)
-> Perhaps<Box<dyn ::tengri::output::Render<#output> + 'state>>
{
Ok(match dsl.val() { #builtins #exposed _ => return Ok(None) })
@ -77,8 +77,11 @@ impl ViewDef {
let Self(ViewMeta { output }, ViewImpl { .. }) = self;
let builtins = builtins_with_boxes_output(quote! { #output }).map(|builtin|quote! {
::tengri::dsl::Val::Exp(_, expr) => return Ok(Some(
#builtin::from_dsl(self, expr, ||Box::new("failed to load builtin".into()))?
.boxed()
#builtin::from_dsl_or_else(
self,
&expr,
|| { format!("failed to load builtin").into() }
)?.boxed()
)),
});
quote! { #(#builtins)* }
@ -89,7 +92,7 @@ impl ViewDef {
let exposed = exposed.iter().map(|(key, value)|write_quote(quote! {
#key => return Ok(Some(self.#value().boxed())),
}));
quote! { ::tengri::dsl::Val::Sym(key) => match key.as_ref() { #(#exposed)* } }
quote! { ::tengri::dsl::Val::Sym(key) => match key.as_ref() { #(#exposed)* _ => panic!() } }
}
}