|
1 | | -use crate::binary_view::{BinaryView, BinaryViewExt}; |
2 | | -use crate::function::Function; |
3 | | -use crate::rc::{Array, CoreArrayProvider, CoreArrayProviderInner, Guard, Ref, RefCountable}; |
4 | | -use crate::string::{BnString, IntoCStr}; |
5 | | -use crate::types::ComponentReferencedType; |
6 | 1 | use std::ffi::c_char; |
7 | 2 | use std::fmt::Debug; |
8 | 3 | use std::ptr::NonNull; |
9 | 4 |
|
10 | | -use crate::variable::DataVariable; |
11 | 5 | use binaryninjacore_sys::*; |
12 | 6 |
|
| 7 | +use crate::binary_view::{BinaryView, BinaryViewExt}; |
| 8 | +use crate::function::Function; |
| 9 | +use crate::rc::{Array, CoreArrayProvider, CoreArrayProviderInner, Guard, Ref, RefCountable}; |
| 10 | +use crate::string::{BnString, IntoCStr}; |
| 11 | +use crate::types::Type; |
| 12 | +use crate::variable::DataVariable; |
| 13 | + |
13 | 14 | pub struct ComponentBuilder { |
14 | 15 | view: Ref<BinaryView>, |
15 | 16 | parent: Option<String>, |
@@ -304,3 +305,24 @@ unsafe impl CoreArrayProviderInner for Component { |
304 | 305 | Guard::new(Self::from_raw(raw_ptr), context) |
305 | 306 | } |
306 | 307 | } |
| 308 | + |
| 309 | +// TODO: Remove this struct, or make it not a ZST with a terrible array provider. |
| 310 | +/// ZST used only for `Array<ComponentReferencedType>`. |
| 311 | +pub struct ComponentReferencedType; |
| 312 | + |
| 313 | +impl CoreArrayProvider for ComponentReferencedType { |
| 314 | + type Raw = *mut BNType; |
| 315 | + type Context = (); |
| 316 | + type Wrapped<'a> = &'a Type; |
| 317 | +} |
| 318 | + |
| 319 | +unsafe impl CoreArrayProviderInner for ComponentReferencedType { |
| 320 | + unsafe fn free(raw: *mut Self::Raw, count: usize, _context: &Self::Context) { |
| 321 | + BNComponentFreeReferencedTypes(raw, count) |
| 322 | + } |
| 323 | + |
| 324 | + unsafe fn wrap_raw<'a>(raw: &'a Self::Raw, _context: &'a Self::Context) -> Self::Wrapped<'a> { |
| 325 | + // SAFETY: &*mut BNType == &Type (*mut BNType == Type) |
| 326 | + std::mem::transmute(raw) |
| 327 | + } |
| 328 | +} |
0 commit comments