22use binaryninjacore_sys:: * ;
33use std:: ffi:: { c_char, c_void} ;
44use std:: fmt:: Debug ;
5+ use std:: path:: PathBuf ;
56use std:: ptr:: NonNull ;
67
78use crate :: platform:: Platform ;
@@ -83,15 +84,15 @@ impl TypeParser for CoreTypeParser {
8384 platform : & Platform ,
8485 existing_types : & TypeContainer ,
8586 options : & [ String ] ,
86- include_directories : & [ String ] ,
87+ include_directories : & [ PathBuf ] ,
8788 ) -> Result < String , Vec < TypeParserError > > {
8889 let source_cstr = BnString :: new ( source) ;
8990 let file_name_cstr = BnString :: new ( file_name) ;
9091 let options: Vec < _ > = options. into_iter ( ) . map ( |o| o. to_cstr ( ) ) . collect ( ) ;
9192 let options_raw: Vec < * const c_char > = options. iter ( ) . map ( |o| o. as_ptr ( ) ) . collect ( ) ;
9293 let include_directories: Vec < _ > = include_directories
9394 . into_iter ( )
94- . map ( |d| d. to_cstr ( ) )
95+ . map ( |d| d. clone ( ) . to_cstr ( ) )
9596 . collect ( ) ;
9697 let include_directories_raw: Vec < * const c_char > =
9798 include_directories. iter ( ) . map ( |d| d. as_ptr ( ) ) . collect ( ) ;
@@ -131,7 +132,7 @@ impl TypeParser for CoreTypeParser {
131132 platform : & Platform ,
132133 existing_types : & TypeContainer ,
133134 options : & [ String ] ,
134- include_directories : & [ String ] ,
135+ include_directories : & [ PathBuf ] ,
135136 auto_type_source : & str ,
136137 ) -> Result < TypeParserResult , Vec < TypeParserError > > {
137138 let source_cstr = BnString :: new ( source) ;
@@ -140,7 +141,7 @@ impl TypeParser for CoreTypeParser {
140141 let options_raw: Vec < * const c_char > = options. iter ( ) . map ( |o| o. as_ptr ( ) ) . collect ( ) ;
141142 let include_directories: Vec < _ > = include_directories
142143 . into_iter ( )
143- . map ( |d| d. to_cstr ( ) )
144+ . map ( |d| d. clone ( ) . to_cstr ( ) )
144145 . collect ( ) ;
145146 let include_directories_raw: Vec < * const c_char > =
146147 include_directories. iter ( ) . map ( |d| d. as_ptr ( ) ) . collect ( ) ;
@@ -238,7 +239,7 @@ pub trait TypeParser {
238239 platform : & Platform ,
239240 existing_types : & TypeContainer ,
240241 options : & [ String ] ,
241- include_dirs : & [ String ] ,
242+ include_dirs : & [ PathBuf ] ,
242243 ) -> Result < String , Vec < TypeParserError > > ;
243244
244245 /// Parse an entire block of source into types, variables, and functions
@@ -257,7 +258,7 @@ pub trait TypeParser {
257258 platform : & Platform ,
258259 existing_types : & TypeContainer ,
259260 options : & [ String ] ,
260- include_dirs : & [ String ] ,
261+ include_dirs : & [ PathBuf ] ,
261262 auto_type_source : & str ,
262263 ) -> Result < TypeParserResult , Vec < TypeParserError > > ;
263264
@@ -556,7 +557,7 @@ unsafe extern "C" fn cb_preprocess_source<T: TypeParser>(
556557 let includes_raw = unsafe { std:: slice:: from_raw_parts ( include_dirs, include_dir_count) } ;
557558 let includes: Vec < _ > = includes_raw
558559 . iter ( )
559- . filter_map ( |& r| raw_to_string ( r) )
560+ . filter_map ( |& r| Some ( PathBuf :: from ( raw_to_string ( r) ? ) ) )
560561 . collect ( ) ;
561562 match ctxt. preprocess_source (
562563 & raw_to_string ( source) . unwrap ( ) ,
@@ -616,7 +617,7 @@ unsafe extern "C" fn cb_parse_types_from_source<T: TypeParser>(
616617 let includes_raw = unsafe { std:: slice:: from_raw_parts ( include_dirs, include_dir_count) } ;
617618 let includes: Vec < _ > = includes_raw
618619 . iter ( )
619- . filter_map ( |& r| raw_to_string ( r) )
620+ . filter_map ( |& r| Some ( PathBuf :: from ( raw_to_string ( r) ? ) ) )
620621 . collect ( ) ;
621622 match ctxt. parse_types_from_source (
622623 & raw_to_string ( source) . unwrap ( ) ,
0 commit comments