Skip to content

Commit 87b1470

Browse files
committed
rust: account for changes to NameAndType bindings
1 parent 8817116 commit 87b1470

File tree

3 files changed

+10
-19
lines changed

3 files changed

+10
-19
lines changed

rust/src/architecture.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,7 +1000,7 @@ impl Intrinsic for crate::architecture::CoreIntrinsic {
10001000

10011001
let ret = slice::from_raw_parts_mut(inputs, count)
10021002
.iter()
1003-
.map(NameAndType::from_raw)
1003+
.map(|x| NameAndType::from_raw(x).to_owned())
10041004
.collect();
10051005

10061006
BNFreeNameAndTypeList(inputs, count);
@@ -2419,7 +2419,7 @@ where
24192419
};
24202420

24212421
let inputs = intrinsic.inputs();
2422-
let mut res: Box<[_]> = inputs.into_iter().map(|input| input.into_raw()).collect();
2422+
let mut res: Box<[_]> = inputs.into_iter().map(|input| unsafe { Ref::into_raw(input) }.0).collect();
24232423

24242424
unsafe {
24252425
*count = res.len();
@@ -2443,7 +2443,7 @@ where
24432443
unsafe {
24442444
let name_and_types = Box::from_raw(ptr::slice_from_raw_parts_mut(nt, count));
24452445
for nt in name_and_types.into_iter() {
2446-
BnString::from_raw(nt.name);
2446+
Ref::new(NameAndType::from_raw(nt));
24472447
}
24482448
}
24492449
}

rust/src/debuginfo.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ impl DebugInfo {
390390
let result: Vec<Ref<NameAndType>> = unsafe {
391391
slice::from_raw_parts_mut(debug_types_ptr, count)
392392
.iter()
393-
.map(NameAndType::from_raw)
393+
.map(|x| NameAndType::from_raw(x).to_owned())
394394
.collect()
395395
};
396396

@@ -405,7 +405,7 @@ impl DebugInfo {
405405
let result: Vec<Ref<NameAndType>> = unsafe {
406406
slice::from_raw_parts_mut(debug_types_ptr, count)
407407
.iter()
408-
.map(NameAndType::from_raw)
408+
.map(|x| NameAndType::from_raw(x).to_owned())
409409
.collect()
410410
};
411411

rust/src/types.rs

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2440,16 +2440,11 @@ unsafe impl CoreArrayWrapper for QualifiedNameTypeAndId {
24402440
//////////////////////////
24412441
// NameAndType
24422442

2443-
#[repr(transparent)]
24442443
pub struct NameAndType(pub(crate) BNNameAndType);
24452444

24462445
impl NameAndType {
2447-
pub(crate) fn from_raw(raw: &BNNameAndType) -> Ref<Self> {
2448-
Self::new(
2449-
raw_to_string(raw.name).unwrap(),
2450-
unsafe { &Type::ref_from_raw(raw.type_) },
2451-
raw.typeConfidence,
2452-
)
2446+
pub(crate) unsafe fn from_raw(raw: &BNNameAndType) -> Self {
2447+
Self ( *raw )
24532448
}
24542449
}
24552450

@@ -2464,10 +2459,6 @@ impl NameAndType {
24642459
}
24652460
}
24662461

2467-
pub(crate) fn into_raw(self) -> BNNameAndType {
2468-
self.0
2469-
}
2470-
24712462
pub fn name(&self) -> &str {
24722463
let c_str = unsafe { CStr::from_ptr(self.0.name) };
24732464
c_str.to_str().unwrap()
@@ -2495,7 +2486,7 @@ unsafe impl RefCountable for NameAndType {
24952486
Self::new(
24962487
CStr::from_ptr(handle.0.name),
24972488
handle.t(),
2498-
handle.type_with_confidence().confidence,
2489+
handle.0.typeConfidence,
24992490
)
25002491
}
25012492

@@ -2519,10 +2510,10 @@ unsafe impl CoreOwnedArrayProvider for NameAndType {
25192510
}
25202511

25212512
unsafe impl CoreArrayWrapper for NameAndType {
2522-
type Wrapped<'a> = &'a NameAndType;
2513+
type Wrapped<'a> = Guard<'a, NameAndType>;
25232514

25242515
unsafe fn wrap_raw<'a>(raw: &'a Self::Raw, _context: &'a Self::Context) -> Self::Wrapped<'a> {
2525-
mem::transmute(raw)
2516+
unsafe { Guard::new(NameAndType::from_raw(raw), raw) }
25262517
}
25272518
}
25282519

0 commit comments

Comments
 (0)