From a06fce06e56b3f0643f34b23c27736432709b48b Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sun, 22 Jan 2017 15:50:48 +0100 Subject: [PATCH] Beautify wrapper helper macros --- libimagruby/src/entry.rs | 14 +++++++------- libimagruby/src/store.rs | 4 ++-- libimagruby/src/storeid.rs | 4 ++-- libimagruby/src/util.rs | 4 ++-- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/libimagruby/src/entry.rs b/libimagruby/src/entry.rs index 0e544d2a..83ae868f 100644 --- a/libimagruby/src/entry.rs +++ b/libimagruby/src/entry.rs @@ -56,8 +56,8 @@ impl FileLockEntryHandle { wrappable_struct!(FileLockEntryHandle, FileLockEntryWrapper, FLE_WRAPPER); class!(RFileLockEntryHandle); -impl_wrap!(FileLockEntryHandle, FLE_WRAPPER); -impl_unwrap!(RFileLockEntryHandle, FileLockEntryHandle, FLE_WRAPPER); +impl_wrap!(FileLockEntryHandle => FLE_WRAPPER); +impl_unwrap!(RFileLockEntryHandle => FileLockEntryHandle => FLE_WRAPPER); impl_verified_object!(RFileLockEntryHandle); /// Helper macro for operating on RUBY_STORE_CACHE object @@ -184,8 +184,8 @@ methods!( wrappable_struct!(EntryHeader, EntryHeaderWrapper, ENTRY_HEADER_WRAPPER); class!(REntryHeader); -impl_wrap!(EntryHeader, ENTRY_HEADER_WRAPPER); -impl_unwrap!(REntryHeader, EntryHeader, ENTRY_HEADER_WRAPPER); +impl_wrap!(EntryHeader => ENTRY_HEADER_WRAPPER); +impl_unwrap!(REntryHeader => EntryHeader => ENTRY_HEADER_WRAPPER); impl_verified_object!(REntryHeader); methods!( @@ -244,12 +244,12 @@ methods!( wrappable_struct!(EntryContent, EntryContentWrapper, ENTRY_CONTENT_WRAPPER); class!(REntryContent); -impl_wrap!(EntryContent, ENTRY_CONTENT_WRAPPER); -impl_unwrap!(REntryContent, EntryContent, ENTRY_CONTENT_WRAPPER); +impl_wrap!(EntryContent => ENTRY_CONTENT_WRAPPER); +impl_unwrap!(REntryContent => EntryContent => ENTRY_CONTENT_WRAPPER); wrappable_struct!(Entry, EntryWrapper, ENTRY_WRAPPER); class!(REntry); -impl_unwrap!(REntry, Entry, ENTRY_WRAPPER); +impl_unwrap!(REntry => Entry => ENTRY_WRAPPER); pub fn setup_filelockentry() -> Class { let mut class = Class::new("RFileLockEntryHandle", None); diff --git a/libimagruby/src/store.rs b/libimagruby/src/store.rs index e1d16a17..4c3a49a2 100644 --- a/libimagruby/src/store.rs +++ b/libimagruby/src/store.rs @@ -36,8 +36,8 @@ use cache::StoreHandle; wrappable_struct!(StoreHandle, StoreWrapper, STORE_WRAPPER); class!(RStoreHandle); -impl_wrap!(StoreHandle, STORE_WRAPPER); -impl_unwrap!(RStoreHandle, StoreHandle, STORE_WRAPPER); +impl_wrap!(StoreHandle => STORE_WRAPPER); +impl_unwrap!(RStoreHandle => StoreHandle => STORE_WRAPPER); impl_verified_object!(RStoreHandle); macro_rules! call_on_store_by_handle { diff --git a/libimagruby/src/storeid.rs b/libimagruby/src/storeid.rs index 330c9808..a8200649 100644 --- a/libimagruby/src/storeid.rs +++ b/libimagruby/src/storeid.rs @@ -27,8 +27,8 @@ use util::Wrap; wrappable_struct!(StoreId, StoreIdWrapper, STOREID_WRAPPER); class!(RStoreId); -impl_wrap!(StoreId, STOREID_WRAPPER); -impl_unwrap!(RStoreId, StoreId, STOREID_WRAPPER); +impl_wrap!(StoreId => STOREID_WRAPPER); +impl_unwrap!(RStoreId => StoreId => STOREID_WRAPPER); impl_verified_object!(RStoreId); diff --git a/libimagruby/src/util.rs b/libimagruby/src/util.rs index e94e1b43..85813f29 100644 --- a/libimagruby/src/util.rs +++ b/libimagruby/src/util.rs @@ -24,7 +24,7 @@ pub trait Wrap { #[macro_export] macro_rules! impl_wrap { - ($target: ty, $wrapper: path) => { + ($target:ty => $wrapper:path) => { impl Wrap for $target { fn wrap(self) -> AnyObject { Class::from_existing(concat!("R", stringify!($target))) @@ -41,7 +41,7 @@ pub trait Unwrap { #[macro_export] macro_rules! impl_unwrap { - ($from: ty, $to: ty, $wrapper: path) => { + ($from:ty => $to:ty => $wrapper:path) => { impl Unwrap for $from { type Target = $to; fn unwrap<'a>(&'a self) -> &'a mut $to {