pub type CFunction = unsafe extern "C" fn(l: *mut State) -> c_int;Expand description
C function registered with Lua.
Also known as lua_CFunction.
This is still called a C function, because Rust has to speak the language of C to be able to use this.
C functions accept a pointer to a Lua state that they can manipulate. If a C function pushes some values onto the Lua stack that it wishes to return, then it must return the number of values it wants to return.
§Safety
When a C function is called from Lua, l always points to a valid Lua state.
However, it is not guaranteed that the garbage collector is off.
If code requires that the garbage collector is off (i.e. if pointers from
Lua are used after a call to
Thread::run_managed_no_gc), then
garbage collection must be manually stopped.