diff options
Diffstat (limited to 'rust/src/disassembly.rs')
| -rw-r--r-- | rust/src/disassembly.rs | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/rust/src/disassembly.rs b/rust/src/disassembly.rs index 855807b1..1fd51cee 100644 --- a/rust/src/disassembly.rs +++ b/rust/src/disassembly.rs @@ -265,6 +265,35 @@ impl Drop for InstructionTextToken { } } +impl CoreArrayProvider for InstructionTextToken { + type Raw = BNInstructionTextToken; + type Context = (); + type Wrapped<'a> = Self; +} +unsafe impl CoreArrayProviderInner for InstructionTextToken { + unsafe fn free(raw: *mut Self::Raw, count: usize, _context: &Self::Context) { + BNFreeInstructionText(raw, count) + } + unsafe fn wrap_raw<'a>(raw: &'a Self::Raw, _context: &'a Self::Context) -> Self::Wrapped<'a> { + Self(*raw) + } +} + +impl CoreArrayProvider for Array<InstructionTextToken> { + type Raw = BNInstructionTextLine; + type Context = (); + type Wrapped<'a> = Self; +} +unsafe impl CoreArrayProviderInner for Array<InstructionTextToken> { + unsafe fn free(raw: *mut Self::Raw, count: usize, _context: &Self::Context) { + BNFreeInstructionTextLines(raw, count) + } + unsafe fn wrap_raw<'a>(raw: &'a Self::Raw, _context: &'a Self::Context) -> Self::Wrapped<'a> { + Self::new(raw.tokens, raw.count, ()) + } +} + +#[repr(transparent)] pub struct DisassemblyTextLine(pub(crate) BNDisassemblyTextLine); impl DisassemblyTextLine { @@ -422,6 +451,21 @@ impl Drop for DisassemblyTextLine { } } +impl CoreArrayProvider for DisassemblyTextLine { + type Raw = BNDisassemblyTextLine; + type Context = (); + type Wrapped<'a> = &'a Self; +} + +unsafe impl CoreArrayProviderInner for DisassemblyTextLine { + unsafe fn free(raw: *mut Self::Raw, count: usize, _context: &Self::Context) { + BNFreeDisassemblyTextLines(raw, count) + } + unsafe fn wrap_raw<'a>(raw: &'a Self::Raw, _context: &'a Self::Context) -> Self::Wrapped<'a> { + core::mem::transmute(raw) + } +} + pub type DisassemblyOption = BNDisassemblyOption; #[derive(PartialEq, Eq, Hash)] |
