diff options
| author | HampusM <hampus@hampusmat.com> | 2026-06-18 23:33:07 +0200 |
|---|---|---|
| committer | HampusM <hampus@hampusmat.com> | 2026-06-18 23:33:07 +0200 |
| commit | d6cf708a4fd1caf0f2e193ceb7c23fa8e77cc1db (patch) | |
| tree | 90dec16ff48a5d8c46c4dfd72c9dd4b340153e0e | |
| parent | 48e70075f641181e23847bf7f0ff7ac90cc463a3 (diff) | |
| -rw-r--r-- | engine-macros/src/reflection/enum_impl.rs | 11 | ||||
| -rw-r--r-- | engine-reflection/src/lib.rs | 2 |
2 files changed, 13 insertions, 0 deletions
diff --git a/engine-macros/src/reflection/enum_impl.rs b/engine-macros/src/reflection/enum_impl.rs index 0ce2562..9d53d8e 100644 --- a/engine-macros/src/reflection/enum_impl.rs +++ b/engine-macros/src/reflection/enum_impl.rs @@ -139,6 +139,16 @@ fn generate_impls( let input_ident = &input.ident; + let discriminant_size = if is_unit_only { + quote! { + std::mem::size_of::<Self>() + } + } else { + quote! { + std::mem::size_of::<#mod_name::Discriminant>() + } + }; + quote! { unsafe impl #engine_crate_path::reflection::Reflection for #input_ident #generic_args @@ -151,6 +161,7 @@ fn generate_impls( #engine_crate_path::reflection::Enum { variants: &[#(#variants),*], is_unit_only: #is_unit_only, + discriminant_size: #discriminant_size, tagged_union: #tagged_union, get_default_value: || { #get_default_value_fn diff --git a/engine-reflection/src/lib.rs b/engine-reflection/src/lib.rs index b48ecfe..289989c 100644 --- a/engine-reflection/src/lib.rs +++ b/engine-reflection/src/lib.rs @@ -120,6 +120,8 @@ pub struct Enum /// The enum only contains unit variants. pub is_unit_only: bool, + pub discriminant_size: usize, + pub tagged_union: Option<EnumTaggedUnion>, pub get_default_value: fn() -> Option<DefaultValueFn>, |
