Skip to main content

Module api

Module api 

Source
Expand description

Rust-native translation of lapi.c — the Lua C-API surface.

The C-API surface (lua_State *, int stack-index protocol) is replaced by methods on LuaState. lua_lock/lua_unlock are dropped (no-op in the single-threaded default build). api_incr_top is dropped; state.push() already increments. Stack pointers (StkId) become StackIdx (u32).

Enums§

GcArgs
GcWhat
GC operation codes (C: LUA_GC* constants)

Constants§

LUA_IDENT

Functions§

abs_index
arith
at_panic
call_k
check_stack
close_slot
C’s lua_closeslot: this clears the slot at idx (sets it to nil), but does not invoke the value’s __close metamethod — a destructive but incomplete stand-in. The host-side to-be-closed path is not wired into the VM’s TBC machinery (issue #278); scripts still get full <close> semantics via OP_TBC.
compare
concat
configure_startup_gc_mode
Configure the hosted-runtime GC mode after the standard libraries are open.
copy
C’s lua_copy: copy the value at fromidx into toidx (a stack slot or a function-upvalue pseudo-index). Copying to LUA_REGISTRYINDEX is intentionally a no-op — C would replace the whole l_registry table, a footgun no real embedder uses (issue #278).
create_table
dump
gc
get_field
get_global
get_i
get_i_uservalue
get_i_value
Variant of get_i that accepts a pre-resolved table value instead of a stack index. Callers that invoke get_i repeatedly on the same table (e.g. the shift loops in table.remove / table.insert) should resolve the table once and use this function to avoid calling index_to_value on every iteration.
get_metatable
get_table
get_top
get_upvalue
is_cfunction
is_integer
is_number
is_string
is_userdata
len
load
lua_error
lua_type_at
new_userdata_uv
next
pcall_k
positive_index_value
Fast path for ordinary positive stack indices.
push_boolean
push_cclosure
C’s lua_pushcclosure: register f, then push either a light C function (n == 0) or a C closure that captures the top n stack values as upvalues.
push_fstring
push_integer
push_light_userdata
push_lstring
push_nil
push_number
push_string
push_thread
push_value
push_vfstring
raw_equal
raw_get
raw_get_i
raw_get_p
raw_len
raw_set
raw_set_i
raw_set_p
rotate
run_close_finalizers
Run every still-pending __gc finalizer at state close.
run_pending_finalizers
Drain objects already promoted from pending_finalizers to to_be_finalized by the heap mark phase.
run_pending_finalizers_inner
__gc driver that mirrors C-Lua’s GCTM(L, propagateerrors).
scan_v51_finalizable_userdata
Lua 5.1 collect-time finalizability scan, run before an explicit collect.
set_field
set_global
set_i
set_i_uservalue
set_i_value
Variant of set_i that accepts a pre-resolved table value instead of a stack index. Callers that invoke set_i repeatedly on the same table (e.g. the shift loops in table.remove / table.insert) should resolve the table once and use this function to avoid calling index_to_value on every iteration.
set_metatable
set_table
set_top
set_warn_f
setup_value
status
string_to_number
to_boolean
to_cfunction
C’s lua_tocfunction: the underlying bare C function pointer for a light C function or a C closure, or None for any other value. LightC/LuaCClosure store a LuaCFnPtr index into the per-state c_functions table; resolve it and hand back the registered fn.
to_close
C’s lua_toclose: mark the value at idx as a to-be-closed slot. Host-only stub — scripts get <close> semantics through the VM’s OP_TBC path, which is not routed through this C-API surface, so this only validates the index and does nothing else. See docs/EMBEDDING_API_IMPLEMENTATION.md “Known Limits” (issue #278).
to_integer_x
to_lua_string
to_number_x
to_pointer
C’s lua_topointer keyed on a stack index. Returns a usize identity token (raw void* pointers are confined to lua-gc / lua-coro). Delegates to the single value_identity_pointer resolver.
to_thread
to_userdata
type_name
upvalue_id
upvalue_join
value_identity_pointer
The object-identity token for a LuaValue, mirroring lua_topointer. Reference types (string, table, function, userdata, thread, light userdata) yield Some; the value types (nil, boolean, numbers) yield None.
version
warning
xmove
Move the top n values from from’s stack onto to’s stack.