diff options
| author | HampusM <hampus@hampusmat.com> | 2026-06-08 17:19:46 +0200 |
|---|---|---|
| committer | HampusM <hampus@hampusmat.com> | 2026-06-08 17:19:46 +0200 |
| commit | eaff58026be19c068005d6e90bd9e8cbe985b093 (patch) | |
| tree | 9798fb71252a1c468b3ccb94f270ee59cb77366a /engine-reflection/src/lib.rs | |
| parent | 02b258ae1eefbcc613afbd9fab0f195401a00b35 (diff) | |
Diffstat (limited to 'engine-reflection/src/lib.rs')
| -rw-r--r-- | engine-reflection/src/lib.rs | 53 |
1 files changed, 36 insertions, 17 deletions
diff --git a/engine-reflection/src/lib.rs b/engine-reflection/src/lib.rs index ef705a0..53aa953 100644 --- a/engine-reflection/src/lib.rs +++ b/engine-reflection/src/lib.rs @@ -69,23 +69,55 @@ impl Type #[derive(Debug, Clone)] pub struct Struct { - pub fields: &'static [StructField], + pub fields: &'static [Field], } #[derive(Debug, Clone)] -pub struct StructField +pub struct Enum +{ + /// Enum variants in the same order as in the enum definition. + pub variants: &'static [EnumVariant], + + /// The enum only contains unit variants. + pub is_unit_only: bool, +} + +#[derive(Debug, Clone)] +pub struct EnumVariant { pub name: &'static str, + + /// The fields of this variant. If `None`, this variant is a unit variant. + pub fields: Option<EnumVariantFields>, +} + +#[derive(Debug, Clone)] +pub enum EnumVariantFields +{ + Named + { + fields: &'static [Field] + }, + Unnamed + { + fields: &'static [Field] + }, +} + +#[derive(Debug, Clone)] +pub struct Field +{ + pub name: Option<&'static str>, pub index: usize, pub layout: Layout, - pub byte_offset: usize, + pub byte_offset: Option<usize>, pub type_id: TypeId, pub type_name: &'static str, pub get_type: FnWithDebug<Option<&'static Type>>, pub visibility: Visibility, } -impl StructField +impl Field { pub fn type_reflection(&self) -> Option<&'static Type> { @@ -94,19 +126,6 @@ impl StructField } #[derive(Debug, Clone)] -pub struct Enum -{ - /// Enum variants in the same order as in the enum definition. - pub variants: &'static [EnumVariant], -} - -#[derive(Debug, Clone)] -pub struct EnumVariant -{ - pub name: &'static str, -} - -#[derive(Debug, Clone)] pub struct Array { pub item_reflection: &'static Type, |
