aboutsummaryrefslogtreecommitdiffstats
path: root/components/plugins/macros.rs
diff options
context:
space:
mode:
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 }))
+ }
+ }
+ )
+)