Skip to content

Split BindgenOptions #2263

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,195 changes: 2,195 additions & 0 deletions src/builder.rs

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions src/codegen/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ pub fn integer_type(
pub fn bitfield_unit(ctx: &BindgenContext, layout: Layout) -> TokenStream {
let mut tokens = quote! {};

if ctx.options().enable_cxx_namespaces {
if ctx.inputs().enable_cxx_namespaces {
tokens.append_all(quote! { root:: });
}

Expand All @@ -138,16 +138,16 @@ pub mod ast_ty {

pub fn c_void(ctx: &BindgenContext) -> TokenStream {
// ctypes_prefix takes precedence
match ctx.options().ctypes_prefix {
match ctx.inputs().ctypes_prefix {
Some(ref prefix) => {
let prefix = TokenStream::from_str(prefix.as_str()).unwrap();
quote! {
#prefix::c_void
}
}
None => {
if ctx.options().use_core &&
ctx.options().rust_features.core_ffi_c_void
if ctx.inputs().use_core &&
ctx.inputs().rust_features().core_ffi_c_void
{
quote! { ::core::ffi::c_void }
} else {
Expand All @@ -159,16 +159,16 @@ pub mod ast_ty {

pub fn raw_type(ctx: &BindgenContext, name: &str) -> TokenStream {
let ident = ctx.rust_ident_raw(name);
match ctx.options().ctypes_prefix {
match ctx.inputs().ctypes_prefix {
Some(ref prefix) => {
let prefix = TokenStream::from_str(prefix.as_str()).unwrap();
quote! {
#prefix::#ident
}
}
None => {
if ctx.options().use_core &&
ctx.options().rust_features().core_ffi_c
if ctx.inputs().use_core &&
ctx.inputs().rust_features().core_ffi_c
{
quote! {
::core::ffi::#ident
Expand All @@ -191,7 +191,7 @@ pub mod ast_ty {
// often?
//
// Also, maybe this one shouldn't be the default?
match (fk, ctx.options().convert_floats) {
match (fk, ctx.inputs().convert_floats) {
(FloatKind::Float, true) => quote! { f32 },
(FloatKind::Double, true) => quote! { f64 },
(FloatKind::Float, false) => raw_type(ctx, "c_float"),
Expand All @@ -218,7 +218,7 @@ pub mod ast_ty {
}
}
(FloatKind::Float128, _) => {
if ctx.options().rust_features.i128_and_u128 {
if ctx.inputs().rust_features().i128_and_u128 {
quote! { u128 }
} else {
quote! { [u64; 2] }
Expand Down
6 changes: 3 additions & 3 deletions src/codegen/impl_debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,11 @@ impl<'a> ImplDebug<'a> for Item {
vec![],
))
} else if len < RUST_DERIVE_IN_ARRAY_LIMIT ||
ctx.options().rust_features().larger_arrays
ctx.inputs().rust_features().larger_arrays
{
// The simple case
debug_print(name, quote! { #name_ident })
} else if ctx.options().use_core {
} else if ctx.inputs().use_core {
// There is no String in core; reducing field visibility to avoid breaking
// no_std setups.
Some((format!("{}: [...]", name), vec![]))
Expand All @@ -204,7 +204,7 @@ impl<'a> ImplDebug<'a> for Item {
}
}
TypeKind::Vector(_, len) => {
if ctx.options().use_core {
if ctx.inputs().use_core {
// There is no format! in core; reducing field visibility to avoid breaking
// no_std setups.
Some((format!("{}(...)", name), vec![]))
Expand Down
4 changes: 2 additions & 2 deletions src/codegen/impl_partialeq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub fn gen_partialeq_impl(
&self._bindgen_opaque_blob[..] == &other._bindgen_opaque_blob[..]
});
} else if comp_info.kind() == CompKind::Union {
assert!(!ctx.options().rust_features().untagged_union);
assert!(!ctx.inputs().rust_features().untagged_union);
tokens.push(quote! {
&self.bindgen_union_field[..] == &other.bindgen_union_field[..]
});
Expand Down Expand Up @@ -114,7 +114,7 @@ fn gen_field(

TypeKind::Array(_, len) => {
if len <= RUST_DERIVE_IN_ARRAY_LIMIT ||
ctx.options().rust_features().larger_arrays
ctx.inputs().rust_features().larger_arrays
{
quote_equals(name_ident)
} else {
Expand Down
Loading