This commit is contained in:
🪞👃🪞 2025-07-19 08:42:08 +03:00
parent 291b917970
commit 238ac2e888
25 changed files with 1018 additions and 1147 deletions

View file

@ -50,7 +50,7 @@ impl ToTokens for ViewDef {
impl ViewDef {
fn generated (&self) -> impl ToTokens {
let Self(ViewMeta { output }, ViewImpl { block, exposed }) = self;
let Self(ViewMeta { output }, ViewImpl { block, .. }) = self;
let self_ty = &block.self_ty;
let builtins = self.builtins();
let exposed = self.exposed();
@ -63,7 +63,7 @@ impl ViewDef {
impl<'state> ::tengri::dsl::DslInto<
Box<dyn ::tengri::output::Render<#output> + 'state>
> for #self_ty {
fn try_dsl_into (&self, dsl: &impl ::tengri::dsl::Dsl)
fn dsl_into (&self, dsl: &impl ::tengri::dsl::Dsl)
-> Perhaps<Box<dyn ::tengri::output::Render<#output> + 'state>>
{
Ok(match dsl.val() { #builtins #exposed _ => return Ok(None) })
@ -74,7 +74,7 @@ impl ViewDef {
/// Expressions are handled by built-in functions
/// that operate over constants and symbols.
fn builtins (&self) -> impl ToTokens {
let Self(ViewMeta { output }, ViewImpl { block, exposed }) = self;
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()))?
@ -85,7 +85,7 @@ impl ViewDef {
}
/// Symbols are handled by user-taked functions that take no parameters but `&self`.
fn exposed (&self) -> impl ToTokens {
let Self(ViewMeta { output }, ViewImpl { block, exposed }) = self;
let Self(ViewMeta { .. }, ViewImpl { exposed, .. }) = self;
let exposed = exposed.iter().map(|(key, value)|write_quote(quote! {
#key => return Ok(Some(self.#value().boxed())),
}));