From 48e70075f641181e23847bf7f0ff7ac90cc463a3 Mon Sep 17 00:00:00 2001 From: HampusM Date: Thu, 18 Jun 2026 23:32:36 +0200 Subject: feat(engine-reflection): add reference reflection --- engine-reflection/src/lib.rs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'engine-reflection') diff --git a/engine-reflection/src/lib.rs b/engine-reflection/src/lib.rs index dabf4b9..b48ecfe 100644 --- a/engine-reflection/src/lib.rs +++ b/engine-reflection/src/lib.rs @@ -45,6 +45,7 @@ pub enum Type Array(Array), Slice(Slice), Literal(Literal), + Reference(Reference), } impl Type @@ -72,7 +73,7 @@ impl Type Self::Struct(struct_type) => struct_type.default_value(), Self::Enum(enum_type) => enum_type.default_value(), Self::Literal(literal_type) => literal_type.default_value(), - Self::Array(_) | Self::Slice(_) => None, + Self::Array(_) | Self::Slice(_) | Self::Reference(_) => None, } } @@ -83,7 +84,7 @@ impl Type Self::Struct(struct_type) => struct_type.has_default_value(), Self::Enum(enum_type) => enum_type.has_default_value(), Self::Literal(literal_type) => literal_type.has_default_value(), - Self::Array(_) | Self::Slice(_) => false, + Self::Array(_) | Self::Slice(_) | Self::Reference(_) => false, } } } @@ -281,6 +282,12 @@ impl Literal } } +#[derive(Debug)] +pub struct Reference +{ + pub ty: &'static Type, +} + #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] #[non_exhaustive] pub enum LiteralType @@ -375,6 +382,11 @@ unsafe impl Reflection for &'static [T] }); } +unsafe impl Reflection for &'static T +{ + const TYPE_REFLECTION: &Type = &Type::Reference(Reference { ty: T::TYPE_REFLECTION }); +} + #[derive(Clone)] pub struct FnWithDebug { -- cgit v1.2.3-18-g5258