Skip to main content

luaur_vm/records/
lua_callbacks.rs

1//! Node: `cxx:Record:Luau.VM:VM/include/lua.h:511:lua_callbacks`
2//! Source: `VM/include/lua.h` (lua.h:511-527, hand-ported)
3
4use crate::records::lua_debug::LuaDebug as lua_Debug;
5use crate::type_aliases::lua_state::lua_State;
6use core::ffi::{c_char, c_int, c_void};
7
8#[repr(C)]
9#[derive(Debug, Clone)]
10pub struct LuaCallbacks {
11    /// arbitrary userdata pointer that is never overwritten by Luau
12    pub userdata: *mut c_void,
13
14    /// gets called at safepoints (loop back edges, call/ret, gc) if set
15    pub interrupt: Option<unsafe extern "C-unwind" fn(l: *mut lua_State, gc: c_int)>,
16    /// gets called when an unprotected error is raised (if longjmp is used)
17    pub panic: Option<unsafe extern "C" fn(l: *mut lua_State, errcode: c_int)>,
18
19    /// gets called when L is created (LP == parent) or destroyed (LP == NULL)
20    pub userthread: Option<unsafe extern "C" fn(lp: *mut lua_State, l: *mut lua_State)>,
21    /// gets called when a string is created to assign an atom id
22    pub useratom:
23        Option<unsafe extern "C" fn(l: *mut lua_State, s: *const c_char, len: usize) -> i16>,
24
25    /// gets called when BREAK instruction is encountered
26    pub debugbreak: Option<unsafe extern "C" fn(l: *mut lua_State, ar: *mut lua_Debug)>,
27    /// gets called after each instruction in single step mode
28    pub debugstep: Option<unsafe extern "C" fn(l: *mut lua_State, ar: *mut lua_Debug)>,
29    /// gets called when thread execution is interrupted by break in another thread
30    pub debuginterrupt: Option<unsafe extern "C" fn(l: *mut lua_State, ar: *mut lua_Debug)>,
31    /// gets called when protected call results in an error
32    pub debugprotectederror: Option<unsafe extern "C-unwind" fn(l: *mut lua_State)>,
33
34    /// gets called when memory is allocated
35    pub onallocate: Option<unsafe extern "C" fn(l: *mut lua_State, osize: usize, nsize: usize)>,
36}
37
38#[allow(non_camel_case_types)]
39pub type lua_Callbacks = LuaCallbacks;