aboutsummaryrefslogtreecommitdiffstats
path: root/components/plugins/macros.rs
diff options
context:
space:
mode:
authorManish Goregaokar <manishsmail@gmail.com>2014-09-20 23:18:34 +0530
committerManish Goregaokar <manishsmail@gmail.com>2014-09-23 17:37:27 +0530
commitfcb25a35ec7586dfa280c4787d673a3525376942 (patch)
treeb9fa11b8c10a58c96e06201cd97f2feda62f4761 /components/plugins/macros.rs
parent6177a3bdcca974d5070b0ecab0973d42963946ec (diff)
downloadservo-fcb25a35ec7586dfa280c4787d673a3525376942.tar.gz
servo-fcb25a35ec7586dfa280c4787d673a3525376942.zip
Rename macros crate to plugins
Diffstat (limited to 'components/plugins/macros.rs')
-rw-r--r--components/plugins/macros.rs20
1 files changed, 20 insertions, 0 deletions
diff --git a/components/plugins/macros.rs b/components/plugins/macros.rs
new file mode 100644
index 00000000000..fde756d6895
--- /dev/null
+++ b/components/plugins/macros.rs
@@ -0,0 +1,20 @@
+//! Exports macros for use in other Servo crates.
+
+#[macro_export]
+macro_rules! bitfield(
+ ($bitfieldname:ident, $getter:ident, $setter:ident, $value:expr) => (
+ impl $bitfieldname {
+ #[inline]
+ pub fn $getter(self) -> bool {
+ let $bitfieldname(this) = self;
+ (this & $value) != 0
+ }
+
+ #[inline]
+ pub fn $setter(&mut self, value: bool) {
+ let $bitfieldname(this) = *self;
+ *self = $bitfieldname((this & !$value) | (if value { $value } else { 0 }))
+ }
+ }
+ )
+)