2024-03-25 11:49:32 -05:00
|
|
|
extern crate proc_macro;
|
|
|
|
|
|
|
|
use proc_macro::TokenStream;
|
|
|
|
use quote::quote;
|
|
|
|
use syn::{parse_macro_input, DeriveInput};
|
|
|
|
|
2024-03-25 12:13:10 -05:00
|
|
|
/// Implements `Signal` trait for the given type
|
2024-03-25 11:49:32 -05:00
|
|
|
#[proc_macro_derive(Signal)]
|
2024-03-29 07:44:56 -05:00
|
|
|
pub fn derive_signal(input: TokenStream) -> TokenStream {
|
2024-03-25 11:49:32 -05:00
|
|
|
let input = parse_macro_input!(input as DeriveInput);
|
|
|
|
let name = input.ident;
|
|
|
|
quote!(impl ::hui::signal::Signal for #name {}).into()
|
|
|
|
}
|
2024-03-29 07:44:56 -05:00
|
|
|
|
|
|
|
/// Implements `State` trait for the given type
|
|
|
|
#[proc_macro_derive(State)]
|
|
|
|
pub fn derive_state(input: TokenStream) -> TokenStream {
|
|
|
|
let input = parse_macro_input!(input as DeriveInput);
|
|
|
|
let name = input.ident;
|
|
|
|
quote!(impl ::hui::state::State for #name {}).into()
|
|
|
|
}
|