Skip to main content

LumenFnV2

Type Alias LumenFnV2 

Source
pub type LumenFnV2 = unsafe extern "C" fn(out: *mut LumenValue, argc: c_int, argv: *const LumenValue, user_data: *mut c_void);
Expand description

Out-parameter callback variant of LumenFn (ABI 0.3).

Instead of returning a LumenValue by value - which forces every non-Rust binding to hand-encode the platform’s aggregate-return (SysV sret) convention because LumenValue is larger than the 16-byte register-pair threshold - the callback writes its result through out. Lumen copies *out into a Dynamic before this function returns, exactly as it does for the value LumenFn returns.

out is never null when Lumen invokes the callback, and points to a single writable, uninitialised LumenValue. A callback that wants to return nil may leave it untouched (Lumen zero-initialises the slot to LumenKind::Nil first) or set kind = LUMEN_NIL explicitly. Any pointers the written value carries must stay valid until the callback returns. Register with lumen_app_expose_v2.