You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.4 KiB
Rust
46 lines
1.4 KiB
Rust
use proc_macro::TokenStream;
|
|
use quote::quote;
|
|
use syn::{parse_macro_input, DeriveInput};
|
|
|
|
pub fn invoke(input: TokenStream) -> TokenStream {
|
|
let input = parse_macro_input!(input as DeriveInput);
|
|
let name = input.ident;
|
|
|
|
let expanded = quote! {
|
|
#[automatically_derived]
|
|
impl<B: crate::backend::Backend>
|
|
crate::view::custom::CustomComponent<B> for #name
|
|
{}
|
|
|
|
#[automatically_derived]
|
|
impl<B: crate::backend::Backend>
|
|
crate::view::Construct<B> for #name
|
|
{
|
|
type Params = <Self as crate::view::custom::NewCustom<B>>::Params;
|
|
|
|
fn construct(params: Self::Params) -> Self {
|
|
<Self as crate::view::custom::NewCustom<B>>::new(params)
|
|
}
|
|
|
|
fn into_view(self) -> crate::view::SomeView<B> {
|
|
crate::view::SomeView::<B>::Custom(Box::new(self))
|
|
}
|
|
}
|
|
|
|
#[automatically_derived]
|
|
impl<B: crate::backend::Backend>
|
|
crate::view::ConstructGroup<B> for #name
|
|
where
|
|
#name : crate::view::custom::NewCustomGroup<B>,
|
|
{
|
|
fn construct_group<'a, I>(params: Self::Params, children: I) -> Self
|
|
where
|
|
I: Iterator<Item = &'a crate::view::View<B>>,
|
|
{
|
|
<Self as crate::view::custom::NewCustomGroup<B>>::new_group(params, children)
|
|
}
|
|
}
|
|
};
|
|
expanded.into()
|
|
}
|