Skip to main content

intuicio_function

Attribute Macro intuicio_function 

Source
#[intuicio_function]
Expand description

Wraps a free function so scripts can call it.

Generates a module named after the function, holding the fn(&mut Context, &Registry) shim, define_signature and define_function. The original function is emitted unchanged beside it.

#[intuicio_function(module_name = "lib")]
fn add(a: i32, b: i32) -> i32 {
    a + b
}

registry.add_function(add::define_function(&registry));

§Attributes

AttributeEffect
name = "..."registered name, defaults to the Rust name
module_name = "..."module the function is registered under
type_path = "..."associates the function with that type
use_registrythe argument named registry receives &Registry instead of a stack value
use_contextthe argument named context receives &mut Context instead of a stack value
transformer = "..."routes arguments and results through a ValueTransformer
dependency = "..."argument a returned reference borrows from
meta = "..."Meta source attached to the function
args_meta(a = "...")Meta source attached to argument a
debugprints the generated code during compilation

§Panics

Expanding panics on a self argument, or on an argument whose pattern is not a plain identifier. The generated define_signature panics at run time when a type from the signature is missing from the registry.