diff options
Diffstat (limited to 'engine-reflection/src')
| -rw-r--r-- | engine-reflection/src/lib.rs | 35 |
1 files 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<T: Reflection, const LEN: usize> 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::<T>(), + get_item_type_name: FnWithDebug::new(|| type_name::<T>()), length: LEN, }); } unsafe impl<T: Reflection> 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::<T>(), + get_item_type_name: FnWithDebug::new(|| type_name::<T>()), + }); } #[derive(Clone)] |
