diff options
-rw-r--r-- | ecs-macros/src/lib.rs | 72 | ||||
-rw-r--r-- | ecs/src/component.rs | 8 |
2 files changed, 1 insertions, 79 deletions
diff --git a/ecs-macros/src/lib.rs b/ecs-macros/src/lib.rs index aab8dd2..7d00736 100644 --- a/ecs-macros/src/lib.rs +++ b/ecs-macros/src/lib.rs @@ -14,7 +14,6 @@ use syn::{ ItemStruct, ItemUnion, Path, - Type, }; use toml::value::{Table as TomlTable, Value as TomlValue}; @@ -49,15 +48,11 @@ macro_rules! syn_path_segment { /// - Not attributed to a type item /// - The attributed-to type item is generic /// - If parsing the user crate's `Cargo.toml` file fails. -#[proc_macro_derive(Component, attributes(component))] +#[proc_macro_derive(Component)] pub fn component_derive(input: TokenStream) -> TokenStream { let item: TypeItem = parse::<Item>(input).unwrap().try_into().unwrap(); - let ComponentAttribute { handle_type, handle_mut_type } = item - .attribute::<ComponentAttribute>("component") - .unwrap_or_default(); - let item_ident = item.ident(); let (impl_generics, type_generics, where_clause) = item.generics().split_for_impl(); @@ -88,10 +83,6 @@ pub fn component_derive(input: TokenStream) -> TokenStream use ::std::sync::{LazyLock, Mutex}; use #ecs_path::component::Component; - use #ecs_path::component::{ - Handle as ComponentHandle, - HandleMut as ComponentHandleMut - }; use #ecs_path::uid::{Uid, Kind as UidKind}; use #ecs_path::system::Input as SystemInput; @@ -102,9 +93,6 @@ pub fn component_derive(input: TokenStream) -> TokenStream impl #impl_generics Component for #item_ident #type_generics #where_clause { - type HandleMut<'component> = #handle_mut_type; - type Handle<'component> = #handle_type; - fn id() -> Uid { *#id_var_ident @@ -326,61 +314,3 @@ fn find_engine_ecs_crate_path() -> Option<Path> None }) } - -#[derive(Debug)] -struct ComponentAttribute -{ - handle_type: proc_macro2::TokenStream, - handle_mut_type: proc_macro2::TokenStream, -} - -impl FromAttribute for ComponentAttribute -{ - fn from_attribute(attribute: &Attribute) -> Result<Self, syn::Error> - { - let mut handle_type: Option<Type> = None; - let mut handle_mut_type: Option<Type> = None; - - attribute.parse_nested_meta(|meta| { - let Some(flag) = meta.path.get_ident() else { - return Err(meta.error("Not a single identifier")); - }; - - if flag == "handle_type" { - let value = meta.value()?; - - handle_type = Some(value.parse::<Type>()?); - - return Ok(()); - } else if flag == "handle_mut_type" { - let value = meta.value()?; - - handle_mut_type = Some(value.parse::<Type>()?); - - return Ok(()); - } - - Err(meta.error("Unrecognized token")) - })?; - - Ok(Self { - handle_type: handle_type - .map_or_else(|| Self::default().handle_type, ToTokens::into_token_stream), - handle_mut_type: handle_mut_type.map_or_else( - || Self::default().handle_mut_type, - ToTokens::into_token_stream, - ), - }) - } -} - -impl Default for ComponentAttribute -{ - fn default() -> Self - { - Self { - handle_type: quote! { ComponentHandle<'component, Self> }, - handle_mut_type: quote! { ComponentHandleMut<'component, Self> }, - } - } -} diff --git a/ecs/src/component.rs b/ecs/src/component.rs index a0ed752..222c5fe 100644 --- a/ecs/src/component.rs +++ b/ecs/src/component.rs @@ -23,14 +23,6 @@ pub(crate) mod storage; pub trait Component: SystemInput + Any { - type HandleMut<'component>: HandleFromEntityComponentRef<'component> - where - Self: Sized; - - type Handle<'component>: HandleFromEntityComponentRef<'component> - where - Self: Sized; - /// Returns the ID of this component. fn id() -> Uid where |