Skip to content

Commit

Permalink
Rust: change signatures of define_{auto,user}_data_var
Browse files Browse the repository at this point in the history
  • Loading branch information
mkrasnitski authored and ElykDeer committed May 15, 2024
1 parent 3037596 commit be6936a
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions rust/src/binaryview.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ use crate::segment::{Segment, SegmentBuilder};
use crate::settings::Settings;
use crate::symbol::{Symbol, SymbolType};
use crate::tags::{Tag, TagType};
use crate::types::{DataVariable, NamedTypeReference, QualifiedName, QualifiedNameAndType, Type};
use crate::types::{
Conf, DataVariable, NamedTypeReference, QualifiedName, QualifiedNameAndType, Type,
};
use crate::Endianness;

use crate::rc::*;
Expand Down Expand Up @@ -550,24 +552,16 @@ pub trait BinaryViewExt: BinaryViewBase {
}
}

fn define_auto_data_var(&self, dv: &DataVariable) {
fn define_auto_data_var<'a, T: Into<Conf<&'a Type>>>(&self, addr: u64, ty: T) {
unsafe {
BNDefineDataVariable(
self.as_ref().handle,
dv.address(),
&mut dv.type_with_confidence().into(),
);
BNDefineDataVariable(self.as_ref().handle, addr, &mut ty.into().into());
}
}

/// You likely would also like to call [`Self::define_user_symbol`] to bind this data variable with a name
fn define_user_data_var(&self, dv: &DataVariable) {
fn define_user_data_var<'a, T: Into<Conf<&'a Type>>>(&self, addr: u64, ty: T) {
unsafe {
BNDefineUserDataVariable(
self.as_ref().handle,
dv.address(),
&mut dv.type_with_confidence().into(),
);
BNDefineUserDataVariable(self.as_ref().handle, addr, &mut ty.into().into());
}
}

Expand Down

0 comments on commit be6936a

Please sign in to comment.