add color-related getters and mutations

This commit is contained in:
little-bobby-tables
2018-01-03 17:04:45 +07:00
parent bc88fa81c2
commit f2b153c987
4 changed files with 98 additions and 6 deletions

View File

@ -83,6 +83,16 @@ macro_rules! wand_common {
}
}
macro_rules! get {
($($get:ident, $c_get:ident, $typ:ty )*) => {
$(
pub fn $get(&self) -> $typ {
unsafe { ::bindings::$c_get(self.wand) }
}
)*
}
}
macro_rules! set_get {
($($get:ident, $set:ident, $c_get:ident, $c_set:ident, $typ:ty )*) => {
$(
@ -227,3 +237,17 @@ macro_rules! color_set_get {
}
}
}
macro_rules! mutations {
($($(#[$attr:meta])* $c_fun:ident => $fun:ident($($arg:ident: $ty:ty),*))*) => {
$(
$(#[$attr])*
pub fn $fun(&self $(, $arg: $ty)*) -> Result<(), &'static str> {
match unsafe { bindings::$c_fun(self.wand $(, $arg)*) } {
bindings::MagickBooleanType::MagickTrue => Ok(()),
_ => Err(concat!(stringify!($c_fun), " invocation failed"))
}
}
)*
}
}