
This is a rather simple but wide change, and it involves adding a new `bevy_app_macros` crate. Let me know if there is a better way to do any of this! --- # Objective - Allow adding and accessing sub-apps by using a label instead of an index ## Solution - Migrate the bevy label implementation and derive code to the `bevy_utils` and `bevy_macro_utils` crates and then add a new `SubAppLabel` trait to the `bevy_app` crate that is used when adding or getting a sub-app from an app.
20 lines
551 B
Rust
20 lines
551 B
Rust
extern crate proc_macro;
|
|
|
|
use bevy_macro_utils::{derive_label, BevyManifest};
|
|
use proc_macro::TokenStream;
|
|
use quote::format_ident;
|
|
|
|
#[proc_macro_derive(SubAppLabel)]
|
|
pub fn derive_sub_app_label(input: TokenStream) -> TokenStream {
|
|
let input = syn::parse_macro_input!(input as syn::DeriveInput);
|
|
let mut trait_path = bevy_app_path();
|
|
trait_path
|
|
.segments
|
|
.push(format_ident!("SubAppLabel").into());
|
|
derive_label(input, trait_path)
|
|
}
|
|
|
|
fn bevy_app_path() -> syn::Path {
|
|
BevyManifest::default().get_path("bevy_app")
|
|
}
|