aboutsummaryrefslogtreecommitdiff
path: root/llthreads2/src/l52util.h
diff options
context:
space:
mode:
Diffstat (limited to 'llthreads2/src/l52util.h')
-rw-r--r--llthreads2/src/l52util.h57
1 files changed, 57 insertions, 0 deletions
diff --git a/llthreads2/src/l52util.h b/llthreads2/src/l52util.h
new file mode 100644
index 0000000..38a87db
--- /dev/null
+++ b/llthreads2/src/l52util.h
@@ -0,0 +1,57 @@
1#ifndef _LZUTILS_H_9B43D914_9652_4E22_9A43_8073502BF3F4_
2#define _LZUTILS_H_9B43D914_9652_4E22_9A43_8073502BF3F4_
3
4#include "lua.h"
5#include "lauxlib.h"
6
7#if LUA_VERSION_NUM >= 502 // lua 5.2
8
9// lua_rawgetp
10// lua_rawsetp
11// luaL_setfuncs
12// lua_absindex
13
14#ifndef lua_objlen
15
16#define lua_objlen lua_rawlen
17
18#endif
19
20int luaL_typerror (lua_State *L, int narg, const char *tname);
21
22#ifndef luaL_register
23
24void luaL_register (lua_State *L, const char *libname, const luaL_Reg *l);
25
26#endif
27
28#define lutil_require luaL_requiref
29
30#else // lua 5.1
31
32// functions form lua 5.2
33
34# define lua_absindex(L, i) (((i)>0)?(i):((i)<=LUA_REGISTRYINDEX?(i):(lua_gettop(L)+(i)+1)))
35# define lua_rawlen lua_objlen
36
37void lua_rawgetp (lua_State *L, int index, const void *p);
38void lua_rawsetp (lua_State *L, int index, const void *p);
39void luaL_setfuncs (lua_State *L, const luaL_Reg *l, int nup);
40
41void lutil_require(lua_State *L, const char* name, lua_CFunction fn, int glb);
42
43#endif
44
45int lutil_newmetatablep (lua_State *L, const void *p);
46void lutil_getmetatablep (lua_State *L, const void *p);
47void lutil_setmetatablep (lua_State *L, const void *p);
48
49#define lutil_newudatap(L, TTYPE, TNAME) (TTYPE *)lutil_newudatap_impl(L, sizeof(TTYPE), TNAME)
50int lutil_isudatap (lua_State *L, int ud, const void *p);
51void *lutil_checkudatap (lua_State *L, int ud, const void *p);
52int lutil_createmetap (lua_State *L, const void *p, const luaL_Reg *methods, int nup);
53
54void *lutil_newudatap_impl (lua_State *L, size_t size, const void *p);
55
56#endif
57