From 723f48d8e008d216978b8ed7d70499c972cc5a1c Mon Sep 17 00:00:00 2001 From: HampusM Date: Fri, 30 Oct 2026 05:24:39 +0100 Subject: refactor(engine-ecs): replace uid::WithUid* traits with new component traits --- engine-ecs-macros/src/lib.rs | 44 ++++++++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 18 deletions(-) (limited to 'engine-ecs-macros/src/lib.rs') diff --git a/engine-ecs-macros/src/lib.rs b/engine-ecs-macros/src/lib.rs index 9bc829b..a95cfe4 100644 --- a/engine-ecs-macros/src/lib.rs +++ b/engine-ecs-macros/src/lib.rs @@ -45,8 +45,6 @@ pub fn component_derive(input: TokenStream) -> TokenStream let item_ident = item.ident(); - let (impl_generics, type_generics, where_clause) = item.generics().split_for_impl(); - let ecs_path = find_engine_ecs_crate_path().unwrap_or_else(|| syn_path!(ecs)); assert!( @@ -80,14 +78,8 @@ pub fn component_derive(input: TokenStream) -> TokenStream #id_var - impl #impl_generics Component for #item_ident #type_generics - #where_clause + impl Component for #item_ident { - fn id() -> Uid - { - *#id_var_ident - } - fn type_reflection() -> Option<&'static #ecs_path::reflection::Type> { struct SpecializationTarget(std::marker::PhantomData); @@ -134,8 +126,7 @@ pub fn component_derive(input: TokenStream) -> TokenStream } } - impl #impl_generics SystemInput for #item_ident #type_generics - #where_clause + impl SystemInput for #item_ident { } @@ -146,7 +137,18 @@ pub fn component_derive(input: TokenStream) -> TokenStream #ecs_path::component::Parts::builder() .name(::name(&self)) .type_reflection(::type_reflection()) - .build(::id(), self) + .build( + ::id(), + self + ) + } + } + + impl #ecs_path::component::WithAssociatedId for #item_ident + { + fn id() -> Uid + { + *#id_var_ident } } } @@ -203,11 +205,6 @@ pub fn sole_derive(input: TokenStream) -> TokenStream impl Sole for #item_ident { - fn id() -> Uid - { - *#id_var_ident - } - fn type_reflection() -> Option<&'static #ecs_path::reflection::Type> { struct SpecializationTarget(std::marker::PhantomData); @@ -262,7 +259,18 @@ pub fn sole_derive(input: TokenStream) -> TokenStream .name(::name(&self)) .is_sole(true) .type_reflection(::type_reflection()) - .build(::id(), self) + .build( + ::id(), + self + ) + } + } + + impl #ecs_path::component::WithAssociatedId for #item_ident + { + fn id() -> Uid + { + *#id_var_ident } } } -- cgit v1.2.3-18-g5258