hook_helper

Macro hook_helper 

Source
macro_rules! hook_helper {
    (
        $(
            $(#[$meta: meta])*
            $(-($($r:tt)*)[$class1: ident $($sel1:tt)*])?
            $(+($($r2:tt)*)[$class2: ident $($sel2:tt)*])?
            unsafe extern "C" fn $name: ident ($($arg:ident: $ty: ty),* $(,)?) $(->$ret:ty)? $body: block
        )*
    ) => { ... };
}
Expand description

Example:

hook_helper! {
    // hook a class method
    +(void)[ClassA hello]
    unsafe extern "C" fn(this: &NSObject, _cmd: Sel) {
        // call the original implementation by the `hook_*` selector`
       let _:() = msg_send![this, hook_hello];
    }

    // hokk a instance method
    -(void)[ClassB world:]
    unsafe extern "C" fn(this: &NSObject, _cmd: Sel, s: &NSString) {
        // call the original implementation by the `hook_*` selector`
        let _:() = msg_send![this, hook_world:s];
    }
}