diff options
| author | Glenn Smith <glenn@vector35.com> | 2022-07-21 15:24:16 -0400 |
|---|---|---|
| committer | Glenn Smith <glenn@vector35.com> | 2022-09-29 21:02:22 -0400 |
| commit | d552ae9beae6404c13548b98ec7a7ec4e6b3dd90 (patch) | |
| tree | 00a2696b2a3a33b1ac5bb058801fdea9f1a38c03 /rust/src/platform.rs | |
| parent | 2e18783a2f6e29c225d177e8a0fb866a9c9d85df (diff) | |
[Rust API] Better name for this trait fn, more CC support
Diffstat (limited to 'rust/src/platform.rs')
| -rw-r--r-- | rust/src/platform.rs | 31 |
1 files changed, 22 insertions, 9 deletions
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<S: BnStrCompatible>(name: S) -> Option<Ref<Self>> { - 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<S: BnStrCompatible>(name: S) -> Array<Platform> { - 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<Platform> { - 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<A: Architecture, S: BnStrCompatible>(arch: &A, name: S) -> Ref<Self> { - 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<S: BnStrCompatible>(&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<CallingConvention<CoreArchitecture>> { + unsafe { + let mut count = 0; + let handles = BNGetPlatformCallingConventions(self.handle, &mut count); + + Array::new(handles, count, self.arch()) + } + } + pub fn types(&self) -> Array<QualifiedNameAndType> { 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 _); } |
