summaryrefslogtreecommitdiff
path: root/src/codegen
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2017-10-09 19:28:44 -0500
committerGitHub <noreply@github.com>2017-10-09 19:28:44 -0500
commit5dbdadc5cc1d15e23d804b4d0ce80cae90338ef7 (patch)
tree037a4ef445842ae2cd4598accc89e1e4774503ce /src/codegen
parent745d60610ec6979368fc240472f7c04a3e04f282 (diff)
parentc187b9f36001bebf756f9ed4748deeb01759c61b (diff)
Auto merge of #1066 - pepyakin:bitfields-in-unions, r=fitzgen
Bitfields in unions Fixes #744 I think it is WIP for the moment as I didn't run tests locally.
Diffstat (limited to 'src/codegen')
-rw-r--r--src/codegen/mod.rs16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/codegen/mod.rs b/src/codegen/mod.rs
index ea9fec41..94a62b97 100644
--- a/src/codegen/mod.rs
+++ b/src/codegen/mod.rs
@@ -1152,7 +1152,21 @@ impl<'a> FieldCodegen<'a> for BitfieldUnit {
F: Extend<quote::Tokens>,
M: Extend<quote::Tokens>,
{
- let field_ty = helpers::blob(self.layout());
+ let field_ty = if parent.is_union() && !parent.can_be_rust_union(ctx) {
+ let ty = helpers::blob(self.layout());
+ if ctx.options().enable_cxx_namespaces {
+ quote! {
+ root::__BindgenUnionField<#ty>
+ }
+ } else {
+ quote! {
+ __BindgenUnionField<#ty>
+ }
+ }
+ } else {
+ helpers::blob(self.layout())
+ };
+
let unit_field_name = format!("_bitfield_{}", self.nth());
let unit_field_ident = ctx.rust_ident(&unit_field_name);