typedef const char * (*lua_Reader) (lua_State *L,
void *data,
size_t *size);
<
The reader function used by `lua_load` (see |lua_load()|). Every
time it needs another piece of the chunk, `lua_load` calls the reader,
passing along its `data` parameter. The reader must return a pointer
to a block of memory with a new piece of the chunk and set `size` to
the block size. The block must exist until the reader function is
called again. To signal the end of the chunk, the reader must return
`NULL`. The reader function may return pieces of any size greater than
zero.
lua_register *lua_register()*
>c
void lua_register (lua_State *L,
const char *name,
lua_CFunction f);
<
Sets the C function `f` as the new value of global `name`. It is
defined as a macro:
>c
#define lua_register(L,n,f) \
(lua_pushcfunction(L, f), lua_setglobal(L, n))
<
lua_remove *lua_remove()*
>c
void lua_remove (lua_State *L, int index);
<
Removes the element at the given valid index, shifting down the
elements above this index to fill the gap. Cannot be called with a
pseudo-index, because a pseudo-index is not an actual stack position.
lua_replace *lua_replace()*
>c
void lua_replace (lua_State *L, int index);
<
Moves the top element into the given position (and pops it), without
shifting any element (therefore replacing the value at the given
position).
lua_resume *lua_resume()*
>c
int lua_resume (lua_State *L, int narg);
<
Starts and resumes a coroutine in a given thread.
To start a coroutine, you first create a new thread (see
|lua_newthread()|); then you push onto its stack the main
function plus any arguments; then you call `lua_resume` (see
|lua_resume()|) with `narg` being the number of arguments. This
call returns when the coroutine suspends or finishes its execution.
When it returns, the stack contains all values passed to `lua_yield`
(see |lua_yield()|), or all values returned by the body function.
`lua_resume` returns `LUA_YIELD` if the coroutine yields, 0 if the
coroutine finishes its execution without errors, or an error code in
case of errors (see |lua_pcall()|). In case of errors, the stack
is not unwound, so you can use the debug API over it. The error
message is on the top of the stack. To restart a coroutine, you put on
its stack only the values to be passed as results from `lua_yield`,
and then call `lua_resume`.
lua_setallocf *lua_setallocf()*
>c
void lua_setallocf (lua_State *L, lua_Alloc f, void *ud);
<
Changes the allocator function of a given state to `f` with user data
`ud`.
lua_setfenv *lua_setfenv()*
>c
int lua_setfenv (lua_State *L, int index);
<
Pops a table from the stack and sets it as the new environment for the
value at the given index. If the value at the given index is neither a
function nor a thread nor a userdata, `lua_setfenv` returns 0.
Otherwise it returns 1.
lua_setfield *lua_setfield()*
>c
void lua_setfield (lua_State *L, int index, const char *k);
<
Does the equivalent to `t[k] = v`, where `t` is the value at the given
valid index `index` and `v` is the value at the top of the stack.
This function pops the value from the stack. As in Lua, this function