diff options
| author | Ryan Snyder <ryan@vector35.com> | 2024-05-01 10:43:58 -0400 |
|---|---|---|
| committer | Ryan Snyder <ryan@vector35.com> | 2024-05-01 10:43:58 -0400 |
| commit | 87b1470b2de74640c856d8a90ba88ec672713d71 (patch) | |
| tree | efcdf60ca4b7709b30221cf1e2898c6fc89254b8 /rust/src | |
| parent | 8817116bee33f3d8bee71fbd82b1220deb10993d (diff) | |
rust: account for changes to NameAndType bindings
Diffstat (limited to 'rust/src')
| -rw-r--r-- | rust/src/architecture.rs | 6 | ||||
| -rw-r--r-- | rust/src/debuginfo.rs | 4 | ||||
| -rw-r--r-- | rust/src/types.rs | 19 |
3 files changed, 10 insertions, 19 deletions
diff --git a/rust/src/architecture.rs b/rust/src/architecture.rs index db887e4f..0e1349e6 100644 --- a/rust/src/architecture.rs +++ b/rust/src/architecture.rs @@ -1000,7 +1000,7 @@ impl Intrinsic for crate::architecture::CoreIntrinsic { let ret = slice::from_raw_parts_mut(inputs, count) .iter() - .map(NameAndType::from_raw) + .map(|x| NameAndType::from_raw(x).to_owned()) .collect(); BNFreeNameAndTypeList(inputs, count); @@ -2419,7 +2419,7 @@ where }; let inputs = intrinsic.inputs(); - let mut res: Box<[_]> = inputs.into_iter().map(|input| input.into_raw()).collect(); + let mut res: Box<[_]> = inputs.into_iter().map(|input| unsafe { Ref::into_raw(input) }.0).collect(); unsafe { *count = res.len(); @@ -2443,7 +2443,7 @@ where unsafe { let name_and_types = Box::from_raw(ptr::slice_from_raw_parts_mut(nt, count)); for nt in name_and_types.into_iter() { - BnString::from_raw(nt.name); + Ref::new(NameAndType::from_raw(nt)); } } } diff --git a/rust/src/debuginfo.rs b/rust/src/debuginfo.rs index ac398334..d53faef3 100644 --- a/rust/src/debuginfo.rs +++ b/rust/src/debuginfo.rs @@ -390,7 +390,7 @@ impl DebugInfo { let result: Vec<Ref<NameAndType>> = unsafe { slice::from_raw_parts_mut(debug_types_ptr, count) .iter() - .map(NameAndType::from_raw) + .map(|x| NameAndType::from_raw(x).to_owned()) .collect() }; @@ -405,7 +405,7 @@ impl DebugInfo { let result: Vec<Ref<NameAndType>> = unsafe { slice::from_raw_parts_mut(debug_types_ptr, count) .iter() - .map(NameAndType::from_raw) + .map(|x| NameAndType::from_raw(x).to_owned()) .collect() }; diff --git a/rust/src/types.rs b/rust/src/types.rs index dae8a6cc..75c8fb36 100644 --- a/rust/src/types.rs +++ b/rust/src/types.rs @@ -2440,16 +2440,11 @@ unsafe impl CoreArrayWrapper for QualifiedNameTypeAndId { ////////////////////////// // NameAndType -#[repr(transparent)] pub struct NameAndType(pub(crate) BNNameAndType); impl NameAndType { - pub(crate) fn from_raw(raw: &BNNameAndType) -> Ref<Self> { - Self::new( - raw_to_string(raw.name).unwrap(), - unsafe { &Type::ref_from_raw(raw.type_) }, - raw.typeConfidence, - ) + pub(crate) unsafe fn from_raw(raw: &BNNameAndType) -> Self { + Self ( *raw ) } } @@ -2464,10 +2459,6 @@ impl NameAndType { } } - pub(crate) fn into_raw(self) -> BNNameAndType { - self.0 - } - pub fn name(&self) -> &str { let c_str = unsafe { CStr::from_ptr(self.0.name) }; c_str.to_str().unwrap() @@ -2495,7 +2486,7 @@ unsafe impl RefCountable for NameAndType { Self::new( CStr::from_ptr(handle.0.name), handle.t(), - handle.type_with_confidence().confidence, + handle.0.typeConfidence, ) } @@ -2519,10 +2510,10 @@ unsafe impl CoreOwnedArrayProvider for NameAndType { } unsafe impl CoreArrayWrapper for NameAndType { - type Wrapped<'a> = &'a NameAndType; + type Wrapped<'a> = Guard<'a, NameAndType>; unsafe fn wrap_raw<'a>(raw: &'a Self::Raw, _context: &'a Self::Context) -> Self::Wrapped<'a> { - mem::transmute(raw) + unsafe { Guard::new(NameAndType::from_raw(raw), raw) } } } |
