19 lines
No EOL
647 B
Rust
19 lines
No EOL
647 B
Rust
use quote::quote;
|
|
use syn::{parse_macro_input, DeriveInput};
|
|
|
|
#[proc_macro_derive(Component)]
|
|
pub fn derive_component(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
|
|
let input = parse_macro_input!(input as DeriveInput);
|
|
let (impl_generics, ty_generics, where_clause) = input.generics.split_for_impl();
|
|
|
|
let type_ident = &input.ident;
|
|
let type_name = type_ident.to_string();
|
|
|
|
proc_macro::TokenStream::from(quote! {
|
|
impl #impl_generics lyra_engine::ecs::Component for #type_ident #ty_generics #where_clause {
|
|
fn name() -> &'static str {
|
|
#type_name
|
|
}
|
|
}
|
|
})
|
|
} |