summaryrefslogtreecommitdiff
path: root/engine-macros/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'engine-macros/src/lib.rs')
-rw-r--r--engine-macros/src/lib.rs38
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()