summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/codegen/mod.rs35
-rw-r--r--tests/expectations/tests/bitfield-enum-basic.rs66
2 files changed, 101 insertions, 0 deletions
diff --git a/src/codegen/mod.rs b/src/codegen/mod.rs
index 6f9685b5..550ff90c 100644
--- a/src/codegen/mod.rs
+++ b/src/codegen/mod.rs
@@ -2009,8 +2009,43 @@ impl<'a> EnumBuilder<'a> {
}
)
.unwrap();
+ result.push(impl_);
+
+ let impl_ = quote_item!(ctx.ext_cx(),
+ impl ::$prefix::ops::BitOrAssign for $rust_ty {
+ #[inline]
+ fn bitor_assign(&mut self, rhs: $rust_ty) {
+ self.0 |= rhs.0;
+ }
+ }
+ )
+ .unwrap();
+ result.push(impl_);
+
+ let impl_ = quote_item!(ctx.ext_cx(),
+ impl ::$prefix::ops::BitAnd<$rust_ty> for $rust_ty {
+ type Output = Self;
+
+ #[inline]
+ fn bitand(self, other: Self) -> Self {
+ $rust_ty_name(self.0 & other.0)
+ }
+ }
+ )
+ .unwrap();
+ result.push(impl_);
+ let impl_ = quote_item!(ctx.ext_cx(),
+ impl ::$prefix::ops::BitAndAssign for $rust_ty {
+ #[inline]
+ fn bitand_assign(&mut self, rhs: $rust_ty) {
+ self.0 &= rhs.0;
+ }
+ }
+ )
+ .unwrap();
result.push(impl_);
+
aster
}
EnumBuilder::Consts { aster, .. } => aster,
diff --git a/tests/expectations/tests/bitfield-enum-basic.rs b/tests/expectations/tests/bitfield-enum-basic.rs
index a3eb0d7a..e12574ad 100644
--- a/tests/expectations/tests/bitfield-enum-basic.rs
+++ b/tests/expectations/tests/bitfield-enum-basic.rs
@@ -16,6 +16,22 @@ impl ::std::ops::BitOr<Foo> for Foo {
#[inline]
fn bitor(self, other: Self) -> Self { Foo(self.0 | other.0) }
}
+impl ::std::ops::BitOrAssign for Foo {
+ #[inline]
+ fn bitor_assign(&mut self, rhs: Foo) { self.0 |= rhs.0; }
+}
+impl ::std::ops::BitAnd<Foo> for Foo {
+ type
+ Output
+ =
+ Self;
+ #[inline]
+ fn bitand(self, other: Self) -> Self { Foo(self.0 & other.0) }
+}
+impl ::std::ops::BitAndAssign for Foo {
+ #[inline]
+ fn bitand_assign(&mut self, rhs: Foo) { self.0 &= rhs.0; }
+}
#[repr(C)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub struct Foo(pub ::std::os::raw::c_int);
@@ -31,6 +47,22 @@ impl ::std::ops::BitOr<Buz> for Buz {
#[inline]
fn bitor(self, other: Self) -> Self { Buz(self.0 | other.0) }
}
+impl ::std::ops::BitOrAssign for Buz {
+ #[inline]
+ fn bitor_assign(&mut self, rhs: Buz) { self.0 |= rhs.0; }
+}
+impl ::std::ops::BitAnd<Buz> for Buz {
+ type
+ Output
+ =
+ Self;
+ #[inline]
+ fn bitand(self, other: Self) -> Self { Buz(self.0 & other.0) }
+}
+impl ::std::ops::BitAndAssign for Buz {
+ #[inline]
+ fn bitand_assign(&mut self, rhs: Buz) { self.0 &= rhs.0; }
+}
#[repr(C)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub struct Buz(pub ::std::os::raw::c_schar);
@@ -44,6 +76,22 @@ impl ::std::ops::BitOr<_bindgen_ty_1> for _bindgen_ty_1 {
#[inline]
fn bitor(self, other: Self) -> Self { _bindgen_ty_1(self.0 | other.0) }
}
+impl ::std::ops::BitOrAssign for _bindgen_ty_1 {
+ #[inline]
+ fn bitor_assign(&mut self, rhs: _bindgen_ty_1) { self.0 |= rhs.0; }
+}
+impl ::std::ops::BitAnd<_bindgen_ty_1> for _bindgen_ty_1 {
+ type
+ Output
+ =
+ Self;
+ #[inline]
+ fn bitand(self, other: Self) -> Self { _bindgen_ty_1(self.0 & other.0) }
+}
+impl ::std::ops::BitAndAssign for _bindgen_ty_1 {
+ #[inline]
+ fn bitand_assign(&mut self, rhs: _bindgen_ty_1) { self.0 &= rhs.0; }
+}
#[repr(C)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub struct _bindgen_ty_1(pub ::std::os::raw::c_uint);
@@ -64,6 +112,24 @@ impl ::std::ops::BitOr<Dummy__bindgen_ty_1> for Dummy__bindgen_ty_1 {
Dummy__bindgen_ty_1(self.0 | other.0)
}
}
+impl ::std::ops::BitOrAssign for Dummy__bindgen_ty_1 {
+ #[inline]
+ fn bitor_assign(&mut self, rhs: Dummy__bindgen_ty_1) { self.0 |= rhs.0; }
+}
+impl ::std::ops::BitAnd<Dummy__bindgen_ty_1> for Dummy__bindgen_ty_1 {
+ type
+ Output
+ =
+ Self;
+ #[inline]
+ fn bitand(self, other: Self) -> Self {
+ Dummy__bindgen_ty_1(self.0 & other.0)
+ }
+}
+impl ::std::ops::BitAndAssign for Dummy__bindgen_ty_1 {
+ #[inline]
+ fn bitand_assign(&mut self, rhs: Dummy__bindgen_ty_1) { self.0 &= rhs.0; }
+}
#[repr(C)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub struct Dummy__bindgen_ty_1(pub ::std::os::raw::c_uint);