@@ -298,11 +298,11 @@ fn impl_abstract_structure_type(
298298 ( quote ! { #width } , quote ! { #align } )
299299 }
300300 FieldKind :: Ty ( ty) => (
301- quote ! { <#ty as :: binaryninja:: types:: AbstractType >:: SIZE } ,
302- quote ! { { <#ty as :: binaryninja:: types:: AbstractType >:: ALIGN } } ,
301+ quote ! { { <#ty as :: binaryninja:: types:: AbstractType >:: LAYOUT . size ( ) } } ,
302+ quote ! { { <#ty as :: binaryninja:: types:: AbstractType >:: LAYOUT . align ( ) } } ,
303303 ) ,
304304 } ;
305- quote ! { #ident: #field_wrapper<[ u8 ; #size] , #align> }
305+ quote ! { #ident: #field_wrapper<#size, #align> }
306306 } )
307307 . collect :: < Vec < _ > > ( ) ;
308308 let args = abstract_fields
@@ -330,7 +330,7 @@ fn impl_abstract_structure_type(
330330 . map ( |n| {
331331 (
332332 quote ! { #[ repr( align( #n) ) ] } ,
333- quote ! { . set_alignment( Self :: ALIGN ) } ,
333+ quote ! { . set_alignment( Self :: LAYOUT . align ( ) ) } ,
334334 )
335335 } )
336336 . unzip ( ) ;
@@ -348,12 +348,12 @@ fn impl_abstract_structure_type(
348348 Ok ( quote ! {
349349 #[ repr( C ) ]
350350 #[ derive( Copy , Clone ) ]
351- struct #field_wrapper<T , const N : usize >
351+ struct #field_wrapper<const SIZE : usize , const ALIGN : usize >
352352 where
353- :: binaryninja:: elain:: Align <N >: :: binaryninja:: elain:: Alignment
353+ :: binaryninja:: elain:: Align <ALIGN >: :: binaryninja:: elain:: Alignment
354354 {
355- t: T ,
356- _align: :: binaryninja:: elain:: Align <N >,
355+ t: [ u8 ; SIZE ] ,
356+ _align: :: binaryninja:: elain:: Align <ALIGN >,
357357 }
358358
359359 #[ repr( C ) ]
@@ -364,13 +364,12 @@ fn impl_abstract_structure_type(
364364 }
365365
366366 impl :: binaryninja:: types:: AbstractType for #name {
367- const SIZE : usize = :: std:: mem:: size_of:: <#layout_name>( ) ;
368- const ALIGN : usize = :: std:: mem:: align_of:: <#layout_name>( ) ;
367+ const LAYOUT : :: std:: alloc:: Layout = :: std:: alloc:: Layout :: new:: <#layout_name>( ) ;
369368 fn resolve_type( ) -> :: binaryninja:: rc:: Ref <:: binaryninja:: types:: Type > {
370369 :: binaryninja:: types:: Type :: structure(
371370 & :: binaryninja:: types:: Structure :: builder( )
372371 #( . insert( #args) ) *
373- . set_width( Self :: SIZE as u64 )
372+ . set_width( Self :: LAYOUT . size ( ) as u64 )
374373 . set_packed( #is_packed)
375374 #set_alignment
376375 #set_union
0 commit comments