summaryrefslogtreecommitdiff
path: root/rust/src/component.rs
diff options
context:
space:
mode:
Diffstat (limited to 'rust/src/component.rs')
-rw-r--r--rust/src/component.rs23
1 files changed, 22 insertions, 1 deletions
diff --git a/rust/src/component.rs b/rust/src/component.rs
index 4c5d5992..f038d5c3 100644
--- a/rust/src/component.rs
+++ b/rust/src/component.rs
@@ -2,7 +2,7 @@ use crate::binary_view::{BinaryView, BinaryViewExt};
use crate::function::Function;
use crate::rc::{Array, CoreArrayProvider, CoreArrayProviderInner, Guard, Ref, RefCountable};
use crate::string::{BnString, IntoCStr};
-use crate::types::ComponentReferencedType;
+use crate::types::Type;
use std::ffi::c_char;
use std::fmt::Debug;
use std::ptr::NonNull;
@@ -304,3 +304,24 @@ unsafe impl CoreArrayProviderInner for Component {
Guard::new(Self::from_raw(raw_ptr), context)
}
}
+
+// TODO: Remove this struct, or make it not a ZST with a terrible array provider.
+/// ZST used only for `Array<ComponentReferencedType>`.
+pub struct ComponentReferencedType;
+
+impl CoreArrayProvider for ComponentReferencedType {
+ type Raw = *mut BNType;
+ type Context = ();
+ type Wrapped<'a> = &'a Type;
+}
+
+unsafe impl CoreArrayProviderInner for ComponentReferencedType {
+ unsafe fn free(raw: *mut Self::Raw, count: usize, _context: &Self::Context) {
+ BNComponentFreeReferencedTypes(raw, count)
+ }
+
+ unsafe fn wrap_raw<'a>(raw: &'a Self::Raw, _context: &'a Self::Context) -> Self::Wrapped<'a> {
+ // SAFETY: &*mut BNType == &Type (*mut BNType == Type)
+ std::mem::transmute(raw)
+ }
+}