diff --git a/src/entity/property_list.rs b/src/entity/property_list.rs index 4742684d..2b4b48e8 100644 --- a/src/entity/property_list.rs +++ b/src/entity/property_list.rs @@ -142,7 +142,7 @@ macro_rules! impl_property_list { impl,)*> PropertyList for (#(P~N, )*){ fn validate() -> Result<(), IxaError> { // For `Property` distinctness check - let property_type_ids: [TypeId; $ct] = [#(P~N::type_id(),)*]; + let property_type_ids: [TypeId; $ct] = [#(>::type_id(),)*]; for i in 0..$ct - 1 { for j in (i + 1)..$ct { @@ -159,7 +159,7 @@ macro_rules! impl_property_list { } fn contains_properties(property_type_ids: &[TypeId]) -> bool { - let self_property_type_ids: [TypeId; $ct] = [#(P~N::type_id(),)*]; + let self_property_type_ids: [TypeId; $ct] = [#(>::type_id(),)*]; property_type_ids.len() <= $ct && property_type_ids.iter().all(|id| self_property_type_ids.contains(id)) } diff --git a/src/entity/query/query_impls.rs b/src/entity/query/query_impls.rs index 77c50fb6..2628ab0f 100644 --- a/src/entity/query/query_impls.rs +++ b/src/entity/query/query_impls.rs @@ -200,7 +200,12 @@ macro_rules! impl_query { fn get_query(&self) -> Vec<(usize, HashValueType)> { let mut ordered_items = vec![ #( - (T~N::id(), T~N::hash_property_value(&T~N::make_canonical(self.N))), + ( + >::id(), + >::hash_property_value( + &>::make_canonical(self.N) + ), + ), )* ]; ordered_items.sort_unstable_by(|a, b| a.0.cmp(&b.0)); @@ -210,7 +215,7 @@ macro_rules! impl_query { fn get_type_ids(&self) -> Vec { vec![ #( - T~N::type_id(), + >::type_id(), )* ] } @@ -230,7 +235,7 @@ macro_rules! impl_query { // ]; let keys: [&str; $ct] = [ #( - T~N::name(), + >::name(), )* ]; // It is convenient to have the elements of the array to be `Copy` in the `static_apply_reordering` @@ -239,7 +244,11 @@ macro_rules! impl_query { // keep the referenced value in scope.) let mut values: [&Vec; $ct] = [ #( - &$crate::bincode::serde::encode_to_vec(self.N, bincode::config::standard()).unwrap(), + &$crate::bincode::serde::encode_to_vec( + self.N, + $crate::bincode::config::standard(), + ) + .unwrap(), )* ]; static_reorder_by_keys(&keys, &mut values); @@ -253,11 +262,11 @@ macro_rules! impl_query { // This mirrors the indexed case in `SourceSet<'a, E>::new()`. The difference is, if the // multi-property is unindexed, we fall through to create `SourceSet`s for the components // rather than wrapping a `DerivedPropertySource`. - if let Some(multi_property_id) = self.multi_property_id() { + if let Some(multi_property_id) = >::multi_property_id(self) { let property_store = context.entity_store.get_property_store::(); match property_store.get_index_set_with_hash_for_property_id( multi_property_id, - self.multi_property_value_hash(), + >::multi_property_value_hash(self), ) { $crate::entity::index::IndexSetResult::Set(entity_set) => { return EntitySet::from_source(SourceSet::IndexSet(entity_set)); @@ -288,11 +297,11 @@ macro_rules! impl_query { fn new_query_result_iterator<'c>(&self, context: &'c Context) -> EntitySetIterator<'c, E> { // Constructing the `EntitySetIterator` directly instead of constructing an `EntitySet` // first is a micro-optimization improving tight-loop benchmark performance. - if let Some(multi_property_id) = self.multi_property_id() { + if let Some(multi_property_id) = >::multi_property_id(self) { let property_store = context.entity_store.get_property_store::(); match property_store.get_index_set_with_hash_for_property_id( multi_property_id, - self.multi_property_value_hash(), + >::multi_property_value_hash(self), ) { $crate::entity::index::IndexSetResult::Set(entity_set) => { return EntitySetIterator::from_index_set(entity_set); @@ -331,11 +340,11 @@ macro_rules! impl_query { fn filter_entities(&self, entities: &mut Vec>, context: &Context) { // The fast path: If this query is indexed, we only have to do one pass over the entities. - if let Some(multi_property_id) = self.multi_property_id() { + if let Some(multi_property_id) = >::multi_property_id(self) { let property_store = context.entity_store.get_property_store::(); match property_store.get_index_set_with_hash_for_property_id( multi_property_id, - self.multi_property_value_hash(), + >::multi_property_value_hash(self), ) { $crate::entity::index::IndexSetResult::Set(entity_set) => { entities.retain(|entity_id| entity_set.contains(entity_id)); diff --git a/src/macros/define_global_property.rs b/src/macros/define_global_property.rs index 6cc13f8a..52fedbc8 100644 --- a/src/macros/define_global_property.rs +++ b/src/macros/define_global_property.rs @@ -46,6 +46,6 @@ macro_rules! define_global_property { }; ($global_property: ident, $value: ty) => { - define_global_property!($global_property, $value, |_| { Ok(()) }); + $crate::define_global_property!($global_property, $value, |_| { Ok(()) }); }; } diff --git a/src/macros/entity_impl.rs b/src/macros/entity_impl.rs index 632f398f..5b724aa8 100644 --- a/src/macros/entity_impl.rs +++ b/src/macros/entity_impl.rs @@ -12,7 +12,7 @@ macro_rules! define_entity { impl $entity_name { #[allow(unused)] pub fn new() -> Self { - Self::default() + ::default() } } diff --git a/src/macros/property_impl.rs b/src/macros/property_impl.rs index f5c118e3..86b0a43a 100644 --- a/src/macros/property_impl.rs +++ b/src/macros/property_impl.rs @@ -309,7 +309,8 @@ macro_rules! define_property { /// * `make_uncanonical = ` — Function converting from `CanonicalValue` to `Self`; defaults to `std::convert::identity`. /// * Optional parameters that should generally be left alone, used internally to implement derived properties and /// multi-properties: -/// * `index_id_fn = ` — Function used to initialize the property index id; defaults to `Self::id()`. +/// * `index_id_fn = ` — Function used to initialize the property index id; defaults to +/// `>::id()`. /// * `collect_deps_fn = ` — Function used to collect property dependencies; defaults to an empty implementation. /// * `ctor_registration = ` — Code run in the `ctor` for property registration. /// @@ -683,10 +684,10 @@ macro_rules! impl_derived_property { ), collect_deps_fn = | deps: &mut $crate::HashSet | { $( - if $dependency::is_derived() { - $dependency::collect_non_derived_dependencies(deps); + if <$dependency as $crate::entity::property::Property<$entity>>::is_derived() { + <$dependency as $crate::entity::property::Property<$entity>>::collect_non_derived_dependencies(deps); } else { - deps.insert($dependency::id()); + deps.insert(<$dependency as $crate::entity::property::Property<$entity>>::id()); } )* } @@ -800,17 +801,17 @@ macro_rules! define_multi_property { collect_deps_fn = | deps: &mut $crate::HashSet | { $( - if $dependency::is_derived() { - $dependency::collect_non_derived_dependencies(deps); + if <$dependency as $crate::entity::property::Property<$entity>>::is_derived() { + <$dependency as $crate::entity::property::Property<$entity>>::collect_non_derived_dependencies(deps); } else { - deps.insert($dependency::id()); + deps.insert(<$dependency as $crate::entity::property::Property<$entity>>::id()); } )* }, ctor_registration = { - // Ensure `Self::index_id()` is initialized at startup. - let _ = [<$($dependency)*>]::index_id(); + // Ensure the property's `index_id()` is initialized at startup. + let _ = < [<$($dependency)*>] as $crate::entity::property::Property::<$entity> >::index_id(); $crate::entity::property_store::add_to_property_registry::<$entity, [<$($dependency)*>]>(); } );