Macro red4ext_rs::call
source · macro_rules! call { ($cls_name:literal :: $fn_name:literal ($( $args:expr ),*) -> $rett:ty) => { ... }; ($fn_name:literal ($( $args:expr ),*) -> $rett:ty) => { ... }; ($this:expr, $fn_name:literal ($( $args:expr ),*) -> $rett:ty) => { ... }; }
Expand description
A macro for conveniently calling functions and methods. If you’re calling a method, the first argument should be the instance of the class. The next argument should be a full function name, which might have to include mangled names of the parameter types.
§Example
use red4ext_rs::{call, types::{IScriptable, Ref, CName}};
fn method_example(inst: Ref<IScriptable>) -> CName {
call!(inst, "GetClassName" () -> CName).unwrap()
}
fn global_example() -> i32 {
call!("OperatorAdd;Int32Int32;Int32" (1i32, 2i32) -> i32).unwrap()
}
fn static_example() -> f32 {
call!("PlayerPuppet"::"GetCriticalHealthThreshold;" () -> f32).unwrap()
}