Skip to content

Commit 0ffcdf5

Browse files
committed
move input_header_contents to BindgenOPtions
1 parent d4ff4b5 commit 0ffcdf5

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/lib.rs

+10-9
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).
@@ -676,7 +674,8 @@ impl Builder {
676674
.to_str()
677675
.expect("Cannot convert current directory name to string")
678676
.to_owned();
679-
self.input_header_contents
677+
self.options
678+
.input_header_contents
680679
.push((absolute_path, contents.into()));
681680
self
682681
}
@@ -1533,11 +1532,9 @@ impl Builder {
15331532
);
15341533

15351534
state.input_unsaved_files.extend(
1536-
self.input_header_contents
1537-
.drain(..)
1538-
.map(|(name, contents)| {
1539-
clang::UnsavedFile::new(&name, &contents)
1540-
}),
1535+
self.options.input_header_contents.drain(..).map(
1536+
|(name, contents)| clang::UnsavedFile::new(&name, &contents),
1537+
),
15411538
);
15421539

15431540
Bindings::generate(state, self.options)
@@ -1575,7 +1572,7 @@ impl Builder {
15751572

15761573
// For each input header content, add a prefix line of `#line 0 "$name"`
15771574
// followed by the contents.
1578-
for &(ref name, ref contents) in &self.input_header_contents {
1575+
for &(ref name, ref contents) in &self.options.input_header_contents {
15791576
is_cpp |= file_is_cpp(name);
15801577

15811578
wrapper_contents.push_str("#line 0 \"");
@@ -1919,6 +1916,9 @@ struct BindgenOptions {
19191916
/// The input header files.
19201917
input_headers: Vec<String>,
19211918

1919+
/// Tuples of unsaved file contents of the form (name, contents).
1920+
input_header_contents: Vec<(String, String)>,
1921+
19221922
/// Which kind of items should we generate? By default, we'll generate all
19231923
/// of them.
19241924
codegen_config: CodegenConfig,
@@ -2102,6 +2102,7 @@ impl Default for BindgenOptions {
21022102
module_lines: Default::default(),
21032103
clang_args: Default::default(),
21042104
input_headers: Default::default(),
2105+
input_header_contents: Default::default(),
21052106
codegen_config: CodegenConfig::all(),
21062107
conservative_inline_namespaces: Default::default(),
21072108
generate_comments: true,

0 commit comments

Comments
 (0)