Rename macros crate to plugins

This commit is contained in:
Manish Goregaokar 2014-09-20 23:18:34 +05:30
parent 6177a3bdcc
commit fcb25a35ec
13 changed files with 113 additions and 74 deletions

View file

@ -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 }))
}
}
)
)