summaryrefslogtreecommitdiff
path: root/engine-macros/src/reflection/struct_impl.rs
diff options
context:
space:
mode:
Diffstat (limited to 'engine-macros/src/reflection/struct_impl.rs')
-rw-r--r--engine-macros/src/reflection/struct_impl.rs8
1 files changed, 7 insertions, 1 deletions
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) }
+ }
+ },
},
)
});