Skip to content

Commit 7386c11

Browse files
committed
Provides all prefix tokens in a vector
1 parent 1da5221 commit 7386c11

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

rust/src/data_renderer.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1+
use binaryninjacore_sys::*;
12
use core::ffi;
23
use ffi::c_void;
34
use std::ptr::NonNull;
4-
use log::debug;
5-
use binaryninjacore_sys::*;
65

76
use crate::binary_view::BinaryView;
87
use crate::disassembly::{DisassemblyTextLine, InstructionTextToken};
@@ -42,8 +41,7 @@ pub trait CustomDataRenderer: Sized + Sync + Send + 'static {
4241
view: &BinaryView,
4342
addr: u64,
4443
type_: &Type,
45-
prefix: &InstructionTextToken,
46-
prefix_count: usize,
44+
prefix: Vec<InstructionTextToken>,
4745
width: usize,
4846
types_ctx: &[TypeContext],
4947
language: &str,
@@ -93,12 +91,14 @@ trait CustomDataRendererFFI: CustomDataRenderer {
9391
let ctxt = ctxt as *mut Self;
9492
// SAFETY BNTypeContext and TypeContext are transparent
9593
let types = core::slice::from_raw_parts(type_ctx as *mut TypeContext, ctx_count);
94+
let prefix = core::slice::from_raw_parts(prefix, prefix_count)
95+
.iter().map(InstructionTextToken::from_raw)
96+
.collect::<Vec<_>>();
9697
let result = (*ctxt).lines_for_data(
9798
&BinaryView::from_raw(view),
9899
addr,
99100
&Type::from_raw(type_),
100-
&InstructionTextToken::from_raw(&*prefix),
101-
prefix_count,
101+
prefix,
102102
width,
103103
types,
104104
ffi::CStr::from_ptr(language).to_str().unwrap(),

rust/tests/data_renderer.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ fn test_data_renderer_basic() {
2828
_view: &BinaryView,
2929
addr: u64,
3030
type_: &Type,
31-
_prefix: &InstructionTextToken,
32-
_prefix_count: usize,
31+
_prefix: Vec<InstructionTextToken>,
3332
width: usize,
3433
_types_ctx: &[TypeContext],
3534
_language: &str,

0 commit comments

Comments
 (0)