Skip to content

Commit a5d1fe7

Browse files
committed
move input_header_contents to BindgenOPtions
1 parent 5f3d36c commit a5d1fe7

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/lib.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,6 @@ impl Default for CodegenConfig {
225225
pub struct Builder {
226226
parse_callbacks: Option<Box<dyn callbacks::ParseCallbacks>>,
227227
options: BindgenOptions,
228-
// Tuples of unsaved file contents of the form (name, contents).
229-
input_header_contents: Vec<(String, String)>,
230228
}
231229

232230
/// Construct a new [`Builder`](./struct.Builder.html).
@@ -667,7 +665,8 @@ impl Builder {
667665
.to_str()
668666
.expect("Cannot convert current directory name to string")
669667
.to_owned();
670-
self.input_header_contents
668+
self.options
669+
.input_header_contents
671670
.push((absolute_path, contents.into()));
672671
self
673672
}
@@ -1512,11 +1511,9 @@ impl Builder {
15121511
);
15131512

15141513
state.input_unsaved_files.extend(
1515-
self.input_header_contents
1516-
.drain(..)
1517-
.map(|(name, contents)| {
1518-
clang::UnsavedFile::new(&name, &contents)
1519-
}),
1514+
self.options.input_header_contents.drain(..).map(
1515+
|(name, contents)| clang::UnsavedFile::new(&name, &contents),
1516+
),
15201517
);
15211518

15221519
Bindings::generate(state, self.options)
@@ -1554,7 +1551,7 @@ impl Builder {
15541551

15551552
// For each input header content, add a prefix line of `#line 0 "$name"`
15561553
// followed by the contents.
1557-
for &(ref name, ref contents) in &self.input_header_contents {
1554+
for &(ref name, ref contents) in &self.options.input_header_contents {
15581555
is_cpp |= file_is_cpp(name);
15591556

15601557
wrapper_contents.push_str("#line 0 \"");
@@ -1895,6 +1892,9 @@ struct BindgenOptions {
18951892
/// The input header files.
18961893
input_headers: Vec<String>,
18971894

1895+
/// Tuples of unsaved file contents of the form (name, contents).
1896+
input_header_contents: Vec<(String, String)>,
1897+
18981898
/// Which kind of items should we generate? By default, we'll generate all
18991899
/// of them.
19001900
codegen_config: CodegenConfig,
@@ -2077,6 +2077,7 @@ impl Default for BindgenOptions {
20772077
module_lines: Default::default(),
20782078
clang_args: Default::default(),
20792079
input_headers: Default::default(),
2080+
input_header_contents: Default::default(),
20802081
codegen_config: CodegenConfig::all(),
20812082
conservative_inline_namespaces: Default::default(),
20822083
generate_comments: true,

0 commit comments

Comments
 (0)