Skip to content

Commit 18ff770

Browse files
committed
rename BindgenOptions to BindgenInputs and add BindgenOptions
1 parent 00e30ef commit 18ff770

17 files changed

+2343
-2330
lines changed

src/builder.rs

+2,122
Large diffs are not rendered by default.

src/codegen/helpers.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ pub fn integer_type(
116116
pub fn bitfield_unit(ctx: &BindgenContext, layout: Layout) -> TokenStream {
117117
let mut tokens = quote! {};
118118

119-
if ctx.options().enable_cxx_namespaces {
119+
if ctx.inputs().enable_cxx_namespaces {
120120
tokens.append_all(quote! { root:: });
121121
}
122122

@@ -138,16 +138,16 @@ pub mod ast_ty {
138138

139139
pub fn c_void(ctx: &BindgenContext) -> TokenStream {
140140
// ctypes_prefix takes precedence
141-
match ctx.options().ctypes_prefix {
141+
match ctx.inputs().ctypes_prefix {
142142
Some(ref prefix) => {
143143
let prefix = TokenStream::from_str(prefix.as_str()).unwrap();
144144
quote! {
145145
#prefix::c_void
146146
}
147147
}
148148
None => {
149-
if ctx.options().use_core &&
150-
ctx.options().rust_features.core_ffi_c_void
149+
if ctx.inputs().use_core &&
150+
ctx.inputs().rust_features().core_ffi_c_void
151151
{
152152
quote! { ::core::ffi::c_void }
153153
} else {
@@ -159,7 +159,7 @@ pub mod ast_ty {
159159

160160
pub fn raw_type(ctx: &BindgenContext, name: &str) -> TokenStream {
161161
let ident = ctx.rust_ident_raw(name);
162-
match ctx.options().ctypes_prefix {
162+
match ctx.inputs().ctypes_prefix {
163163
Some(ref prefix) => {
164164
let prefix = TokenStream::from_str(prefix.as_str()).unwrap();
165165
quote! {
@@ -181,7 +181,7 @@ pub mod ast_ty {
181181
// often?
182182
//
183183
// Also, maybe this one shouldn't be the default?
184-
match (fk, ctx.options().convert_floats) {
184+
match (fk, ctx.inputs().convert_floats) {
185185
(FloatKind::Float, true) => quote! { f32 },
186186
(FloatKind::Double, true) => quote! { f64 },
187187
(FloatKind::Float, false) => raw_type(ctx, "c_float"),
@@ -208,7 +208,7 @@ pub mod ast_ty {
208208
}
209209
}
210210
(FloatKind::Float128, _) => {
211-
if ctx.options().rust_features.i128_and_u128 {
211+
if ctx.inputs().rust_features().i128_and_u128 {
212212
quote! { u128 }
213213
} else {
214214
quote! { [u64; 2] }

src/codegen/impl_debug.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -181,11 +181,11 @@ impl<'a> ImplDebug<'a> for Item {
181181
vec![],
182182
))
183183
} else if len < RUST_DERIVE_IN_ARRAY_LIMIT ||
184-
ctx.options().rust_features().larger_arrays
184+
ctx.inputs().rust_features().larger_arrays
185185
{
186186
// The simple case
187187
debug_print(name, quote! { #name_ident })
188-
} else if ctx.options().use_core {
188+
} else if ctx.inputs().use_core {
189189
// There is no String in core; reducing field visibility to avoid breaking
190190
// no_std setups.
191191
Some((format!("{}: [...]", name), vec![]))
@@ -204,7 +204,7 @@ impl<'a> ImplDebug<'a> for Item {
204204
}
205205
}
206206
TypeKind::Vector(_, len) => {
207-
if ctx.options().use_core {
207+
if ctx.inputs().use_core {
208208
// There is no format! in core; reducing field visibility to avoid breaking
209209
// no_std setups.
210210
Some((format!("{}(...)", name), vec![]))

src/codegen/impl_partialeq.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pub fn gen_partialeq_impl(
1818
&self._bindgen_opaque_blob[..] == &other._bindgen_opaque_blob[..]
1919
});
2020
} else if comp_info.kind() == CompKind::Union {
21-
assert!(!ctx.options().rust_features().untagged_union);
21+
assert!(!ctx.inputs().rust_features().untagged_union);
2222
tokens.push(quote! {
2323
&self.bindgen_union_field[..] == &other.bindgen_union_field[..]
2424
});
@@ -114,7 +114,7 @@ fn gen_field(
114114

115115
TypeKind::Array(_, len) => {
116116
if len <= RUST_DERIVE_IN_ARRAY_LIMIT ||
117-
ctx.options().rust_features().larger_arrays
117+
ctx.inputs().rust_features().larger_arrays
118118
{
119119
quote_equals(name_ident)
120120
} else {

0 commit comments

Comments
 (0)