From ea95389b7fae4d75f3c8b6c465866834545ad5d9 Mon Sep 17 00:00:00 2001 From: HampusM Date: Tue, 9 Jun 2026 17:36:17 +0200 Subject: feat(engine): add offsets to reflection of enum variant fields --- engine-macros/src/reflection/struct_impl.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'engine-macros/src/reflection/struct_impl.rs') diff --git a/engine-macros/src/reflection/struct_impl.rs b/engine-macros/src/reflection/struct_impl.rs index 57e3e21..92cf00b 100644 --- a/engine-macros/src/reflection/struct_impl.rs +++ b/engine-macros/src/reflection/struct_impl.rs @@ -22,7 +22,13 @@ pub fn generate(input: syn::ItemStruct) -> proc_macro2::TokenStream &engine_crate_path, ReflectionFieldGenOptions { field_vis_override: None, - include_byte_offset: true, + gen_get_byte_offset: &|field| { + if let Some(field_ident) = &field.ident { + quote! { std::mem::offset_of!(Self, #field_ident) } + } else { + quote! { std::mem::offset_of!(Self, #field_index) } + } + }, }, ) }); -- cgit v1.2.3-18-g5258