thallium_derive/
lib.rs

1#![doc = include_str!("../README.md")]
2
3use proc_macro::TokenStream;
4use quote::quote;
5use syn::{parse_macro_input, DeriveInput};
6
7/// Derives the `thallium_ecs::Component` trait
8#[proc_macro_derive(Component)]
9pub fn derive_component(input: TokenStream) -> TokenStream {
10    let input = parse_macro_input!(input as DeriveInput);
11
12    let name = input.ident;
13    let (impl_generics, ty_generics, where_clause) = input.generics.split_for_impl();
14
15    quote! {
16        impl #impl_generics ::thallium::ecs::Component for #name #ty_generics #where_clause {
17        }
18    }
19    .into()
20}
21
22/// Derives the `thallium_ecs::Resource` trait
23#[proc_macro_derive(Resource)]
24pub fn derive_resource(input: TokenStream) -> TokenStream {
25    let input = parse_macro_input!(input as DeriveInput);
26
27    let name = input.ident;
28    let (impl_generics, ty_generics, where_clause) = input.generics.split_for_impl();
29
30    quote! {
31        impl #impl_generics ::thallium::ecs::Resource for #name #ty_generics #where_clause {
32        }
33    }
34    .into()
35}