mrdocs::lua::makeCallable

Wrap a registry-anchored Lua function as a dom::Function.

Synopsis

Declared in <mrdocs/Engines/Lua/registerHelper.hpp>

[[nodiscard]]
dom::Function
makeCallable(
    Context ctx,
    int ref);

Description

The returned function invokes the referenced Lua function, marshalling arguments and result as DOM values, and owns the reference (released when the last copy is destroyed). Used by the extension API's mrdocs.register_transform / register_generator.

Return Value

A dom::Function that calls the anchored Lua function.

NOTE

The return value should not be discarded.

Parameters

NameDescription
ctxThe Lua context whose registry holds the function and that the returned callable keeps alive.
refA luaL_ref(L, LUA_REGISTRYINDEX) reference to a function value in ctx's state.