mirror of
https://github.com/fluencelabs/wasmer
synced 2025-04-11 11:56:04 +00:00
22 lines
655 B
Rust
22 lines
655 B
Rust
|
/// 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 {
|
||
|
($instance:expr, $func_index:expr) => {
|
||
|
{
|
||
|
use std::mem;
|
||
|
let func_addr = $instance.get_function_pointer($func_index);
|
||
|
unsafe {
|
||
|
mem::transmute(func_addr)
|
||
|
}
|
||
|
}
|
||
|
};
|
||
|
}
|
||
|
|
||
|
// #[cfg(feature = "debug")]
|
||
|
#[macro_export]
|
||
|
macro_rules! debug {
|
||
|
($fmt:expr) => (println!(concat!("Wasmer::", $fmt)));
|
||
|
($fmt:expr, $($arg:tt)*) => (println!(concat!("Wasmer::", $fmt, "\n"), $($arg)*));
|
||
|
}
|