pub unsafe extern "C" fn pushcclosure(
state: lua_State,
func: lua_CFunction,
upvalues: i32,
)
Expand description
Pushes a new C closure onto the stack.
When a C function is created, it is possible to associate some values with it, thus creating a C closure (see ยง3.4); these values are then accessible to the function whenever it is called.
To associate values with a C function, first these values should be pushed onto the stack (when there are multiple values, the first value is pushed first).
Then pushcclosure
(lua_pushcclosure
) is called to create and push the C function onto the stack, with the argument n telling how many values should be associated with the function.
pushcclosure
(lua_pushcclosure
) also pops these values from the stack.
The maximum value for upvalues
is 255.