2018-10-16 17:01:47 +02:00
|
|
|
/// This macro helps to get a function for an instance easily
|
|
|
|
/// let func: fn(i32) -> i32 = get_instance_function!(instance, func_index);
|
|
|
|
#[macro_export]
|
|
|
|
macro_rules! get_instance_function {
|
2018-10-17 11:22:45 +02:00
|
|
|
($instance:expr, $func_index:expr) => {{
|
|
|
|
use std::mem;
|
|
|
|
let func_addr = $instance.get_function_pointer($func_index);
|
|
|
|
unsafe { mem::transmute(func_addr) }
|
|
|
|
}};
|
2018-10-16 17:01:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// #[cfg(feature = "debug")]
|
|
|
|
#[macro_export]
|
|
|
|
macro_rules! debug {
|
|
|
|
($fmt:expr) => (println!(concat!("Wasmer::", $fmt)));
|
|
|
|
($fmt:expr, $($arg:tt)*) => (println!(concat!("Wasmer::", $fmt, "\n"), $($arg)*));
|
|
|
|
}
|