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;
|
2021-04-21 23:46:54 +00:00
|
|
|
mod enum_variant_meta;
|
2020-05-04 00:54:16 +00:00
|
|
|
mod modules;
|
|
|
|
|
2021-08-24 06:37:28 +00:00
|
|
|
use bevy_macro_utils::{derive_label, BevyManifest};
|
2020-01-19 10:02:12 +00:00
|
|
|
use proc_macro::TokenStream;
|
2021-08-24 06:37:28 +00:00
|
|
|
use quote::format_ident;
|
2020-03-18 23:06:33 +00:00
|
|
|
|
2020-08-09 23:13:04 +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)]
|
2020-08-09 23:13:04 +00:00
|
|
|
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-10-18 20:48:15 +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)
|
|
|
|
}
|
2021-04-21 23:46:54 +00:00
|
|
|
|
2021-05-19 19:03:36 +00:00
|
|
|
#[proc_macro_derive(EnumVariantMeta)]
|
2021-04-21 23:46:54 +00:00
|
|
|
pub fn derive_enum_variant_meta(input: TokenStream) -> TokenStream {
|
|
|
|
enum_variant_meta::derive_enum_variant_meta(input)
|
|
|
|
}
|
2021-08-24 06:37:28 +00:00
|
|
|
|
|
|
|
#[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());
|
2022-02-13 22:33:55 +00:00
|
|
|
derive_label(input, &trait_path)
|
2021-08-24 06:37:28 +00:00
|
|
|
}
|