From a9873edbc67c763ab4034ba16dbd8710acf67504 Mon Sep 17 00:00:00 2001 From: Yarvin Date: Tue, 7 Jan 2025 09:21:28 +0100 Subject: [PATCH] Derive Var and Export for DynGd - Remove unnecressary derive macros, make some classes private, add few readability fixes. --- godot-core/src/obj/dyn_gd.rs | 2 +- godot-core/src/registry/class.rs | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/godot-core/src/obj/dyn_gd.rs b/godot-core/src/obj/dyn_gd.rs index 2829174cd..86aa8eb4d 100644 --- a/godot-core/src/obj/dyn_gd.rs +++ b/godot-core/src/obj/dyn_gd.rs @@ -492,7 +492,7 @@ where fn set_property(&mut self, value: Self::Via) { // `set_property` can't be delegated to Gd since we have to set `erased_obj` as well - *self = Self::from_godot(value); + *self = ::from_godot(value); } } diff --git a/godot-core/src/registry/class.rs b/godot-core/src/registry/class.rs index dd35e4f41..478481448 100644 --- a/godot-core/src/registry/class.rs +++ b/godot-core/src/registry/class.rs @@ -44,7 +44,7 @@ fn global_loaded_classes_by_name() -> GlobalGuard<'static, HashMap GlobalGuard<'static, HashMap>> { static DYN_TRAITS_BY_TYPEID: Global>> = Global::default(); @@ -68,7 +68,6 @@ pub struct LoadedClass { pub struct ClassMetadata {} /// Represents a `dyn Trait` implemented (and registered) for a class. -#[derive(Debug)] pub struct DynToClassRelation { implementing_class_name: ClassName, erased_dynify_fn: ErasedDynifyFn, @@ -194,7 +193,11 @@ pub fn register_class< }); } -fn fill_the_registries(map: &mut HashMap, init_level: InitLevel) { +/// Populates all the registries with information derived from ClassRegistrationInfo +fn populate_the_registries( + map: &mut HashMap, + init_level: InitLevel, +) { let mut loaded_classes_by_level = global_loaded_classes_by_init_level(); let mut loaded_classes_by_name = global_loaded_classes_by_name(); let mut dyn_traits_by_typeid = global_dyn_traits_by_typeid(); @@ -256,10 +259,10 @@ pub fn auto_register_classes(init_level: InitLevel) { }); // First register all the loaded classes and dyn traits. - // We need all the dyn classes in the registry to properly register the properties; + // We need all the dyn classes in the registry to properly register DynGd properties; // one can do it directly inside the loop – by locking and unlocking the mutex – - // but it is much slower and doesn't guarantee that all the dependent classes will be loaded in most cases. - fill_the_registries(&mut map, init_level); + // but it is much slower and doesn't guarantee that all the dependent classes will be already loaded in most cases. + populate_the_registries(&mut map, init_level); // actually register all the classes for info in map.into_values() {