11use std:: { env, fs, io, path:: Path , process} ;
22
3+ use bindgen:: callbacks:: ParseCallbacks ;
34use quote:: ToTokens ;
45use syn:: visit_mut:: VisitMut ;
56
@@ -79,6 +80,27 @@ pub fn generate(
7980 }
8081}
8182
83+ #[ derive( Debug ) ]
84+ struct Callbacks ;
85+
86+ impl ParseCallbacks for Callbacks {
87+ fn process_comment ( & self , comment : & str ) -> Option < String > {
88+ let comment = comment. replace ( "@param[int]" , "@param[in]" ) ;
89+ let comment = comment. replace ( "[inout]" , "[in,out]" ) ;
90+ let comment = comment. replace ( "[in]\t " , "[in] \t " ) ;
91+ let comment = comment. replace ( "[out]\t " , "[out] \t " ) ;
92+
93+ let comment = doxygen_rs:: transform ( & comment) ;
94+
95+ let comment = comment. strip_prefix ( "!<" ) . unwrap_or ( & comment) ;
96+ let comment = comment. strip_prefix ( '!' ) . unwrap_or ( & comment) ;
97+ let comment = comment. strip_prefix ( '<' ) . unwrap_or ( & comment) ;
98+ let comment = comment. trim ( ) ;
99+
100+ Some ( comment. to_string ( ) )
101+ }
102+ }
103+
82104fn generate_preprocessed_bindings (
83105 headers : & Path ,
84106 vita_headers_include : & Path ,
@@ -92,7 +114,8 @@ fn generate_preprocessed_bindings(
92114 . clang_args ( & [ "-target" , "armv7a-none-eabihf" ] )
93115 . use_core ( )
94116 . ctypes_prefix ( "crate::ctypes" )
95- . generate_comments ( false )
117+ . generate_comments ( true )
118+ . parse_callbacks ( Box :: new ( Callbacks ) )
96119 . prepend_enum_name ( false )
97120 . layout_tests ( false )
98121 . formatter ( bindgen:: Formatter :: None ) ;
0 commit comments