1#![no_std]
2#![allow(non_snake_case)]
3#![allow(non_camel_case_types)]
4
5mod ffi;
19pub use ffi::*;
20
21use core::ptr;
22
23#[inline]
27pub unsafe fn lua_pop(L: *mut lua_State, idx: libc::c_int) {
28 lua_settop(L, -(idx) - 1)
29}
30
31#[inline]
33pub unsafe fn lua_newtable(L: *mut lua_State) {
34 lua_createtable(L, 0, 0)
35}
36
37#[inline]
39pub unsafe fn lua_register(L: *mut lua_State, name: *const libc::c_char, f: lua_CFunction) {
40 lua_pushcfunction(L, f);
41 lua_setglobal(L, name);
42}
43
44#[inline]
46pub unsafe fn lua_pushcfunction(L: *mut lua_State, f: lua_CFunction) {
47 lua_pushcclosure(L, f, 0);
48}
49
50#[inline]
52pub unsafe fn lua_strlen(L: *mut lua_State, idx: libc::c_int) -> usize {
53 lua_objlen(L, idx)
54}
55
56#[inline]
58pub unsafe fn lua_isfunction(L: *mut lua_State, idx: libc::c_int) -> libc::c_int {
59 (lua_type(L, idx) == LUA_TFUNCTION as i32) as i32
60}
61
62#[inline]
64pub unsafe fn lua_istable(L: *mut lua_State, idx: libc::c_int) -> libc::c_int {
65 (lua_type(L, idx) == LUA_TTABLE as i32) as i32
66}
67
68#[inline]
70pub unsafe fn lua_islightuserdata(L: *mut lua_State, idx: libc::c_int) -> libc::c_int {
71 (lua_type(L, idx) == LUA_TLIGHTUSERDATA as i32) as i32
72}
73
74#[inline]
76pub unsafe fn lua_isnil(L: *mut lua_State, idx: libc::c_int) -> libc::c_int {
77 (lua_type(L, idx) == LUA_TNIL as i32) as i32
78}
79
80#[inline]
82pub unsafe fn lua_isboolean(L: *mut lua_State, idx: libc::c_int) -> libc::c_int {
83 (lua_type(L, idx) == LUA_TBOOLEAN as i32) as i32
84}
85
86#[inline]
88pub unsafe fn lua_isthread(L: *mut lua_State, idx: libc::c_int) -> libc::c_int {
89 (lua_type(L, idx) == LUA_TTHREAD as i32) as i32
90}
91
92#[inline]
94pub unsafe fn lua_isnone(L: *mut lua_State, idx: libc::c_int) -> libc::c_int {
95 (lua_type(L, idx) == LUA_TNONE as i32) as i32
96}
97
98#[inline]
100pub unsafe fn lua_isnoneornil(L: *mut lua_State, idx: libc::c_int) -> libc::c_int {
101 (lua_type(L, idx) <= 0) as i32
102}
103
104#[inline]
106pub unsafe fn lua_pushliteral(L: *mut lua_State, s: &str) {
107 lua_pushlstring(L, s.as_ptr() as _, s.len() as _);
108}
109
110#[inline]
112pub unsafe fn lua_setglobal(L: *mut lua_State, k: *const libc::c_char) {
113 lua_setfield(L, LUA_GLOBALSINDEX, k);
114}
115
116#[inline]
118pub unsafe fn lua_getglobal(L: *mut lua_State, k: *const libc::c_char) {
119 lua_getfield(L, LUA_GLOBALSINDEX, k)
120}
121
122#[inline]
124pub unsafe fn lua_tostring(L: *mut lua_State, idx: libc::c_int) -> *const libc::c_char {
125 lua_tolstring(L, idx, ptr::null_mut())
126}
127
128#[inline]
132#[deprecated(since = "Lua 5.1", note = "replace with `luaL_newstate()`")]
133pub unsafe fn lua_open() -> *mut lua_State {
134 luaL_newstate()
135}
136
137#[inline]
139#[deprecated(
140 since = "Lua 5.1",
141 note = "replace with `lua_pushvalue(L, LUA_REGISTRYINDEX)`"
142)]
143pub unsafe fn lua_getregistry(L: *mut lua_State) {
144 lua_pushvalue(L, LUA_REGISTRYINDEX)
145}
146
147#[inline]
149#[deprecated(
150 since = "Lua 5.1",
151 note = "replace with `lua_gc(L, LUA_GCCOUNT as _, 0)`"
152)]
153pub unsafe fn lua_getgccount(L: *mut lua_State) -> libc::c_int {
154 lua_gc(L, LUA_GCCOUNT as _, 0)
155}
156
157#[deprecated(since = "Lua 5.1", note = "replace with `lua_Reader`")]
159pub type lua_Chunkreader = lua_Reader;
160
161#[deprecated(since = "Lua 5.1", note = "replace with `lua_Writer`")]
163pub type lua_Chunkwriter = lua_Writer;