diff options
| author | Mason Reed <mason@vector35.com> | 2026-02-09 17:01:24 -0800 |
|---|---|---|
| committer | Mason Reed <35282038+emesare@users.noreply.github.com> | 2026-02-23 00:09:44 -0800 |
| commit | e45d8e4324cdc1fb8ed2b60113c1af9e7db499de (patch) | |
| tree | 0f29afc287d5afb76f7a46c05c1e68a9ea6bfaed /rust/src/types | |
| parent | ddf9fb555f97a5a009d9c1ea2aa1a76e6435726e (diff) | |
[Rust] Use `PathBuf` instead of `String` for include directories param in `TypeParser`
Diffstat (limited to 'rust/src/types')
| -rw-r--r-- | rust/src/types/parser.rs | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/rust/src/types/parser.rs b/rust/src/types/parser.rs index 18fe363f..896327f6 100644 --- a/rust/src/types/parser.rs +++ b/rust/src/types/parser.rs @@ -2,6 +2,7 @@ use binaryninjacore_sys::*; use std::ffi::{c_char, c_void}; use std::fmt::Debug; +use std::path::PathBuf; use std::ptr::NonNull; use crate::platform::Platform; @@ -83,7 +84,7 @@ impl TypeParser for CoreTypeParser { platform: &Platform, existing_types: &TypeContainer, options: &[String], - include_directories: &[String], + include_directories: &[PathBuf], ) -> Result<String, Vec<TypeParserError>> { let source_cstr = BnString::new(source); let file_name_cstr = BnString::new(file_name); @@ -91,7 +92,7 @@ impl TypeParser for CoreTypeParser { let options_raw: Vec<*const c_char> = options.iter().map(|o| o.as_ptr()).collect(); let include_directories: Vec<_> = include_directories .into_iter() - .map(|d| d.to_cstr()) + .map(|d| d.clone().to_cstr()) .collect(); let include_directories_raw: Vec<*const c_char> = include_directories.iter().map(|d| d.as_ptr()).collect(); @@ -131,7 +132,7 @@ impl TypeParser for CoreTypeParser { platform: &Platform, existing_types: &TypeContainer, options: &[String], - include_directories: &[String], + include_directories: &[PathBuf], auto_type_source: &str, ) -> Result<TypeParserResult, Vec<TypeParserError>> { let source_cstr = BnString::new(source); @@ -140,7 +141,7 @@ impl TypeParser for CoreTypeParser { let options_raw: Vec<*const c_char> = options.iter().map(|o| o.as_ptr()).collect(); let include_directories: Vec<_> = include_directories .into_iter() - .map(|d| d.to_cstr()) + .map(|d| d.clone().to_cstr()) .collect(); let include_directories_raw: Vec<*const c_char> = include_directories.iter().map(|d| d.as_ptr()).collect(); @@ -238,7 +239,7 @@ pub trait TypeParser { platform: &Platform, existing_types: &TypeContainer, options: &[String], - include_dirs: &[String], + include_dirs: &[PathBuf], ) -> Result<String, Vec<TypeParserError>>; /// Parse an entire block of source into types, variables, and functions @@ -257,7 +258,7 @@ pub trait TypeParser { platform: &Platform, existing_types: &TypeContainer, options: &[String], - include_dirs: &[String], + include_dirs: &[PathBuf], auto_type_source: &str, ) -> Result<TypeParserResult, Vec<TypeParserError>>; @@ -556,7 +557,7 @@ unsafe extern "C" fn cb_preprocess_source<T: TypeParser>( let includes_raw = unsafe { std::slice::from_raw_parts(include_dirs, include_dir_count) }; let includes: Vec<_> = includes_raw .iter() - .filter_map(|&r| raw_to_string(r)) + .filter_map(|&r| Some(PathBuf::from(raw_to_string(r)?))) .collect(); match ctxt.preprocess_source( &raw_to_string(source).unwrap(), @@ -616,7 +617,7 @@ unsafe extern "C" fn cb_parse_types_from_source<T: TypeParser>( let includes_raw = unsafe { std::slice::from_raw_parts(include_dirs, include_dir_count) }; let includes: Vec<_> = includes_raw .iter() - .filter_map(|&r| raw_to_string(r)) + .filter_map(|&r| Some(PathBuf::from(raw_to_string(r)?))) .collect(); match ctxt.parse_types_from_source( &raw_to_string(source).unwrap(), |
