diff options
| author | rose <47357290+rose4096@users.noreply.github.com> | 2022-06-22 13:37:21 -0400 |
|---|---|---|
| committer | rose <47357290+rose4096@users.noreply.github.com> | 2022-06-23 12:00:25 -0400 |
| commit | a651dd81ff72d5155b122ce99e9252d6e714cc1e (patch) | |
| tree | c343b19b77d286ff51356b1d11001a524682ac89 /rust/src/disassembly.rs | |
| parent | 6c6dc60787427789e4bc9e3a20cca304a8210e8d (diff) | |
Rust API: Change instruction_text to use Vec<>
Diffstat (limited to 'rust/src/disassembly.rs')
| -rw-r--r-- | rust/src/disassembly.rs | 30 |
1 files changed, 8 insertions, 22 deletions
diff --git a/rust/src/disassembly.rs b/rust/src/disassembly.rs index ff00e8d0..ab8f91f9 100644 --- a/rust/src/disassembly.rs +++ b/rust/src/disassembly.rs @@ -192,25 +192,6 @@ impl Clone for InstructionTextToken { // } // } -impl CoreArrayProvider for InstructionTextToken { - type Raw = BNInstructionTextToken; - type Context = (); -} - -unsafe impl CoreOwnedArrayProvider for InstructionTextToken { - unsafe fn free(raw: *mut BNInstructionTextToken, count: usize, _context: &()) { - BNFreeInstructionText(raw, count); - } -} - -unsafe impl<'a> CoreArrayWrapper<'a> for InstructionTextToken { - type Wrapped = Guard<'a, InstructionTextToken>; - - unsafe fn wrap_raw(raw: &'a Self::Raw, _context: &'a Self::Context) -> Self::Wrapped { - Guard::new(InstructionTextToken::from_raw(raw), _context) - } -} - pub struct DisassemblyTextLine(pub(crate) BNDisassemblyTextLine); impl DisassemblyTextLine { @@ -235,8 +216,13 @@ impl DisassemblyTextLine { self.0.tagCount } - pub fn tokens(&self) -> ArrayGuard<InstructionTextToken> { - unsafe { ArrayGuard::new(self.0.tokens, self.0.count, ()) } + pub fn tokens(&self) -> Vec<InstructionTextToken> { + unsafe { + Vec::<BNInstructionTextToken>::from_raw_parts(self.0.tokens, self.0.count, self.0.count) + .iter() + .map(|x| InstructionTextToken::from_raw(x)) + .collect() + } } } @@ -267,7 +253,7 @@ impl From<Vec<InstructionTextToken>> for DisassemblyTextLine { tokens.shrink_to_fit(); assert!(tokens.len() == tokens.capacity()); - // let (tokens_pointer, tokens_len, _) = unsafe { tokens.into_raw_parts() }; // Can't use for now...still a rust nighly feature + // TODO: let (tokens_pointer, tokens_len, _) = unsafe { tokens.into_raw_parts() }; // Can't use for now...still a rust nightly feature let tokens_pointer = tokens.as_mut_ptr(); let tokens_len = tokens.len(); mem::forget(tokens); |
