@@ -298,11 +298,11 @@ fn impl_abstract_structure_type(
298
298
( quote ! { #width } , quote ! { #align } )
299
299
}
300
300
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 ( ) } } ,
303
303
) ,
304
304
} ;
305
- quote ! { #ident: #field_wrapper<[ u8 ; #size] , #align> }
305
+ quote ! { #ident: #field_wrapper<#size, #align> }
306
306
} )
307
307
. collect :: < Vec < _ > > ( ) ;
308
308
let args = abstract_fields
@@ -330,7 +330,7 @@ fn impl_abstract_structure_type(
330
330
. map ( |n| {
331
331
(
332
332
quote ! { #[ repr( align( #n) ) ] } ,
333
- quote ! { . set_alignment( Self :: ALIGN ) } ,
333
+ quote ! { . set_alignment( Self :: LAYOUT . align ( ) ) } ,
334
334
)
335
335
} )
336
336
. unzip ( ) ;
@@ -348,12 +348,12 @@ fn impl_abstract_structure_type(
348
348
Ok ( quote ! {
349
349
#[ repr( C ) ]
350
350
#[ derive( Copy , Clone ) ]
351
- struct #field_wrapper<T , const N : usize >
351
+ struct #field_wrapper<const SIZE : usize , const ALIGN : usize >
352
352
where
353
- :: binaryninja:: elain:: Align <N >: :: binaryninja:: elain:: Alignment
353
+ :: binaryninja:: elain:: Align <ALIGN >: :: binaryninja:: elain:: Alignment
354
354
{
355
- t: T ,
356
- _align: :: binaryninja:: elain:: Align <N >,
355
+ t: [ u8 ; SIZE ] ,
356
+ _align: :: binaryninja:: elain:: Align <ALIGN >,
357
357
}
358
358
359
359
#[ repr( C ) ]
@@ -364,13 +364,12 @@ fn impl_abstract_structure_type(
364
364
}
365
365
366
366
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>( ) ;
369
368
fn resolve_type( ) -> :: binaryninja:: rc:: Ref <:: binaryninja:: types:: Type > {
370
369
:: binaryninja:: types:: Type :: structure(
371
370
& :: binaryninja:: types:: Structure :: builder( )
372
371
#( . insert( #args) ) *
373
- . set_width( Self :: SIZE as u64 )
372
+ . set_width( Self :: LAYOUT . size ( ) as u64 )
374
373
. set_packed( #is_packed)
375
374
#set_alignment
376
375
#set_union
0 commit comments