bevy/crates/bevy_derive/src/lib.rs

35 lines
1 KiB
Rust
Raw Normal View History

2020-01-21 11:15:28 +00:00
extern crate proc_macro;
2020-06-04 03:08:20 +00:00
mod app_plugin;
2020-11-12 21:26:48 +00:00
mod bevy_main;
mod enum_variant_meta;
2020-05-04 00:54:16 +00:00
mod modules;
use bevy_macro_utils::{derive_label, BevyManifest};
2020-01-19 10:02:12 +00:00
use proc_macro::TokenStream;
use quote::format_ident;
2020-03-18 23:06:33 +00:00
/// Generates a dynamic plugin entry point function for the given `Plugin` type.
2020-08-08 03:22:17 +00:00
#[proc_macro_derive(DynamicPlugin)]
pub fn derive_dynamic_plugin(input: TokenStream) -> TokenStream {
2020-08-08 03:22:17 +00:00
app_plugin::derive_dynamic_plugin(input)
2020-06-15 19:47:35 +00:00
}
2020-11-12 21:26:48 +00:00
#[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)
}