12#include "common/scummsys.h"
18#include "common/lua/luaconf.h"
21#define LUA_VERSION "Lua 5.1"
22#define LUA_RELEASE "Lua 5.1.5"
23#define LUA_VERSION_NUM 501
24#define LUA_COPYRIGHT "Copyright (C) 1994-2012 Lua.org, PUC-Rio"
25#define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo & W. Celes"
29#define LUA_SIGNATURE "\033Lua"
32#define LUA_MULTRET (-1)
38#define LUA_REGISTRYINDEX (-10000)
39#define LUA_ENVIRONINDEX (-10001)
40#define LUA_GLOBALSINDEX (-10002)
41#define lua_upvalueindex(i) (LUA_GLOBALSINDEX-(i))
47#define LUA_ERRSYNTAX 3
53typedef int (*lua_CFunction) (
lua_State *L);
59typedef const char * (*lua_Reader) (
lua_State *L,
void *ud,
size_t *sz);
61typedef int (*lua_Writer) (
lua_State *L,
const void* p,
size_t sz,
void* ud);
67typedef void * (*lua_Alloc) (
void *ud,
void *ptr,
size_t osize,
size_t nsize);
77#define LUA_TLIGHTUSERDATA 2
81#define LUA_TFUNCTION 6
82#define LUA_TUSERDATA 7
88#define LUA_MINSTACK 20
94#if defined(LUA_USER_H)
100typedef LUA_NUMBER lua_Number;
104typedef LUA_INTEGER lua_Integer;
111LUA_API
lua_State *(lua_newstate) (lua_Alloc f,
void *ud);
115LUA_API lua_CFunction (lua_atpanic) (
lua_State *L, lua_CFunction panicf);
122LUA_API void (lua_settop) (
lua_State *L,
int idx);
123LUA_API void (lua_pushvalue) (
lua_State *L,
int idx);
124LUA_API void (lua_remove) (
lua_State *L,
int idx);
125LUA_API void (lua_insert) (
lua_State *L,
int idx);
126LUA_API void (lua_replace) (
lua_State *L,
int idx);
127LUA_API int (lua_checkstack) (
lua_State *L,
int sz);
136LUA_API int (lua_isnumber) (
lua_State *L,
int idx);
137LUA_API int (lua_isstring) (
lua_State *L,
int idx);
138LUA_API int (lua_iscfunction) (
lua_State *L,
int idx);
139LUA_API int (lua_isuserdata) (
lua_State *L,
int idx);
140LUA_API int (lua_type) (
lua_State *L,
int idx);
141LUA_API
const char *(lua_typename) (
lua_State *L,
int tp);
143LUA_API int (lua_equal) (
lua_State *L,
int idx1,
int idx2);
144LUA_API int (lua_rawequal) (
lua_State *L,
int idx1,
int idx2);
145LUA_API int (lua_lessthan) (
lua_State *L,
int idx1,
int idx2);
147LUA_API lua_Number (lua_tonumber) (
lua_State *L,
int idx);
148LUA_API lua_Integer (lua_tointeger) (
lua_State *L,
int idx);
149LUA_API int (lua_toboolean) (
lua_State *L,
int idx);
150LUA_API
const char *(lua_tolstring) (
lua_State *L,
int idx,
size_t *len);
151LUA_API size_t (lua_objlen) (
lua_State *L,
int idx);
152LUA_API lua_CFunction (lua_tocfunction) (
lua_State *L,
int idx);
153LUA_API
void *(lua_touserdata) (
lua_State *L,
int idx);
155LUA_API
const void *(lua_topointer) (
lua_State *L,
int idx);
161LUA_API void (lua_pushnil) (
lua_State *L);
162LUA_API void (lua_pushnumber) (
lua_State *L, lua_Number n);
163LUA_API void (lua_pushinteger) (
lua_State *L, lua_Integer n);
164LUA_API void (lua_pushlstring) (
lua_State *L,
const char *s,
size_t l);
165LUA_API void (lua_pushstring) (
lua_State *L,
const char *s);
166LUA_API
const char *(lua_pushvfstring) (
lua_State *L,
const char *fmt,
168LUA_API
const char *(lua_pushfstring) (
lua_State *L,
const char *fmt, ...);
169LUA_API void (lua_pushcclosure) (
lua_State *L, lua_CFunction fn,
int n);
170LUA_API void (lua_pushboolean) (
lua_State *L,
int b);
171LUA_API void (lua_pushlightuserdata) (
lua_State *L,
void *p);
172LUA_API int (lua_pushthread) (
lua_State *L);
178LUA_API void (lua_gettable) (
lua_State *L,
int idx);
179LUA_API void (lua_getfield) (
lua_State *L,
int idx,
const char *k);
180LUA_API void (lua_rawget) (
lua_State *L,
int idx);
181LUA_API void (lua_rawgeti) (
lua_State *L,
int idx,
int n);
182LUA_API void (lua_createtable) (
lua_State *L,
int narr,
int nrec);
183LUA_API
void *(lua_newuserdata) (
lua_State *L,
size_t sz);
184LUA_API int (lua_getmetatable) (
lua_State *L,
int objindex);
185LUA_API void (lua_getfenv) (
lua_State *L,
int idx);
191LUA_API void (lua_settable) (
lua_State *L,
int idx);
192LUA_API void (lua_setfield) (
lua_State *L,
int idx,
const char *k);
193LUA_API void (lua_rawset) (
lua_State *L,
int idx);
194LUA_API void (lua_rawseti) (
lua_State *L,
int idx,
int n);
195LUA_API int (lua_setmetatable) (
lua_State *L,
int objindex);
196LUA_API int (lua_setfenv) (
lua_State *L,
int idx);
202LUA_API void (lua_call) (
lua_State *L,
int nargs,
int nresults);
203LUA_API int (lua_pcall) (
lua_State *L,
int nargs,
int nresults,
int errfunc);
204LUA_API int (lua_cpcall) (
lua_State *L, lua_CFunction func,
void *ud);
205LUA_API int (lua_load) (
lua_State *L, lua_Reader reader,
void *dt,
206 const char *chunkname);
208LUA_API int (lua_dump) (
lua_State *L, lua_Writer writer,
void *data);
214LUA_API int (lua_yield) (
lua_State *L,
int nresults);
215LUA_API int (lua_resume) (
lua_State *L,
int narg);
223#define LUA_GCRESTART 1
224#define LUA_GCCOLLECT 2
226#define LUA_GCCOUNTB 4
228#define LUA_GCSETPAUSE 6
229#define LUA_GCSETSTEPMUL 7
231LUA_API int (lua_gc) (
lua_State *L,
int what,
int data);
240LUA_API int (lua_next) (
lua_State *L,
int idx);
242LUA_API void (lua_concat) (
lua_State *L,
int n);
244LUA_API lua_Alloc (lua_getallocf) (
lua_State *L,
void **ud);
245LUA_API
void lua_setallocf (
lua_State *L, lua_Alloc f,
void *ud);
255#define lua_pop(L,n) lua_settop(L, -(n)-1)
257#define lua_newtable(L) lua_createtable(L, 0, 0)
259#define lua_register(L,n,f) (lua_pushcfunction(L, (f)), lua_setglobal(L, (n)))
261#define lua_pushcfunction(L,f) lua_pushcclosure(L, (f), 0)
263#define lua_strlen(L,i) lua_objlen(L, (i))
265#define lua_isfunction(L,n) (lua_type(L, (n)) == LUA_TFUNCTION)
266#define lua_istable(L,n) (lua_type(L, (n)) == LUA_TTABLE)
267#define lua_islightuserdata(L,n) (lua_type(L, (n)) == LUA_TLIGHTUSERDATA)
268#define lua_isnil(L,n) (lua_type(L, (n)) == LUA_TNIL)
269#define lua_isboolean(L,n) (lua_type(L, (n)) == LUA_TBOOLEAN)
270#define lua_isthread(L,n) (lua_type(L, (n)) == LUA_TTHREAD)
271#define lua_isnone(L,n) (lua_type(L, (n)) == LUA_TNONE)
272#define lua_isnoneornil(L, n) (lua_type(L, (n)) <= 0)
274#define lua_pushliteral(L, s) \
275 lua_pushlstring(L, "" s, (sizeof(s)/sizeof(char))-1)
277#define lua_setglobal(L,s) lua_setfield(L, LUA_GLOBALSINDEX, (s))
278#define lua_getglobal(L,s) lua_getfield(L, LUA_GLOBALSINDEX, (s))
280#define lua_tostring(L,i) lua_tolstring(L, (i), NULL)
288#define lua_open() luaL_newstate()
290#define lua_getregistry(L) lua_pushvalue(L, LUA_REGISTRYINDEX)
292#define lua_getgccount(L) lua_gc(L, LUA_GCCOUNT, 0)
294#define lua_Chunkreader lua_Reader
295#define lua_Chunkwriter lua_Writer
312#define LUA_HOOKCALL 0
314#define LUA_HOOKLINE 2
315#define LUA_HOOKCOUNT 3
316#define LUA_HOOKTAILRET 4
322#define LUA_MASKCALL (1 << LUA_HOOKCALL)
323#define LUA_MASKRET (1 << LUA_HOOKRET)
324#define LUA_MASKLINE (1 << LUA_HOOKLINE)
325#define LUA_MASKCOUNT (1 << LUA_HOOKCOUNT)
338LUA_API
const char *lua_getupvalue (
lua_State *L,
int funcindex,
int n);
339LUA_API
const char *lua_setupvalue (
lua_State *L,
int funcindex,
int n);
341LUA_API
int lua_sethook (
lua_State *L, lua_Hook func,
int mask,
int count);
342LUA_API lua_Hook lua_gethook (
lua_State *L);
343LUA_API
int lua_gethookmask (
lua_State *L);
344LUA_API
int lua_gethookcount (
lua_State *L);
350 const char *namewhat;
357 char short_src[LUA_IDSIZE];