@@ -57,7 +57,6 @@ pub type MemberScope = BNMemberScope;
5757// Confidence
5858
5959/// Compatible with the `BNType*WithConfidence` types
60- #[ repr( C ) ]
6160pub struct Conf < T > {
6261 pub contents : T ,
6362 pub confidence : u8 ,
@@ -2487,9 +2486,8 @@ impl NameAndType {
24872486 unsafe { mem:: transmute :: < _ , & Type > ( & self . 0 . type_ ) }
24882487 }
24892488
2490- pub fn type_with_confidence ( & self ) -> & Conf < Type > {
2491- // the struct BNNameAndType contains a Conf inside of it, so this is safe
2492- unsafe { mem:: transmute :: < _ , & Conf < Type > > ( & self . 0 . type_ ) }
2489+ pub fn type_with_confidence ( & self ) -> Conf < & Type > {
2490+ Conf :: new ( self . t ( ) , self . 0 . typeConfidence )
24932491 }
24942492}
24952493
@@ -2545,11 +2543,11 @@ pub struct DataVariable(pub(crate) BNDataVariable);
25452543
25462544// impl DataVariable {
25472545// pub(crate) fn from_raw(var: &BNDataVariable) -> Self {
2548- // Self {
2549- // address: var.address,
2550- // t: Conf::new( unsafe { Type::ref_from_raw (var.type_) }, var.typeConfidence) ,
2551- // auto_discovered: var.autoDiscovered,
2552- // }
2546+ // let var = DataVariable(*var);
2547+ // Self(BNDataVariable {
2548+ // type_: unsafe { Ref::into_raw (var.t().to_owned()).handle } ,
2549+ // .. var.0
2550+ // })
25532551// }
25542552// }
25552553
@@ -2558,18 +2556,16 @@ impl DataVariable {
25582556 self . 0 . address
25592557 }
25602558
2561- pub fn auto_discovered ( & self ) -> & bool {
2562- unsafe { mem :: transmute ( & self . 0 . autoDiscovered ) }
2559+ pub fn auto_discovered ( & self ) -> bool {
2560+ self . 0 . autoDiscovered
25632561 }
25642562
25652563 pub fn t ( & self ) -> & Type {
25662564 unsafe { mem:: transmute ( & self . 0 . type_ ) }
25672565 }
25682566
2569- pub fn type_with_confidence ( & self ) -> Conf < Ref < Type > > {
2570- // if it was not for the `autoDiscovered: bool` between `type_` and
2571- // `typeConfidence` this could have being a reference, like NameAndType
2572- Conf :: new ( self . t ( ) . to_owned ( ) , self . 0 . typeConfidence )
2567+ pub fn type_with_confidence ( & self ) -> Conf < & Type > {
2568+ Conf :: new ( self . t ( ) , self . 0 . typeConfidence )
25732569 }
25742570
25752571 pub fn symbol ( & self , bv : & BinaryView ) -> Option < Ref < Symbol > > {
0 commit comments