From 74a038d7eefa389b6d621365998c4bffc6eb8efb Mon Sep 17 00:00:00 2001 From: HampusM Date: Thu, 18 Jun 2026 23:30:04 +0200 Subject: feat(engine-reflection): add item layout & item type name to Array & Slice --- engine-reflection/src/lib.rs | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/engine-reflection/src/lib.rs b/engine-reflection/src/lib.rs index 3bd6f97..dabf4b9 100644 --- a/engine-reflection/src/lib.rs +++ b/engine-reflection/src/lib.rs @@ -225,14 +225,34 @@ impl Field #[derive(Debug, Clone)] pub struct Array { - pub item_reflection: &'static Type, + pub item_type: &'static Type, + pub item_layout: Layout, + pub get_item_type_name: FnWithDebug<&'static str>, pub length: usize, } +impl Array +{ + pub fn item_type_name(&self) -> &'static str + { + self.get_item_type_name.get() + } +} + #[derive(Debug, Clone)] pub struct Slice { - pub item_reflection: &'static Type, + pub item_type: &'static Type, + pub item_layout: Layout, + pub get_item_type_name: FnWithDebug<&'static str>, +} + +impl Slice +{ + pub fn item_type_name(&self) -> &'static str + { + self.get_item_type_name.get() + } } #[derive(Debug)] @@ -339,15 +359,20 @@ impl_reflection_for_literals!( unsafe impl Reflection for [T; LEN] { const TYPE_REFLECTION: &Type = &Type::Array(Array { - item_reflection: T::TYPE_REFLECTION, + item_type: T::TYPE_REFLECTION, + item_layout: Layout::new::(), + get_item_type_name: FnWithDebug::new(|| type_name::()), length: LEN, }); } unsafe impl Reflection for &'static [T] { - const TYPE_REFLECTION: &Type = - &Type::Slice(Slice { item_reflection: T::TYPE_REFLECTION }); + const TYPE_REFLECTION: &Type = &Type::Slice(Slice { + item_type: T::TYPE_REFLECTION, + item_layout: Layout::new::(), + get_item_type_name: FnWithDebug::new(|| type_name::()), + }); } #[derive(Clone)] -- cgit v1.2.3-18-g5258