bevy_gizmos_macros/
lib.rs1#![cfg_attr(docsrs, feature(doc_cfg))]
2
3use bevy_macro_utils::BevyManifest;
6use proc_macro::TokenStream;
7use quote::quote;
8use syn::{parse_macro_input, parse_quote, DeriveInput, Path};
9
10#[proc_macro_derive(GizmoConfigGroup)]
12pub fn derive_gizmo_config_group(input: TokenStream) -> TokenStream {
13 let mut ast = parse_macro_input!(input as DeriveInput);
14 BevyManifest::shared(|manifest| {
15 let bevy_gizmos_path: Path = manifest.get_path("bevy_gizmos");
16 let bevy_reflect_path: Path = manifest.get_path("bevy_reflect");
17
18 ast.generics.make_where_clause().predicates.push(
19 parse_quote! { Self: #bevy_reflect_path::Reflect + #bevy_reflect_path::TypePath + Default},
20 );
21
22 let struct_name = &ast.ident;
23 let (impl_generics, type_generics, where_clause) = &ast.generics.split_for_impl();
24
25 TokenStream::from(quote! {
26 impl #impl_generics #bevy_gizmos_path::config::GizmoConfigGroup for #struct_name #type_generics #where_clause {
27 }
28 })
29 })
30}