Macro detour::static_detour[][src]

macro_rules! static_detour {
    (@parse_attributes ($($input:tt)*) | #[$attribute:meta] $($rest:tt)*) => { ... };
    (@parse_attributes ($($input:tt)*) | $($rest:tt)+) => { ... };
    (@parse_access_modifier ($($input:tt)*) | pub(in $vis:path) static $($rest:tt)*) => { ... };
    (@parse_access_modifier ($($input:tt)*) | pub($vis:tt) static $($rest:tt)*) => { ... };
    (@parse_access_modifier ($($input:tt)*) | pub static $($rest:tt)*) => { ... };
    (@parse_access_modifier ($($input:tt)*) | static $($rest:tt)*) => { ... };
    (@parse_name ($($input:tt)*) | $name:ident : $($rest:tt)*) => { ... };
    (@parse_unsafe ($($input:tt)*) | unsafe $($rest:tt)*) => { ... };
    (@parse_unsafe ($($input:tt)*) | $($rest:tt)*) => { ... };
    (@parse_calling_convention
      ($($input:tt)*) ($($modifier:tt)*) | extern $cc:tt fn $($rest:tt)*) => { ... };
    (@parse_calling_convention
      ($($input:tt)*) ($($modifier:tt)*) | extern fn $($rest:tt)*) => { ... };
    (@parse_calling_convention ($($input:tt)*) ($($modifier:tt)*) | fn $($rest:tt)*) => { ... };
    (@parse_prototype
      ($($input:tt)*) | ($($argument_type:ty),*) -> $return_type:ty ; $($rest:tt)*) => { ... };
    (@parse_prototype ($($input:tt)*) | ($($argument_type:ty),*) $($rest:tt)*) => { ... };
    (@parse_terminator ($($input:tt)*) | ; $($rest:tt)*) => { ... };
    (@parse_entries ($($input:tt)*) | $($rest:tt)+) => { ... };
    (@parse_entries ($($input:tt)*) | ) => { ... };
    (@aggregate ($($attribute:meta)*) ($($visibility:tt)*) ($name:ident)
              ($($modifier:tt)*) ($($argument_type:ty)*) ($return_type:ty)) => { ... };
    (@create_detour ($($argument_name:ident)*) ($($attribute:meta)*) ($($visibility:tt)*)
                  ($name:ident) ($($modifier:tt)*) ($($argument_type:ty)*)
                  ($return_type:ty) ($fn_type:ty)) => { ... };
    (@argument_names ($label:ident) ($($input:tt)*) ($($token:tt)*)) => { ... };
    (@argument_names
      ($label:ident)
      ($($input:tt)*)
      ($hd_name:tt $($tl_name:tt)*)
      ($hd:tt $($tl:tt)*) ($($acc:tt)*)) => { ... };
    (@argument_names ($label:ident) ($($input:tt)*) ($($name:tt)*) () ($($acc:tt)*)) => { ... };
    (@generate $item:item) => { ... };
    ($($t:tt)+) => { ... };
}

A macro for defining static, type-safe detours.

This macro defines one or more StaticDetours.

Syntax

static_detour! {
  [pub] static NAME_1: [unsafe] [extern "cc"] fn([argument]...) [-> ret];
  [pub] static NAME_2: [unsafe] [extern "cc"] fn([argument]...) [-> ret];
  ...
  [pub] static NAME_N: [unsafe] [extern "cc"] fn([argument]...) [-> ret];
}

Example

static_detour! {
  // The simplest detour
  static Foo: fn();

  // An unsafe public detour with a different calling convention
  pub static PubFoo: unsafe extern "C" fn(i32) -> i32;

  // A specific visibility modifier
  pub(crate) static PubSelf: unsafe extern "C" fn();
}