@@ -57,7 +57,6 @@ pub type MemberScope = BNMemberScope;
57
57
// Confidence
58
58
59
59
/// Compatible with the `BNType*WithConfidence` types
60
- #[ repr( C ) ]
61
60
pub struct Conf < T > {
62
61
pub contents : T ,
63
62
pub confidence : u8 ,
@@ -2487,9 +2486,8 @@ impl NameAndType {
2487
2486
unsafe { mem:: transmute :: < _ , & Type > ( & self . 0 . type_ ) }
2488
2487
}
2489
2488
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 )
2493
2491
}
2494
2492
}
2495
2493
@@ -2545,11 +2543,11 @@ pub struct DataVariable(pub(crate) BNDataVariable);
2545
2543
2546
2544
// impl DataVariable {
2547
2545
// 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
+ // })
2553
2551
// }
2554
2552
// }
2555
2553
@@ -2558,18 +2556,16 @@ impl DataVariable {
2558
2556
self . 0 . address
2559
2557
}
2560
2558
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
2563
2561
}
2564
2562
2565
2563
pub fn t ( & self ) -> & Type {
2566
2564
unsafe { mem:: transmute ( & self . 0 . type_ ) }
2567
2565
}
2568
2566
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 )
2573
2569
}
2574
2570
2575
2571
pub fn symbol ( & self , bv : & BinaryView ) -> Option < Ref < Symbol > > {
0 commit comments