Macro execute

Source
macro_rules! execute {
    ($executor:ident ($($val:expr),* $(,)?)) => { ... };
}
Expand description

Executes a Map or compatible executor with a variable number of arguments.

This macro simplifies passing multiple arguments to the execute method by automatically converting them into a vector of ArgInfo_t using get_arg_info.

§Syntax

execute!(executor(val1, val2, ...));

§Arguments

  • executor - An instance of an object that implements execute(&Vec<ArgInfo_t>) -> bool.
  • val1, val2, … - A variadic list of arguments passed to the executor. Each argument can be:
    • A scalar value (e.g., i32, f32, etc.), which is treated as ArgType::Constant
    • A device memory pointer which is allocated from Context, which is treated as ArgType::DeviceMemory.

§Returns

  • bool - Result of the executor’s execute method.

§Safety

  • This macro assumes any pointer arguments are

§Example

let val: i32 = 42;
let ptr: context.mem_alloc(1024) as *mut i32;
let result = execute!(map(val, ptr));

§Caution

  • This macro does not validate the provided pointers.
  • If a pointer is not allocated from a Context, the execute method will return false.