mirror of
https://github.com/bevyengine/bevy
synced 2024-12-21 18:43:07 +00:00
d8974e7c3d
What is says on the tin. This has got more to do with making `clippy` slightly more *quiet* than it does with changing anything that might greatly impact readability or performance. that said, deriving `Default` for a couple of structs is a nice easy win
34 lines
1 KiB
Rust
34 lines
1 KiB
Rust
extern crate proc_macro;
|
|
|
|
mod app_plugin;
|
|
mod bevy_main;
|
|
mod enum_variant_meta;
|
|
mod modules;
|
|
|
|
use bevy_macro_utils::{derive_label, BevyManifest};
|
|
use proc_macro::TokenStream;
|
|
use quote::format_ident;
|
|
|
|
/// Generates a dynamic plugin entry point function for the given `Plugin` type.
|
|
#[proc_macro_derive(DynamicPlugin)]
|
|
pub fn derive_dynamic_plugin(input: TokenStream) -> TokenStream {
|
|
app_plugin::derive_dynamic_plugin(input)
|
|
}
|
|
|
|
#[proc_macro_attribute]
|
|
pub fn bevy_main(attr: TokenStream, item: TokenStream) -> TokenStream {
|
|
bevy_main::bevy_main(attr, item)
|
|
}
|
|
|
|
#[proc_macro_derive(EnumVariantMeta)]
|
|
pub fn derive_enum_variant_meta(input: TokenStream) -> TokenStream {
|
|
enum_variant_meta::derive_enum_variant_meta(input)
|
|
}
|
|
|
|
#[proc_macro_derive(AppLabel)]
|
|
pub fn derive_app_label(input: TokenStream) -> TokenStream {
|
|
let input = syn::parse_macro_input!(input as syn::DeriveInput);
|
|
let mut trait_path = BevyManifest::default().get_path("bevy_app");
|
|
trait_path.segments.push(format_ident!("AppLabel").into());
|
|
derive_label(input, &trait_path)
|
|
}
|