ferment_sys/presentable/
mod.rs

1use std::fmt::Debug;
2use quote::ToTokens;
3use syn::punctuated::Punctuated;
4use proc_macro2::{Ident, TokenStream as TokenStream2};
5use crate::context::ScopeContext;
6
7mod binding;
8mod expression;
9mod name;
10mod argument;
11mod sequence;
12mod aspect;
13mod ty_context;
14#[allow(unused)]
15mod interface;
16
17pub use aspect::*;
18pub use binding::*;
19// pub use ctor_presentable::*;
20pub use expression::*;
21pub use name::*;
22pub use argument::*;
23pub use interface::*;
24pub use sequence::*;
25use syn::{Attribute, Path};
26use crate::composable::FnSignatureContext;
27
28pub trait ScopeContextPresentable {
29    type Presentation: Clone + ToTokens;
30    fn present(&self, source: &ScopeContext) -> Self::Presentation;
31}
32
33impl ScopeContextPresentable for TokenStream2 {
34    type Presentation = TokenStream2;
35
36    fn present(&self, _source: &ScopeContext) -> Self::Presentation {
37        self.to_token_stream()
38    }
39}
40
41impl<T, SEP> ScopeContextPresentable for Punctuated<T, SEP>
42    where T: ScopeContextPresentable, SEP: ToTokens + Clone + Default {
43    type Presentation = Punctuated<<T as ScopeContextPresentable>::Presentation, SEP>;
44
45    fn present(&self, source: &ScopeContext) -> Self::Presentation {
46        self.iter().map(|presentable| presentable.present(source)).collect()
47    }
48}
49// impl<T, SEP> ScopeContextPresentable for Punctuated<T, SEP>
50//     where T: ScopeContextPresentable, SEP: ToTokens + Clone + Default {
51//     type Presentation = Punctuated<<T as ScopeContextPresentable>::Presentation, SEP>;
52//
53//     fn present(&self, source: &ScopeContext) -> Self::Presentation {
54//         self.iter().map(|presentable| presentable.present(source)).collect()
55//     }
56// }
57
58
59
60pub trait NameTreeContext: Clone + Debug + ToTokens {
61    // fn maybe_parent(&self) -> Option<&Box<Self>>;
62    fn join_fn(&self, path: Path, sig_context: FnSignatureContext, attrs: Vec<Attribute>) -> Self;
63    fn join_variant(&self, ident: Ident, variant_ident: Ident, attrs: Vec<Attribute>) -> Self;
64}
65
66