mirror of
https://codeberg.org/unspeaker/tengri.git
synced 2025-12-06 11:46:42 +01:00
This commit is contained in:
parent
21832453d9
commit
17506726cb
36 changed files with 280 additions and 271 deletions
|
|
@ -76,7 +76,7 @@ pub(crate) fn write_quote_to (out: &mut TokenStream2, quote: TokenStream2) {
|
|||
assert_eq!(x.output, output);
|
||||
|
||||
// TODO
|
||||
let x: crate::proc_view::ViewImpl = pq! {
|
||||
let _x: crate::proc_view::ViewImpl = pq! {
|
||||
impl Foo {
|
||||
/// docstring1
|
||||
#[tengri::view(":view1")] #[bar] fn a_view () {}
|
||||
|
|
@ -86,7 +86,7 @@ pub(crate) fn write_quote_to (out: &mut TokenStream2, quote: TokenStream2) {
|
|||
#[baz] fn is_not_view () {}
|
||||
}
|
||||
};
|
||||
let expected_target: Ident = pq! { Foo };
|
||||
let _expected_target: Ident = pq! { Foo };
|
||||
//assert_eq!(x.target, expected_target);
|
||||
//assert_eq!(x.items.len(), 2);
|
||||
//assert_eq!(x.items[0].item, pq! {
|
||||
|
|
|
|||
|
|
@ -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: Take::take_or_fail(self, words)?,
|
||||
#arg: Dsl::try_provide(self, words)?,
|
||||
});
|
||||
}
|
||||
out
|
||||
|
|
@ -149,8 +149,8 @@ impl ToTokens for CommandDef {
|
|||
}
|
||||
}
|
||||
/// Generated by [tengri_proc::command].
|
||||
impl ::tengri::dsl::Take<#state> for #command_enum {
|
||||
fn take (state: &#state, mut words: ::tengri::dsl::Cst) -> Perhaps<Self> {
|
||||
impl ::tengri::dsl::Dsl<#state> for #command_enum {
|
||||
fn try_provide (state: &#state, mut words: ::tengri::dsl::Ast) -> Perhaps<Self> {
|
||||
let mut words = words.clone();
|
||||
let token = words.next();
|
||||
todo!()//Ok(match token { #(#matchers)* _ => None })
|
||||
|
|
|
|||
|
|
@ -85,8 +85,8 @@ impl ToTokens for ExposeImpl {
|
|||
});
|
||||
write_quote_to(out, quote! {
|
||||
/// Generated by [tengri_proc::expose].
|
||||
impl ::tengri::dsl::Take<#state> for #t {
|
||||
fn take (state: &#state, mut words: ::tengri::dsl::Cst) -> Perhaps<Self> {
|
||||
impl ::tengri::dsl::Dsl<#state> for #t {
|
||||
fn try_provide (state: &#state, mut words: ::tengri::dsl::Ast) -> Perhaps<Self> {
|
||||
Ok(Some(match words.next().map(|x|x.value) {
|
||||
#predefined
|
||||
#(#values)*
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ impl ToTokens for ViewDef {
|
|||
// that operate over constants and symbols.
|
||||
let builtin = builtins_with_boxes_output(quote! { #output }).map(|builtin|quote! {
|
||||
::tengri::dsl::Value::Exp(_, expr) => return Ok(Some(
|
||||
#builtin::take_or_fail(state, expr, ||"failed to load builtin")?.boxed()
|
||||
#builtin::try_provide(state, expr, ||"failed to load builtin")?.boxed()
|
||||
)),
|
||||
});
|
||||
// Symbols are handled by user-taked functions
|
||||
|
|
@ -63,11 +63,8 @@ impl ToTokens for 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<'source, 'state: 'source>
|
||||
Take<'state, 'source, #self_ty>
|
||||
for Box<dyn Render<#output> + 'state>
|
||||
{
|
||||
fn take (state: &'state #self_ty, mut words: Cst<'source>) -> Perhaps<Self> {
|
||||
impl<'state> ::tengri::dsl::Dsl<Box<dyn Render<#output> + 'state>> for #self_ty {
|
||||
fn try_provide (state: &'state #self_ty, mut words: ::tengri::dsl::Ast) -> Perhaps<Box<dyn Render<#output> + 'state>> {
|
||||
Ok(if let Some(::tengri::dsl::Token { value, .. }) = words.peek() {
|
||||
match value { #(#builtin)* #(#exposed)* _ => None }
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue