summaryrefslogtreecommitdiff
path: root/engine-macros
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2026-07-07 21:43:55 +0200
committerHampusM <hampus@hampusmat.com>2026-07-07 21:43:55 +0200
commit28686c9359da2c2c46d12ae8aaada14ece17246f (patch)
treea2a260384eb53b214a5837284a594bd3c12f56ad /engine-macros
parent0820dde7d6099f87f9eda6240b64306900e00855 (diff)
feat(engine): change enum reflection get_variant_reflection fn to get_variant_index
Diffstat (limited to 'engine-macros')
-rw-r--r--engine-macros/src/reflection/enum_impl.rs19
1 files changed, 15 insertions, 4 deletions
diff --git a/engine-macros/src/reflection/enum_impl.rs b/engine-macros/src/reflection/enum_impl.rs
index 1cc8f0a..4e27c2b 100644
--- a/engine-macros/src/reflection/enum_impl.rs
+++ b/engine-macros/src/reflection/enum_impl.rs
@@ -110,15 +110,26 @@ fn generate_impls(
#get_default_value_fn
},
cast_dyn_any: |ptr| ptr.cast::<Self>(),
- get_variant_reflection: |target| {
+ get_variant_index: |target| {
use std::any::Any;
+ use #engine_crate_path::reflection::Reflection;
use #engine_crate_path::reflection::EnumReflectionExt;
let target = target.downcast_ref::<Self>()?;
- Some(<Self as EnumReflectionExt>::get_variant_reflection(
- target
- ))
+ let enum_reflection = unsafe {
+ <Self as Reflection>::TYPE_REFLECTION
+ .as_enum()
+ .unwrap_unchecked()
+ };
+
+ Some(enum_reflection.variants
+ .element_offset(
+ match target {
+ #(#variant_lookup_match_arms),*
+ }
+ )
+ .unwrap())
}
}
)