From d552ae9beae6404c13548b98ec7a7ec4e6b3dd90 Mon Sep 17 00:00:00 2001 From: Glenn Smith Date: Thu, 21 Jul 2022 15:24:16 -0400 Subject: [Rust API] Better name for this trait fn, more CC support --- rust/src/platform.rs | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) (limited to 'rust/src/platform.rs') diff --git a/rust/src/platform.rs b/rust/src/platform.rs index 6bdf8c9f..3f33a056 100644 --- a/rust/src/platform.rs +++ b/rust/src/platform.rs @@ -73,7 +73,7 @@ impl Platform { } pub fn by_name(name: S) -> Option> { - let raw_name = name.as_bytes_with_nul(); + let raw_name = name.into_bytes_with_nul(); unsafe { let res = BNGetPlatformByName(raw_name.as_ref().as_ptr() as *mut _); @@ -104,7 +104,7 @@ impl Platform { } pub fn list_by_os(name: S) -> Array { - let raw_name = name.as_bytes_with_nul(); + let raw_name = name.into_bytes_with_nul(); unsafe { let mut count = 0; @@ -118,7 +118,7 @@ impl Platform { name: S, arch: &CoreArchitecture, ) -> Array { - let raw_name = name.as_bytes_with_nul(); + let raw_name = name.into_bytes_with_nul(); unsafe { let mut count = 0; @@ -142,7 +142,7 @@ impl Platform { } pub fn new(arch: &A, name: S) -> Ref { - let name = name.as_bytes_with_nul(); + let name = name.into_bytes_with_nul(); unsafe { let handle = BNCreatePlatform(arch.as_ref().0, name.as_ref().as_ptr() as *mut _); @@ -164,7 +164,7 @@ impl Platform { } pub fn register_os(&self, os: S) { - let os = os.as_bytes_with_nul(); + let os = os.into_bytes_with_nul(); unsafe { BNRegisterPlatform(os.as_ref().as_ptr() as *mut _, self.handle); @@ -206,6 +206,15 @@ impl Platform { BNSetPlatformSystemCallConvention ); + pub fn calling_conventions(&self) -> Array> { + unsafe { + let mut count = 0; + let handles = BNGetPlatformCallingConventions(self.handle, &mut count); + + Array::new(handles, count, self.arch()) + } + } + pub fn types(&self) -> Array { unsafe { let mut count = 0; @@ -274,14 +283,18 @@ impl TypeParser for Platform { let mut error_string: *mut raw::c_char = ptr::null_mut(); - let src = source.as_bytes_with_nul(); - let filename = filename.as_bytes_with_nul(); - let auto_type_source = auto_type_source.as_bytes_with_nul(); + let src = source.into_bytes_with_nul(); + let filename = filename.into_bytes_with_nul(); + let auto_type_source = auto_type_source.into_bytes_with_nul(); let mut include_dirs = vec![]; for dir in include_directories.iter() { - let d = dir.as_ref().to_string_lossy().to_string().as_bytes_with_nul(); + let d = dir + .as_ref() + .to_string_lossy() + .to_string() + .into_bytes_with_nul(); include_dirs.push(d.as_ptr() as _); } -- cgit v1.3.1