summaryrefslogtreecommitdiff
path: root/src/codegen/mod.rs
diff options
context:
space:
mode:
authorJon Gjengset <jon@thesquareplanet.com>2017-05-10 22:23:15 -0400
committerJon Gjengset <jon@thesquareplanet.com>2017-05-10 22:23:15 -0400
commitdafa5a54ab82c9ffa8ec52e5624c38d5c5ac7084 (patch)
tree579ccbe51e25a45bc0675c300d81d519eb17fe0a /src/codegen/mod.rs
parentd4f83a968ae21b31e761585879863ae00ca5061c (diff)
Add other bitwise ops for bitflag enums
Diffstat (limited to 'src/codegen/mod.rs')
-rw-r--r--src/codegen/mod.rs35
1 files changed, 35 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,