summaryrefslogtreecommitdiff
path: root/engine-ecs-macros/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'engine-ecs-macros/src/lib.rs')
-rw-r--r--engine-ecs-macros/src/lib.rs44
1 files changed, 26 insertions, 18 deletions
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<T>(std::marker::PhantomData<T>);
@@ -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(<Self as Component>::name(&self))
.type_reflection(<Self as Component>::type_reflection())
- .build(<Self as Component>::id(), self)
+ .build(
+ <Self as #ecs_path::component::WithAssociatedId>::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<T>(std::marker::PhantomData<T>);
@@ -262,7 +259,18 @@ pub fn sole_derive(input: TokenStream) -> TokenStream
.name(<Self as Sole>::name(&self))
.is_sole(true)
.type_reflection(<Self as Sole>::type_reflection())
- .build(<Self as Sole>::id(), self)
+ .build(
+ <Self as #ecs_path::component::WithAssociatedId>::id(),
+ self
+ )
+ }
+ }
+
+ impl #ecs_path::component::WithAssociatedId for #item_ident
+ {
+ fn id() -> Uid
+ {
+ *#id_var_ident
}
}
}