diff options
| author | HampusM <hampus@hampusmat.com> | 2026-04-06 20:48:36 +0200 |
|---|---|---|
| committer | HampusM <hampus@hampusmat.com> | 2026-04-06 20:48:36 +0200 |
| commit | 5853d458ae55443c79976893f822aaed508de013 (patch) | |
| tree | 02555763fda13d9dfb4fee00802dad205265144d /engine-macros | |
| parent | 942df064017258a92eee1a14cd613c6aec983dc8 (diff) | |
refactor(engine): improve names of reflection types & items
Diffstat (limited to 'engine-macros')
| -rw-r--r-- | engine-macros/src/lib.rs | 38 |
1 files changed, 17 insertions, 21 deletions
diff --git a/engine-macros/src/lib.rs b/engine-macros/src/lib.rs index b87acf8..b7bbd43 100644 --- a/engine-macros/src/lib.rs +++ b/engine-macros/src/lib.rs @@ -63,49 +63,55 @@ pub fn reflection_derive(input: TokenStream) -> TokenStream byte_offset: std::mem::offset_of!(Self, #field_ident), type_id: std::any::TypeId::of::<#field_type>(), type_name: #field_type_name, - get_reflection: #engine_crate_path::reflection::FnWithDebug::new(|| { + get_type: #engine_crate_path::reflection::FnWithDebug::new(|| { struct SpecializationTarget<Field>(std::marker::PhantomData<Field>); trait FieldHasReflection { - fn field_reflection(&self) -> Option<&'static #engine_crate_path::reflection::Reflection>; + fn field_type_reflection(&self) + -> Option<&'static #engine_crate_path::reflection::Type>; } trait FieldDoesNotHaveReflection { - fn field_reflection(&self) -> Option<&'static #engine_crate_path::reflection::Reflection>; + fn field_type_reflection(&self) + -> Option<&'static #engine_crate_path::reflection::Type>; } impl<Field> FieldDoesNotHaveReflection for &SpecializationTarget<Field> { - fn field_reflection(&self) -> Option<&'static #engine_crate_path::reflection::Reflection> + fn field_type_reflection(&self) + -> Option<&'static #engine_crate_path::reflection::Type> { None } } - impl<Field: #engine_crate_path::reflection::With> FieldHasReflection for SpecializationTarget<Field> + impl<Field> FieldHasReflection for SpecializationTarget<Field> + where + Field: #engine_crate_path::reflection::Reflection { - fn field_reflection(&self) -> Option<&'static #engine_crate_path::reflection::Reflection> + fn field_type_reflection(&self) + -> Option<&'static #engine_crate_path::reflection::Type> { - Some(Field::reflection()) + Some(Field::type_reflection()) } } (&SpecializationTarget::<#field_type>(std::marker::PhantomData)) - .field_reflection() + .field_type_reflection() }) } } }); quote! { - impl #impl_generics #engine_crate_path::reflection::With for + impl #impl_generics #engine_crate_path::reflection::Reflection for #input_ident #type_generics #where_clause { - const REFLECTION: &#engine_crate_path::reflection::Reflection = + const TYPE_REFLECTION: &#engine_crate_path::reflection::Type = &const { - #engine_crate_path::reflection::Reflection::Struct( + #engine_crate_path::reflection::Type::Struct( #engine_crate_path::reflection::Struct { fields: &[ #(#fields),* @@ -113,16 +119,6 @@ pub fn reflection_derive(input: TokenStream) -> TokenStream } ) }; - - fn reflection() -> &'static #engine_crate_path::reflection::Reflection - { - Self::REFLECTION - } - - fn get_reflection(&self) -> &'static #engine_crate_path::reflection::Reflection - { - Self::reflection() - } } } .into() |
