@@ -101,6 +101,13 @@ enum StructModification {
101101 //You can specify no prefix..
102102 Prefix { prefix : & ' static str , style : Style } ,
103103}
104+ fn rename_structs ( s : String , pairs : & [ ( & str , & str ) ] , style : Style ) -> String {
105+ let mut temp = s;
106+ for ( old_name, new_name) in pairs {
107+ temp = rename_word_excluding_enum_members ( temp, old_name, new_name, style) ;
108+ }
109+ temp
110+ }
104111
105112fn filter_structs ( s : String , names : & [ & str ] , how : StructModification ) -> String {
106113 let mut temp = s;
@@ -154,7 +161,8 @@ fn filter_enums<'a, 'b>(s: String, names: &'a [&'a str], how: EnumModification)
154161}
155162
156163static ENUM_NAMES : [ & str ; 4 ] = [ "IoMode" , "Direction" , "Lifetime" , "CleanupWith" ] ;
157- static STRUCT_NAMES : [ & str ; 4 ] = [ "Job" , "JobIo" , "Context" , "JsonResponse" ] ;
164+ static STRUCT_NAMES : [ & str ; 5 ] = [ "Job" , "JobIo" , "Context" , "ThreadSafeContext" , "JsonResponse" ] ;
165+ static RENAME_STRUCTS : [ ( & str , & str ) ; 1 ] = [ ( "ThreadSafeContext" , "Context" ) ] ;
158166
159167#[ derive( Copy , Clone , PartialEq , Debug ) ]
160168enum Target {
@@ -267,7 +275,13 @@ fn generate(target: Target) -> String {
267275
268276 let builder = cbindgen:: Builder :: new ( ) . with_config ( config) . with_crate ( crate_dir) ;
269277 let s = generate_to_string ( builder) ;
270- let temp = filter_enums ( filter_structs ( s, & STRUCT_NAMES , structs) , & ENUM_NAMES , enums) ;
278+ // let rename_style = match structs{
279+ // StructModification::Prefix { style , ..} => style,
280+ // _ => Style::Snake
281+ // };
282+ let renamed = rename_structs ( s, & RENAME_STRUCTS , Style :: Unchanged ) ;
283+ let temp =
284+ filter_enums ( filter_structs ( renamed, & STRUCT_NAMES , structs) , & ENUM_NAMES , enums) ;
271285 if no_preprocessor_directives {
272286 strip_preprocessor_directives ( & temp)
273287 } else {
0 commit comments