Beautify wrapper helper macros

This commit is contained in:
Matthias Beyer 2017-01-22 15:50:48 +01:00
parent ce23114f2c
commit a06fce06e5
4 changed files with 13 additions and 13 deletions

View file

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

View file

@ -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 {

View file

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

View file

@ -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 {