Skip to main content

luaur_code_gen/records/
native_context.rs

1use crate::type_aliases::lua_state::lua_State;
2use crate::type_aliases::luau_fast_function::luau_fast_function;
3use core::ffi::{c_double, c_int, c_uint};
4use luaur_vm::type_aliases::stk_id::StkId;
5use luaur_vm::type_aliases::t_value::TValue;
6use luaur_vm::type_aliases::tms::TMS;
7
8#[allow(non_snake_case)]
9#[derive(Debug, Clone, Copy)]
10#[repr(C)]
11pub struct NativeContext {
12    pub gateEntry: *mut u8,
13    pub gateExit: *mut u8,
14
15    pub luaV_lessthan: Option<
16        unsafe extern "C" fn(L: *mut lua_State, l: *const TValue, r: *const TValue) -> c_int,
17    >,
18    pub luaV_lessequal: Option<
19        unsafe extern "C" fn(L: *mut lua_State, l: *const TValue, r: *const TValue) -> c_int,
20    >,
21    pub luaV_equalval: Option<
22        unsafe extern "C" fn(L: *mut lua_State, t1: *const TValue, t2: *const TValue) -> c_int,
23    >,
24    pub luaV_doarithadd: Option<
25        unsafe extern "C" fn(L: *mut lua_State, ra: StkId, rb: *const TValue, rc: *const TValue),
26    >,
27    pub luaV_doarithsub: Option<
28        unsafe extern "C" fn(L: *mut lua_State, ra: StkId, rb: *const TValue, rc: *const TValue),
29    >,
30    pub luaV_doarithmul: Option<
31        unsafe extern "C" fn(L: *mut lua_State, ra: StkId, rb: *const TValue, rc: *const TValue),
32    >,
33    pub luaV_doarithdiv: Option<
34        unsafe extern "C" fn(L: *mut lua_State, ra: StkId, rb: *const TValue, rc: *const TValue),
35    >,
36    pub luaV_doarithidiv: Option<
37        unsafe extern "C" fn(L: *mut lua_State, ra: StkId, rb: *const TValue, rc: *const TValue),
38    >,
39    pub luaV_doarithmod: Option<
40        unsafe extern "C" fn(L: *mut lua_State, ra: StkId, rb: *const TValue, rc: *const TValue),
41    >,
42    pub luaV_doarithpow: Option<
43        unsafe extern "C" fn(L: *mut lua_State, ra: StkId, rb: *const TValue, rc: *const TValue),
44    >,
45    pub luaV_doarithunm: Option<
46        unsafe extern "C" fn(L: *mut lua_State, ra: StkId, rb: *const TValue, rc: *const TValue),
47    >,
48    pub luaV_dolen: Option<unsafe extern "C" fn(L: *mut lua_State, ra: StkId, rb: *const TValue)>,
49    pub luaV_gettable: Option<
50        unsafe extern "C" fn(L: *mut lua_State, t: *const TValue, key: *mut TValue, val: StkId),
51    >,
52    pub luaV_settable: Option<
53        unsafe extern "C" fn(L: *mut lua_State, t: *const TValue, key: *mut TValue, val: StkId),
54    >,
55    pub luaV_concat: Option<unsafe extern "C" fn(L: *mut lua_State, total: c_int, last: c_int)>,
56
57    pub luaH_getn: Option<unsafe extern "C" fn(t: *mut core::ffi::c_void) -> c_int>,
58    pub luaH_new: Option<
59        unsafe extern "C" fn(
60            L: *mut lua_State,
61            narray: c_int,
62            lnhash: c_int,
63        ) -> *mut core::ffi::c_void,
64    >,
65    pub luaH_clone: Option<
66        unsafe extern "C" fn(
67            L: *mut lua_State,
68            tt: *mut core::ffi::c_void,
69        ) -> *mut core::ffi::c_void,
70    >,
71    pub luaH_resizearray:
72        Option<unsafe extern "C" fn(L: *mut lua_State, t: *mut core::ffi::c_void, nasize: c_int)>,
73    pub luaH_setnum: Option<
74        unsafe extern "C" fn(
75            L: *mut lua_State,
76            t: *mut core::ffi::c_void,
77            key: c_int,
78        ) -> *mut TValue,
79    >,
80
81    pub luaC_barriertable: Option<
82        unsafe extern "C" fn(
83            L: *mut lua_State,
84            t: *mut core::ffi::c_void,
85            v: *mut core::ffi::c_void,
86        ),
87    >,
88    pub luaC_barrierf: Option<
89        unsafe extern "C" fn(
90            L: *mut lua_State,
91            o: *mut core::ffi::c_void,
92            v: *mut core::ffi::c_void,
93        ),
94    >,
95    pub luaC_barrierback: Option<
96        unsafe extern "C" fn(
97            L: *mut lua_State,
98            o: *mut core::ffi::c_void,
99            gclist: *mut *mut core::ffi::c_void,
100        ),
101    >,
102    pub luaC_step: Option<unsafe extern "C" fn(L: *mut lua_State, assist: bool) -> usize>,
103
104    pub luaF_close: Option<unsafe extern "C" fn(L: *mut lua_State, level: StkId)>,
105    pub luaF_findupval:
106        Option<unsafe extern "C" fn(L: *mut lua_State, level: StkId) -> *mut core::ffi::c_void>,
107    pub luaF_newLclosure: Option<
108        unsafe extern "C" fn(
109            L: *mut lua_State,
110            nelems: c_int,
111            e: *mut core::ffi::c_void,
112            p: *mut core::ffi::c_void,
113        ) -> *mut core::ffi::c_void,
114    >,
115
116    pub luaT_gettm: Option<
117        unsafe extern "C" fn(
118            events: *mut core::ffi::c_void,
119            event: TMS,
120            ename: *mut core::ffi::c_void,
121        ) -> *const TValue,
122    >,
123    pub luaT_objtypenamestr: Option<
124        unsafe extern "C" fn(L: *mut lua_State, o: *const TValue) -> *const core::ffi::c_void,
125    >,
126
127    pub libm_exp: Option<unsafe extern "C" fn(c_double) -> c_double>,
128    pub libm_pow: Option<unsafe extern "C" fn(c_double, c_double) -> c_double>,
129    pub libm_fmod: Option<unsafe extern "C" fn(c_double, c_double) -> c_double>,
130    pub libm_asin: Option<unsafe extern "C" fn(c_double) -> c_double>,
131    pub libm_sin: Option<unsafe extern "C" fn(c_double) -> c_double>,
132    pub libm_sinh: Option<unsafe extern "C" fn(c_double) -> c_double>,
133    pub libm_acos: Option<unsafe extern "C" fn(c_double) -> c_double>,
134    pub libm_cos: Option<unsafe extern "C" fn(c_double) -> c_double>,
135    pub libm_cosh: Option<unsafe extern "C" fn(c_double) -> c_double>,
136    pub libm_atan: Option<unsafe extern "C" fn(c_double) -> c_double>,
137    pub libm_atan2: Option<unsafe extern "C" fn(c_double, c_double) -> c_double>,
138    pub libm_tan: Option<unsafe extern "C" fn(c_double) -> c_double>,
139    pub libm_tanh: Option<unsafe extern "C" fn(c_double) -> c_double>,
140    pub libm_log: Option<unsafe extern "C" fn(c_double) -> c_double>,
141    pub libm_log2: Option<unsafe extern "C" fn(c_double) -> c_double>,
142    pub libm_log10: Option<unsafe extern "C" fn(c_double) -> c_double>,
143    pub libm_ldexp: Option<unsafe extern "C" fn(c_double, c_int) -> c_double>,
144    pub libm_round: Option<unsafe extern "C" fn(c_double) -> c_double>,
145    pub libm_frexp: Option<unsafe extern "C" fn(c_double, *mut c_int) -> c_double>,
146    pub libm_modf: Option<unsafe extern "C" fn(c_double, *mut c_double) -> c_double>,
147
148    pub forgLoopTableIter: Option<
149        unsafe extern "C" fn(
150            L: *mut lua_State,
151            h: *mut core::ffi::c_void,
152            index: c_int,
153            ra: *mut TValue,
154        ) -> bool,
155    >,
156    pub forgLoopNodeIter: Option<
157        unsafe extern "C" fn(
158            L: *mut lua_State,
159            h: *mut core::ffi::c_void,
160            index: c_int,
161            ra: *mut TValue,
162        ) -> bool,
163    >,
164    pub forgLoopNonTableFallback:
165        Option<unsafe extern "C" fn(L: *mut lua_State, insnA: c_int, aux: c_int) -> c_int>,
166    pub forgLoopNonTableFallback_DEPRECATED:
167        Option<unsafe extern "C" fn(L: *mut lua_State, insnA: c_int, aux: c_int) -> bool>,
168    pub forgPrepXnextFallback:
169        Option<unsafe extern "C" fn(L: *mut lua_State, ra: *mut TValue, pc: c_int)>,
170    pub callProlog: Option<
171        unsafe extern "C" fn(
172            L: *mut lua_State,
173            ra: *mut TValue,
174            argtop: StkId,
175            nresults: c_int,
176        ) -> *mut core::ffi::c_void,
177    >,
178    pub callEpilogC: Option<unsafe extern "C" fn(L: *mut lua_State, nresults: c_int, n: c_int)>,
179    pub newUserdata: Option<
180        unsafe extern "C" fn(L: *mut lua_State, s: usize, tag: c_int) -> *mut core::ffi::c_void,
181    >,
182    pub getImport:
183        Option<unsafe extern "C" fn(L: *mut lua_State, res: StkId, id: c_uint, pc: c_uint)>,
184
185    pub callFallback: Option<
186        unsafe extern "C" fn(
187            L: *mut lua_State,
188            ra: StkId,
189            argtop: StkId,
190            nresults: c_int,
191        ) -> *mut core::ffi::c_void,
192    >,
193
194    pub executeGETGLOBAL: Option<
195        unsafe extern "C" fn(
196            L: *mut lua_State,
197            pc: *const u32,
198            base: StkId,
199            k: *mut TValue,
200        ) -> *const u32,
201    >,
202    pub executeSETGLOBAL: Option<
203        unsafe extern "C" fn(
204            L: *mut lua_State,
205            pc: *const u32,
206            base: StkId,
207            k: *mut TValue,
208        ) -> *const u32,
209    >,
210    pub executeGETTABLEKS: Option<
211        unsafe extern "C" fn(
212            L: *mut lua_State,
213            pc: *const u32,
214            base: StkId,
215            k: *mut TValue,
216        ) -> *const u32,
217    >,
218    pub executeSETTABLEKS: Option<
219        unsafe extern "C" fn(
220            L: *mut lua_State,
221            pc: *const u32,
222            base: StkId,
223            k: *mut TValue,
224        ) -> *const u32,
225    >,
226    pub executeNAMECALL: Option<
227        unsafe extern "C" fn(
228            L: *mut lua_State,
229            pc: *const u32,
230            base: StkId,
231            k: *mut TValue,
232        ) -> *const u32,
233    >,
234    pub executeSETLIST: Option<
235        unsafe extern "C" fn(
236            L: *mut lua_State,
237            pc: *const u32,
238            base: StkId,
239            k: *mut TValue,
240        ) -> *const u32,
241    >,
242    pub executeFORGPREP: Option<
243        unsafe extern "C" fn(
244            L: *mut lua_State,
245            pc: *const u32,
246            base: StkId,
247            k: *mut TValue,
248        ) -> *const u32,
249    >,
250    pub executeGETVARARGSMultRet:
251        Option<unsafe extern "C" fn(L: *mut lua_State, pc: *const u32, base: StkId, rai: c_int)>,
252    pub executeGETVARARGSConst:
253        Option<unsafe extern "C" fn(L: *mut lua_State, base: StkId, rai: c_int, b: c_int)>,
254    pub executeDUPCLOSURE: Option<
255        unsafe extern "C" fn(
256            L: *mut lua_State,
257            pc: *const u32,
258            base: StkId,
259            k: *mut TValue,
260        ) -> *const u32,
261    >,
262    pub executePREPVARARGS: Option<
263        unsafe extern "C" fn(
264            L: *mut lua_State,
265            pc: *const u32,
266            base: StkId,
267            k: *mut TValue,
268        ) -> *const u32,
269    >,
270
271    pub luauF_table: [luau_fast_function; 256],
272}
273
274impl Default for NativeContext {
275    fn default() -> Self {
276        unsafe { core::mem::zeroed() }
277    }
278}