@@ -225,8 +225,6 @@ impl Default for CodegenConfig {
225
225
#[ derive( Debug , Default ) ]
226
226
pub struct Builder {
227
227
options : BindgenOptions ,
228
- // Tuples of unsaved file contents of the form (name, contents).
229
- input_header_contents : Vec < ( String , String ) > ,
230
228
}
231
229
232
230
/// Construct a new [`Builder`](./struct.Builder.html).
@@ -690,7 +688,8 @@ impl Builder {
690
688
. to_str ( )
691
689
. expect ( "Cannot convert current directory name to string" )
692
690
. to_owned ( ) ;
693
- self . input_header_contents
691
+ self . options
692
+ . input_header_contents
694
693
. push ( ( absolute_path, contents. into ( ) ) ) ;
695
694
self
696
695
}
@@ -1572,11 +1571,11 @@ impl Builder {
1572
1571
. flat_map ( |header| [ "-include" . into ( ) , header. to_string ( ) ] ) ,
1573
1572
) ;
1574
1573
1575
- let input_unsaved_files = self
1576
- . input_header_contents
1577
- . into_iter ( )
1578
- . map ( |( name, contents) | clang:: UnsavedFile :: new ( & name, & contents) )
1579
- . collect :: < Vec < _ > > ( ) ;
1574
+ let input_unsaved_files =
1575
+ std :: mem :: take ( & mut self . options . input_header_contents )
1576
+ . into_iter ( )
1577
+ . map ( |( name, contents) | clang:: UnsavedFile :: new ( name, contents) )
1578
+ . collect :: < Vec < _ > > ( ) ;
1580
1579
1581
1580
Bindings :: generate ( self . options , input_unsaved_files)
1582
1581
}
@@ -1613,7 +1612,7 @@ impl Builder {
1613
1612
1614
1613
// For each input header content, add a prefix line of `#line 0 "$name"`
1615
1614
// followed by the contents.
1616
- for & ( ref name, ref contents) in & self . input_header_contents {
1615
+ for & ( ref name, ref contents) in & self . options . input_header_contents {
1617
1616
is_cpp |= file_is_cpp ( name) ;
1618
1617
1619
1618
wrapper_contents. push_str ( "#line 0 \" " ) ;
@@ -1970,6 +1969,9 @@ struct BindgenOptions {
1970
1969
/// The input header files.
1971
1970
input_headers : Vec < String > ,
1972
1971
1972
+ /// Tuples of unsaved file contents of the form (name, contents).
1973
+ input_header_contents : Vec < ( String , String ) > ,
1974
+
1973
1975
/// A user-provided visitor to allow customizing different kinds of
1974
1976
/// situations.
1975
1977
parse_callbacks : Option < Rc < dyn callbacks:: ParseCallbacks > > ,
@@ -2219,6 +2221,7 @@ impl Default for BindgenOptions {
2219
2221
module_lines : HashMap :: default ( ) ,
2220
2222
clang_args : vec ! [ ] ,
2221
2223
input_headers : vec ! [ ] ,
2224
+ input_header_contents : Default :: default ( ) ,
2222
2225
parse_callbacks : None ,
2223
2226
codegen_config : CodegenConfig :: all ( ) ,
2224
2227
conservative_inline_namespaces : false ,
0 commit comments