#![allow(non_snake_case)]
#![allow(non_camel_case_types)]
use std::ffi::{c_char, c_double, c_int, c_void};
use std::marker::{PhantomData, PhantomPinned};
#[repr(C)]
#[doc(hidden)]
pub struct lua_State {
_data: [u8; 0],
_marker: PhantomData<(*mut u8, PhantomPinned)>,
}
pub const LUA_REGISTRYINDEX: c_int = -10000;
pub const LUA_ENVIRONINDEX: c_int = -10001;
pub const LUA_GLOBALSINDEX: c_int = -10002;
pub const fn lua_upvalueindex(i: c_int) -> c_int {
LUA_GLOBALSINDEX - i
}
pub const LUA_OK: c_int = 0;
pub const LUA_ERRRUN: c_int = 2;
pub const LUA_ERRMEM: c_int = 4;
pub const LUA_ERRERR: c_int = 5;
pub const LUA_TNONE: c_int = -1;
pub const LUA_TNIL: c_int = 0;
pub const LUA_TBOOLEAN: c_int = 1;
pub const LUA_TLIGHTUSERDATA: c_int = 2;
pub const LUA_TNUMBER: c_int = 3;
pub const LUA_TSTRING: c_int = 4;
pub const LUA_TTABLE: c_int = 5;
pub const LUA_TFUNCTION: c_int = 6;
pub const LUA_TUSERDATA: c_int = 7;
pub const LUA_TTHREAD: c_int = 8;
pub type lua_CFunction = unsafe extern "C" fn(L: *mut lua_State) -> c_int;
pub type lua_Integer = isize;
pub type lua_Number = c_double;
extern "C" {
pub fn lua_call(L: *mut lua_State, nargs: c_int, nresults: c_int);
pub fn lua_createtable(L: *mut lua_State, narr: c_int, nrec: c_int);
pub fn lua_error(L: *mut lua_State) -> !;
pub fn lua_getfield(L: *mut lua_State, index: c_int, k: *const c_char);
pub fn lua_getmetatable(L: *mut lua_State, index: c_int) -> c_int;
pub fn lua_gettop(L: *mut lua_State) -> c_int;
pub fn lua_newuserdata(L: *mut lua_State, size: usize) -> *mut c_void;
pub fn lua_next(L: *mut lua_State, index: c_int) -> c_int;
pub fn lua_objlen(L: *mut lua_State, index: c_int) -> usize;
pub fn lua_pcall(
L: *mut lua_State,
nargs: c_int,
nresults: c_int,
errorfunc: c_int,
) -> c_int;
pub fn lua_pushboolean(L: *mut lua_State, n: lua_Integer);
pub fn lua_pushcclosure(L: *mut lua_State, r#fn: lua_CFunction, n: c_int);
pub fn lua_pushinteger(L: *mut lua_State, n: lua_Integer);
pub fn lua_pushlightuserdata(L: *mut lua_State, p: *mut c_void);
pub fn lua_pushlstring(L: *mut lua_State, s: *const c_char, len: usize);
pub fn lua_pushnil(L: *mut lua_State);
pub fn lua_pushnumber(L: *mut lua_State, n: lua_Number);
pub fn lua_pushstring(L: *mut lua_State, s: *const c_char);
pub fn lua_pushvalue(L: *mut lua_State, index: c_int);
pub fn lua_rawgeti(L: *mut lua_State, index: c_int, n: c_int);
pub fn lua_rawset(L: *mut lua_State, index: c_int);
pub fn lua_rawseti(L: *mut lua_State, index: c_int, n: c_int);
pub fn lua_settop(L: *mut lua_State, index: c_int);
pub fn lua_toboolean(L: *mut lua_State, index: c_int) -> c_int;
pub fn lua_tointeger(L: *mut lua_State, index: c_int) -> lua_Integer;
pub fn lua_tolstring(
L: *mut lua_State,
index: c_int,
len: *mut usize,
) -> *const c_char;
pub fn lua_tonumber(L: *mut lua_State, index: c_int) -> lua_Number;
pub fn lua_touserdata(L: *mut lua_State, index: c_int) -> *mut c_void;
pub fn lua_type(L: *mut lua_State, index: c_int) -> c_int;
pub fn lua_typename(L: *mut lua_State, tp: c_int) -> *const c_char;
pub fn luaL_error(L: *mut lua_State, fmt: *const c_char, ...) -> !;
pub fn luaL_ref(L: *mut lua_State, t: c_int) -> c_int;
pub fn luaL_unref(L: *mut lua_State, t: c_int, r#ref: c_int);
}
pub unsafe fn lua_getglobal(L: *mut lua_State, name: *const c_char) {
lua_getfield(L, LUA_GLOBALSINDEX, name)
}
pub unsafe fn lua_pop(L: *mut lua_State, n: c_int) {
lua_settop(L, -n - 1)
}
pub unsafe fn lua_pushcfunction(L: *mut lua_State, r#fn: lua_CFunction) {
lua_pushcclosure(L, r#fn, 0)
}
pub unsafe fn lua_tostring(L: *mut lua_State, index: c_int) -> *const c_char {
lua_tolstring(L, index, std::ptr::null_mut())
}
pub unsafe fn luaL_typename(L: *mut lua_State, index: c_int) -> *const c_char {
lua_typename(L, lua_type(L, index))
}