1use crate::*;
2use core::ptr;
3
4pub const LUA_MULTRET: libc::c_int = -1;
9
10#[cfg(LUA_VERSION = "5.2")]
11pub const LUA_REGISTRYINDEX: libc::c_int = -LUAI_MAXSTACK - 1000;
12#[cfg(not(LUA_VERSION = "5.2"))]
13pub const LUA_REGISTRYINDEX: libc::c_int = -10000;
14
15#[cfg(all(LUA_VERSION = "5.1", not(LUA_VERSION = "5.2")))]
16pub const LUA_ENVIRONINDEX: libc::c_int = -10001;
17
18#[cfg(any(not(LUA_VERSION = "5.2")))]
20pub const LUA_GLOBALSINDEX: libc::c_int = -10002;
21
22pub const LUA_YIELD: libc::c_int = 1;
23pub const LUA_ERRRUN: libc::c_int = 2;
24pub const LUA_ERRSYNTAX: libc::c_int = 3;
25pub const LUA_ERRMEM: libc::c_int = 4;
26
27cfg_if::cfg_if! {
28 if #[cfg(LUA_VERSION = "5.2")] {
29 pub const LUA_OK: libc::c_int = 0;
30 pub const LUA_ERRGCMM: libc::c_int = 5;
31 pub const LUA_ERRERR: libc::c_int = 6;
32 } else {
33 pub const LUA_ERRERR: libc::c_int = 5;
34 }
35}
36
37pub const LUA_TNONE: libc::c_int = -1;
38pub const LUA_TNIL: libc::c_int = 0;
39pub const LUA_TBOOLEAN: libc::c_int = 1;
40pub const LUA_TLIGHTUSERDATA: libc::c_int = 2;
41pub const LUA_TNUMBER: libc::c_int = 3;
42pub const LUA_TSTRING: libc::c_int = 4;
43pub const LUA_TTABLE: libc::c_int = 5;
44pub const LUA_TFUNCTION: libc::c_int = 6;
45pub const LUA_TUSERDATA: libc::c_int = 7;
46pub const LUA_TTHREAD: libc::c_int = 8;
47
48cfg_if::cfg_if! {
49 if #[cfg(LUA_VERSION = "5.2")] {
50 pub const LUA_NUMTAGS: libc::c_int = 9;
51 }
52}
53
54pub const LUA_MINSTACK: libc::c_int = 20;
55
56cfg_if::cfg_if! {
58 if #[cfg(LUA_VERSION = "5.2")] {
59 pub const LUA_RIDX_MAINTHREAD: lua_Integer = 1;
60 pub const LUA_RIDX_GLOBALS: lua_Integer = 2;
61 pub const LUA_RIDX_LAST: lua_Integer = LUA_RIDX_GLOBALS;
62 }
63}
64
65pub const LUA_OPADD: libc::c_int = 0;
66pub const LUA_OPSUB: libc::c_int = 1;
67pub const LUA_OPMUL: libc::c_int = 2;
68
69cfg_if::cfg_if! {
70 if #[cfg(LUA_VERSION = "5.3")] {
71 pub const LUA_OPMOD: libc::c_int = 3;
72 pub const LUA_OPPOW: libc::c_int = 4;
73 pub const LUA_OPDIV: libc::c_int = 5;
74 pub const LUA_OPIDIV: libc::c_int = 6;
75 pub const LUA_OPBAND: libc::c_int = 7;
76 pub const LUA_OPBOR: libc::c_int = 8;
77 pub const LUA_OPBXOR: libc::c_int = 9;
78 pub const LUA_OPSHL: libc::c_int = 10;
79 pub const LUA_OPSHR: libc::c_int = 11;
80 pub const LUA_OPUNM: libc::c_int = 12;
81 pub const LUA_OPBNOT: libc::c_int = 13;
82 } else {
83 pub const LUA_OPDIV: libc::c_int = 3;
84 pub const LUA_OPMOD: libc::c_int = 4;
85 pub const LUA_OPPOW: libc::c_int = 5;
86 pub const LUA_OPUNM: libc::c_int = 6;
87 }
88}
89
90pub const LUA_OPEQ: libc::c_int = 0;
91pub const LUA_OPLT: libc::c_int = 1;
92pub const LUA_OPLE: libc::c_int = 2;
93
94pub const LUA_GCSTOP: libc::c_int = 0;
95pub const LUA_GCRESTART: libc::c_int = 1;
96pub const LUA_GCCOLLECT: libc::c_int = 2;
97pub const LUA_GCCOUNT: libc::c_int = 3;
98pub const LUA_GCCOUNTB: libc::c_int = 4;
99pub const LUA_GCSTEP: libc::c_int = 5;
100pub const LUA_GCSETPAUSE: libc::c_int = 6;
101pub const LUA_GCSETSTEPMUL: libc::c_int = 7;
102pub const LUA_GCISRUNNING: libc::c_int = 9;
103
104cfg_if::cfg_if! {
106 if #[cfg(all(LUA_VERSION = "5.2", not(LUA_VERSION = "5.3")))] {
107 pub const LUA_GCSETMAJORINC: libc::c_int = 8;
108 pub const LUA_GCGEN: libc::c_int = 10;
109 pub const LUA_GCINC: libc::c_int = 11;
110 }
111}
112
113pub const LUA_HOOKCALL: libc::c_int = 0;
114pub const LUA_HOOKRET: libc::c_int = 1;
115pub const LUA_HOOKLINE: libc::c_int = 2;
116pub const LUA_HOOKCOUNT: libc::c_int = 3;
117pub const LUA_HOOKTAILCALL: libc::c_int = 4;
118
119pub const LUA_MASKCALL: libc::c_int = (1 as libc::c_int).wrapping_shl(LUA_HOOKCALL as libc::c_uint);
120pub const LUA_MASKRET: libc::c_int = (1 as libc::c_int).wrapping_shl(LUA_HOOKRET as libc::c_uint);
121pub const LUA_MASKLINE: libc::c_int = (1 as libc::c_int).wrapping_shl(LUA_HOOKLINE as libc::c_uint);
122pub const LUA_MASKCOUNT: libc::c_int =
123 (1 as libc::c_int).wrapping_shl(LUA_HOOKCOUNT as libc::c_uint);
124
125pub const LUAI_MAXSTACK: libc::c_int = 1_000_000;
126
127pub const LUA_EXTRASPACE: usize = ::core::mem::size_of::<*const libc::c_void>();
128
129pub const LUA_IDSIZE: usize = 60;
130
131pub const LUA_MAXINTEGER: lua_Integer = lua_Integer::max_value();
132pub const LUA_MININTEGER: lua_Integer = lua_Integer::min_value();
133
134pub type lua_Alloc = Option<
139 unsafe extern "C" fn(
140 ud: *mut libc::c_void,
141 ptr: *mut libc::c_void,
142 osize: usize,
143 nsize: usize,
144 ) -> *mut libc::c_void,
145>;
146
147pub type lua_CFunction = Option<unsafe extern "C" fn(L: *mut lua_State) -> libc::c_int>;
148
149pub type lua_KFunction = Option<
150 unsafe extern "C" fn(L: *mut lua_State, status: libc::c_int, ctx: lua_KContext) -> libc::c_int,
151>;
152
153pub type lua_Reader = Option<
154 unsafe extern "C" fn(
155 L: *mut lua_State,
156 ud: *mut libc::c_void,
157 sz: *mut usize,
158 ) -> *const libc::c_char,
159>;
160
161#[repr(C)]
162#[derive(Debug)]
163pub struct lua_State {
164 _private: [u8; 0],
165}
166
167pub type lua_Writer = Option<
168 unsafe extern "C" fn(
169 L: *mut lua_State,
170 p: *const libc::c_void,
171 sz: usize,
172 ud: *mut libc::c_void,
173 ) -> libc::c_int,
174>;
175
176extern "C" {
181 pub fn lua_absindex(L: *mut lua_State, idx: libc::c_int) -> libc::c_int;
182 pub fn lua_arith(L: *mut lua_State, op: libc::c_int);
183 pub fn lua_atpanic(L: *mut lua_State, panicf: lua_CFunction) -> lua_CFunction;
184
185 #[cfg(not(LUA_VERSION = "5.2"))]
187 pub fn lua_call(L: *mut lua_State, nargs: libc::c_int, nresults: libc::c_int);
188
189 #[cfg(LUA_VERSION = "5.2")]
191 pub fn lua_callk(
192 L: *mut lua_State,
193 nargs: libc::c_int,
194 nresults: libc::c_int,
195 ctx: lua_KContext,
196 k: lua_KFunction,
197 );
198
199 pub fn lua_checkstack(L: *mut lua_State, n: libc::c_int) -> libc::c_int;
200 pub fn lua_close(L: *mut lua_State);
201 pub fn lua_compare(
202 L: *mut lua_State,
203 idx1: libc::c_int,
204 idx2: libc::c_int,
205 op: libc::c_int,
206 ) -> libc::c_int;
207 pub fn lua_concat(L: *mut lua_State, n: libc::c_int);
208 pub fn lua_copy(L: *mut lua_State, fromidx: libc::c_int, toidx: libc::c_int);
209
210 #[cfg(not(LUA_VERSION = "5.2"))]
212 pub fn lua_cpcall(L: *mut lua_State, func: lua_CFunction, ud: *mut libc::c_void)
213 -> libc::c_int;
214
215 pub fn lua_createtable(L: *mut lua_State, narr: libc::c_int, nrec: libc::c_int);
216
217 #[cfg(LUA_VERSION = "5.3")]
219 pub fn lua_dump(
220 L: *mut lua_State,
221 writer: lua_Writer,
222 data: *mut libc::c_void,
223 strip: libc::c_int,
224 ) -> libc::c_int;
225 #[cfg(not(LUA_VERSION = "5.3"))]
226 pub fn lua_dump(L: *mut lua_State, writer: lua_Writer, data: *mut libc::c_void) -> libc::c_int;
227
228 #[cfg(all(LUA_VERSION = "5.0", not(LUA_VERSION = "5.2")))]
230 pub fn lua_equal(L: *mut lua_State, idx1: libc::c_int, idx2: libc::c_int) -> libc::c_int;
231
232 pub fn lua_error(L: *mut lua_State) -> libc::c_int;
233 pub fn lua_gc(L: *mut lua_State, what: libc::c_int, data: libc::c_int) -> libc::c_int;
234 pub fn lua_getallocf(L: *mut lua_State, ud: *mut *mut libc::c_void) -> lua_Alloc;
235
236 #[cfg(all(LUA_VERSION = "5.2", not(LUA_VERSION = "5.3")))]
238 pub fn lua_getctx(L: *mut lua_State, ctx: *mut libc::c_int) -> libc::c_int;
239
240 #[cfg(not(LUA_VERSION = "5.2"))]
242 pub fn lua_getfenv(L: *mut lua_State, index: libc::c_int);
243
244 pub fn lua_getfield(L: *mut lua_State, idx: libc::c_int, k: *const libc::c_char)
245 -> libc::c_int;
246 pub fn lua_getglobal(L: *mut lua_State, name: *const libc::c_char) -> libc::c_int;
247 pub fn lua_geti(L: *mut lua_State, idx: libc::c_int, n: lua_Integer) -> libc::c_int;
248 pub fn lua_getmetatable(L: *mut lua_State, objindex: libc::c_int) -> libc::c_int;
249 pub fn lua_gettable(L: *mut lua_State, idx: libc::c_int) -> libc::c_int;
250 pub fn lua_gettop(L: *mut lua_State) -> libc::c_int;
251 pub fn lua_getuservalue(L: *mut lua_State, idx: libc::c_int) -> libc::c_int;
252 pub fn lua_iscfunction(L: *mut lua_State, idx: libc::c_int) -> libc::c_int;
253 pub fn lua_isinteger(L: *mut lua_State, idx: libc::c_int) -> libc::c_int;
254 pub fn lua_isnumber(L: *mut lua_State, idx: libc::c_int) -> libc::c_int;
255 pub fn lua_isstring(L: *mut lua_State, idx: libc::c_int) -> libc::c_int;
256 pub fn lua_isuserdata(L: *mut lua_State, idx: libc::c_int) -> libc::c_int;
257 pub fn lua_isyieldable(L: *mut lua_State) -> libc::c_int;
258 pub fn lua_len(L: *mut lua_State, idx: libc::c_int);
259
260 #[cfg(all(LUA_VERSION = "5.0", not(LUA_VERSION = "5.2")))]
262 pub fn lua_lessthan(L: *mut lua_State, idx1: libc::c_int, idx2: libc::c_int) -> libc::c_int;
263
264 #[cfg(LUA_VERSION = "5.2")]
266 pub fn lua_load(
267 L: *mut lua_State,
268 reader: lua_Reader,
269 dt: *mut libc::c_void,
270 chunkname: *const libc::c_char,
271 mode: *const libc::c_char,
272 ) -> libc::c_int;
273 #[cfg(not(LUA_VERSION = "5.2"))]
274 pub fn lua_load(
275 L: *mut lua_State,
276 reader: lua_Reader,
277 data: *mut libc::c_void,
278 chunkname: *const libc::c_char,
279 ) -> libc::c_int;
280
281 #[cfg(LUA_VERSION = "5.1")]
283 pub fn lua_newstate(f: lua_Alloc, ud: *mut libc::c_void) -> *mut lua_State;
284
285 pub fn lua_newthread(L: *mut lua_State) -> *mut lua_State;
286 pub fn lua_newuserdata(L: *mut lua_State, sz: usize) -> *mut libc::c_void;
287 pub fn lua_next(L: *mut lua_State, idx: libc::c_int) -> libc::c_int;
288
289 #[cfg(all(LUA_VERSION = "5.1", not(LUA_VERSION = "5.2")))]
291 pub fn lua_objlen(L: *mut lua_State, index: libc::c_int) -> usize;
292
293 #[cfg(all(LUA_VERSION = "5.0", not(LUA_VERSION = "5.1")))]
295 pub fn lua_open() -> *mut lua_State;
296
297 #[cfg(not(LUA_VERSION = "5.2"))]
299 pub fn lua_pcall(
300 L: *mut lua_State,
301 nargs: libc::c_int,
302 nresults: libc::c_int,
303 msgh: libc::c_int,
304 ) -> libc::c_int;
305
306 #[cfg(LUA_VERSION = "5.2")]
308 pub fn lua_pcallk(
309 L: *mut lua_State,
310 nargs: libc::c_int,
311 nresults: libc::c_int,
312 errfunc: libc::c_int,
313 ctx: lua_KContext,
314 k: lua_KFunction,
315 ) -> libc::c_int;
316
317 pub fn lua_pushboolean(L: *mut lua_State, b: libc::c_int);
318 pub fn lua_pushcclosure(L: *mut lua_State, fn_: lua_CFunction, n: libc::c_int);
319 pub fn lua_pushfstring(L: *mut lua_State, fmt: *const libc::c_char, ...)
320 -> *const libc::c_char;
321 pub fn lua_pushinteger(L: *mut lua_State, n: lua_Integer);
322 pub fn lua_pushlightuserdata(L: *mut lua_State, p: *mut libc::c_void);
323 pub fn lua_pushlstring(
324 L: *mut lua_State,
325 s: *const libc::c_char,
326 len: usize,
327 ) -> *const libc::c_char;
328 pub fn lua_pushnil(L: *mut lua_State);
329 pub fn lua_pushnumber(L: *mut lua_State, n: lua_Number);
330 pub fn lua_pushstring(L: *mut lua_State, s: *const libc::c_char) -> *const libc::c_char;
331 pub fn lua_pushthread(L: *mut lua_State) -> libc::c_int;
332
333 #[cfg(any(all(LUA_VERSION = "5.2", not(LUA_VERSION = "5.3"))))]
335 pub fn lua_pushunsigned(L: *mut lua_State, n: lua_Unsigned);
336
337 pub fn lua_pushvalue(L: *mut lua_State, idx: libc::c_int);
338
339 #[cfg(feature = "va-list")]
340 pub fn lua_pushvfstring(
341 L: *mut lua_State,
342 fmt: *const libc::c_char,
343 argp: va_list::VaList,
344 ) -> *const libc::c_char;
345
346 pub fn lua_rawequal(L: *mut lua_State, idx1: libc::c_int, idx2: libc::c_int) -> libc::c_int;
347 pub fn lua_rawget(L: *mut lua_State, idx: libc::c_int) -> libc::c_int;
348 pub fn lua_rawgeti(L: *mut lua_State, idx: libc::c_int, n: lua_Integer) -> libc::c_int;
349
350 #[cfg(LUA_VERSION = "5.2")]
352 pub fn lua_rawgetp(L: *mut lua_State, idx: libc::c_int, p: *const libc::c_void) -> libc::c_int;
353
354 #[cfg(LUA_VERSION = "5.2")]
356 pub fn lua_rawlen(L: *mut lua_State, idx: libc::c_int) -> usize;
357
358 pub fn lua_rawset(L: *mut lua_State, idx: libc::c_int);
359 pub fn lua_rawseti(L: *mut lua_State, idx: libc::c_int, n: lua_Integer);
360
361 #[cfg(LUA_VERSION = "5.2")]
363 pub fn lua_rawsetp(L: *mut lua_State, idx: libc::c_int, p: *const libc::c_void);
364
365 #[cfg(LUA_VERSION = "5.2")]
367 pub fn lua_resume(L: *mut lua_State, from: *mut lua_State, narg: libc::c_int) -> libc::c_int;
368 #[cfg(not(LUA_VERSION = "5.2"))]
369 pub fn lua_resume(L: *mut lua_State, narg: libc::c_int) -> libc::c_int;
370
371 pub fn lua_rotate(L: *mut lua_State, idx: libc::c_int, n: libc::c_int);
372 pub fn lua_setallocf(L: *mut lua_State, f: lua_Alloc, ud: *mut libc::c_void);
373
374 #[cfg(not(LUA_VERSION = "5.2"))]
376 pub fn lua_setfenv(L: *mut lua_State, index: libc::c_int) -> libc::c_int;
377
378 pub fn lua_setfield(L: *mut lua_State, idx: libc::c_int, k: *const libc::c_char);
379 pub fn lua_setglobal(L: *mut lua_State, name: *const libc::c_char);
380 pub fn lua_seti(L: *mut lua_State, idx: libc::c_int, n: lua_Integer);
381 pub fn lua_setmetatable(L: *mut lua_State, objindex: libc::c_int) -> libc::c_int;
382 pub fn lua_settable(L: *mut lua_State, idx: libc::c_int);
383 pub fn lua_settop(L: *mut lua_State, idx: libc::c_int);
384 pub fn lua_setuservalue(L: *mut lua_State, idx: libc::c_int);
385 pub fn lua_status(L: *mut lua_State) -> libc::c_int;
386
387 #[cfg(all(LUA_VERSION = "5.0", not(LUA_VERSION = "5.1")))]
389 pub fn lua_strlen(L: *mut lua_State, idx: libc::c_int) -> usize;
390
391 pub fn lua_stringtonumber(L: *mut lua_State, s: *const libc::c_char) -> usize;
392 pub fn lua_toboolean(L: *mut lua_State, idx: libc::c_int) -> libc::c_int;
393 pub fn lua_tocfunction(L: *mut lua_State, idx: libc::c_int) -> lua_CFunction;
394
395 #[cfg(not(LUA_VERSION = "5.2"))]
397 pub fn lua_tointeger(L: *mut lua_State, index: libc::c_int) -> lua_Integer;
398
399 #[cfg(LUA_VERSION = "5.2")]
401 pub fn lua_tointegerx(
402 L: *mut lua_State,
403 idx: libc::c_int,
404 isnum: *mut libc::c_int,
405 ) -> lua_Integer;
406
407 pub fn lua_tolstring(
408 L: *mut lua_State,
409 idx: libc::c_int,
410 len: *mut usize,
411 ) -> *const libc::c_char;
412
413 #[cfg(not(LUA_VERSION = "5.2"))]
415 pub fn lua_tonumber(L: *mut lua_State, index: libc::c_int) -> lua_Number;
416
417 #[cfg(LUA_VERSION = "5.2")]
419 pub fn lua_tonumberx(
420 L: *mut lua_State,
421 idx: libc::c_int,
422 isnum: *mut libc::c_int,
423 ) -> lua_Number;
424
425 pub fn lua_topointer(L: *mut lua_State, idx: libc::c_int) -> *const libc::c_void;
426 pub fn lua_tothread(L: *mut lua_State, idx: libc::c_int) -> *mut lua_State;
427
428 #[cfg(any(
430 all(LUA_VERSION = "5.2", not(LUA_VERSION = "5.3")),
431 all(LUA_VERSION = "5.3", feature = "lua-compat")
432 ))]
433 pub fn lua_tounsignedx(
434 L: *mut lua_State,
435 idx: libc::c_int,
436 isnum: *mut libc::c_int,
437 ) -> lua_Unsigned;
438
439 pub fn lua_touserdata(L: *mut lua_State, idx: libc::c_int) -> *mut libc::c_void;
440 pub fn lua_type(L: *mut lua_State, idx: libc::c_int) -> libc::c_int;
441 pub fn lua_typename(L: *mut lua_State, tp: libc::c_int) -> *const libc::c_char;
442 pub fn lua_version(L: *mut lua_State) -> *const lua_Number;
443 pub fn lua_xmove(from: *mut lua_State, to: *mut lua_State, n: libc::c_int);
444 pub fn lua_yieldk(
445 L: *mut lua_State,
446 nresults: libc::c_int,
447 ctx: lua_KContext,
448 k: lua_KFunction,
449 ) -> libc::c_int;
450}
451
452#[cfg_attr(LUA_VERSION = "5.2", inline)]
458#[cfg(LUA_VERSION = "5.2")]
459pub unsafe fn lua_call(L: *mut lua_State, nargs: libc::c_int, nresults: libc::c_int) {
460 lua_callk(L, nargs, nresults, 0, None);
461}
462
463#[cfg(all(LUA_VERSION = "5.2", feature = "lua-compat"))]
465pub unsafe fn lua_cpcall(
466 L: *mut lua_State,
467 func: lua_CFunction,
468 ud: *mut libc::c_void,
469) -> libc::c_int {
470 lua_pushcfunction(L, func);
471 lua_pushlightuserdata(L, ud);
472 lua_pcall(L, 1, 0, 0);
473}
474
475#[cfg(all(LUA_VERSION = "5.2", feature = "lua-compat"))]
477pub unsafe fn lua_equal(L: *mut lua_State, idx1: libc::c_int, idx2: libc::c_int) -> libc::c_int {
478 lua_compare(L, idx1, idx2, LUA_OPEQ)
479}
480
481#[inline]
482pub unsafe fn lua_getextraspace(L: *mut lua_State) -> *mut libc::c_void {
483 (L as usize - LUA_EXTRASPACE) as *mut libc::c_void
484}
485
486#[inline]
487pub unsafe fn lua_insert(L: *mut lua_State, index: libc::c_int) {
488 lua_rotate(L, index, 1);
489}
490
491#[inline]
492pub unsafe fn lua_isboolean(L: *mut lua_State, index: libc::c_int) -> libc::c_int {
493 (lua_type(L, index) == LUA_TBOOLEAN) as libc::c_int
494}
495
496#[inline]
497pub unsafe fn lua_isfunction(L: *mut lua_State, index: libc::c_int) -> libc::c_int {
498 (lua_type(L, index) == LUA_TFUNCTION) as libc::c_int
499}
500
501#[inline]
502pub unsafe fn lua_islightuserdata(L: *mut lua_State, index: libc::c_int) -> libc::c_int {
503 (lua_type(L, index) == LUA_TLIGHTUSERDATA) as libc::c_int
504}
505
506#[inline]
507pub unsafe fn lua_isnil(L: *mut lua_State, index: libc::c_int) -> libc::c_int {
508 (lua_type(L, index) == LUA_TNIL) as libc::c_int
509}
510
511#[inline]
512pub unsafe fn lua_isnone(L: *mut lua_State, index: libc::c_int) -> libc::c_int {
513 (lua_type(L, index) == LUA_TNONE) as libc::c_int
514}
515
516#[inline]
517pub unsafe fn lua_isnoneornil(L: *mut lua_State, index: libc::c_int) -> libc::c_int {
518 (lua_type(L, index) <= 0) as libc::c_int
519}
520
521#[inline]
522pub unsafe fn lua_istable(L: *mut lua_State, index: libc::c_int) -> libc::c_int {
523 (lua_type(L, index) == LUA_TTABLE) as libc::c_int
524}
525
526#[inline]
527pub unsafe fn lua_isthread(L: *mut lua_State, index: libc::c_int) -> libc::c_int {
528 (lua_type(L, index) == LUA_TTHREAD) as libc::c_int
529}
530
531#[cfg(all(LUA_VERSION = "5.2", feature = "lua-compat"))]
533pub unsafe fn lua_lessthan(L: *mut lua_State, idx1: libc::c_int, idx2: libc::c_int) -> libc::c_int {
534 lua_compare(L, idx1, idx2, LUA_OPLT)
535}
536
537#[inline]
538pub unsafe fn lua_newtable(L: *mut lua_State) {
539 lua_createtable(L, 0, 0);
540}
541
542#[inline]
543pub unsafe fn lua_numbertointeger(n: lua_Number, p: *mut lua_Integer) -> libc::c_int {
544 if n >= LUA_MININTEGER as lua_Number && n < -(LUA_MININTEGER as lua_Number) {
545 *p = n as lua_Integer;
546 1
547 } else {
548 0
549 }
550}
551
552#[cfg_attr(LUA_VERSION = "5.2", inline)]
554#[cfg(LUA_VERSION = "5.2")]
555pub unsafe fn lua_pcall(
556 L: *mut lua_State,
557 nargs: libc::c_int,
558 nresults: libc::c_int,
559 msgh: libc::c_int,
560) -> libc::c_int {
561 lua_pcallk(L, nargs, nresults, msgh, 0, None)
562}
563
564#[inline]
565pub unsafe fn lua_pop(L: *mut lua_State, n: libc::c_int) {
566 lua_settop(L, -n - 1);
567}
568
569#[inline]
570pub unsafe fn lua_pushcfunction(L: *mut lua_State, f: lua_CFunction) {
571 lua_pushcclosure(L, f, 0);
572}
573
574#[cfg_attr(LUA_VERSION = "5.2", inline)]
576#[cfg(LUA_VERSION = "5.2")]
577pub unsafe fn lua_pushglobaltable(L: *mut lua_State) {
578 lua_rawgeti(L, LUA_REGISTRYINDEX, LUA_RIDX_GLOBALS);
579}
580
581#[inline]
582pub unsafe fn lua_pushliteral(L: *mut lua_State, s: *const libc::c_char) -> *const libc::c_char {
583 lua_pushstring(L, s)
584}
585
586#[cfg(all(LUA_VERSION = "5.3", feature = "lua-compat"))]
588pub unsafe fn lua_pushunsigned(L: *mut lua_State, n: lua_Unsigned) {
589 lua_pushinteger(L, n as lua_Integer);
590}
591
592#[inline]
593pub unsafe fn lua_register(L: *mut lua_State, name: *const libc::c_char, f: lua_CFunction) {
594 lua_pushcfunction(L, f);
595 lua_setglobal(L, name);
596}
597
598#[inline]
599pub unsafe fn lua_remove(L: *mut lua_State, index: libc::c_int) {
600 lua_rotate(L, index, -1);
601 lua_pop(L, 1);
602}
603
604#[inline]
605pub unsafe fn lua_replace(L: *mut lua_State, index: libc::c_int) {
606 lua_copy(L, -1, index);
607 lua_pop(L, 1);
608}
609
610#[cfg(all(LUA_VERSION = "5.2", feature = "lua-compat"))]
612pub unsafe fn lua_strlen(L: *mut lua_State, idx: libc::c_int) -> usize {
613 lua_rawlen(L, idx)
614}
615#[cfg(all(LUA_VERSION = "5.1", not(LUA_VERSION = "5.2")))]
616pub unsafe fn lua_strlen(L: *mut lua_State, idx: libc::c_int) -> usize {
617 lua_objlen(L, idx)
618}
619
620#[cfg_attr(LUA_VERSION = "5.2", inline)]
622#[cfg(LUA_VERSION = "5.2")]
623pub unsafe fn lua_tointeger(L: *mut lua_State, index: libc::c_int) -> lua_Integer {
624 lua_tointegerx(L, index, ptr::null_mut())
625}
626
627#[cfg_attr(LUA_VERSION = "5.2", inline)]
629#[cfg(LUA_VERSION = "5.2")]
630pub unsafe fn lua_tonumber(L: *mut lua_State, index: libc::c_int) -> lua_Number {
631 lua_tonumberx(L, index, ptr::null_mut())
632}
633
634#[inline]
635pub unsafe fn lua_tostring(L: *mut lua_State, index: libc::c_int) -> *const libc::c_char {
636 lua_tolstring(L, index, ptr::null_mut())
637}
638
639#[cfg_attr(
641 any(
642 all(LUA_VERSION = "5.2", not(LUA_VERSION = "5.3")),
643 all(LUA_VERSION = "5.3", feature = "lua-compat")
644 ),
645 inline
646)]
647#[cfg(any(
648 all(LUA_VERSION = "5.2", not(LUA_VERSION = "5.3")),
649 all(LUA_VERSION = "5.3", feature = "lua-compat")
650))]
651pub unsafe fn lua_tounsigned(L: *mut lua_State, index: libc::c_int) -> lua_Unsigned {
652 lua_tounsignedx(L, index, ptr::null_mut())
653}
654
655#[inline]
656pub const unsafe fn lua_upvalueindex(i: libc::c_int) -> libc::c_int {
657 LUA_REGISTRYINDEX - i
658}
659
660#[inline]
661pub unsafe fn lua_yield(L: *mut lua_State, nresults: libc::c_int) -> libc::c_int {
662 lua_yieldk(L, nresults, 0, None)
663}