aboutsummaryrefslogtreecommitdiff
path: root/src/l52util.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/l52util.h')
-rw-r--r--src/l52util.h46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/l52util.h b/src/l52util.h
new file mode 100644
index 0000000..f4f0497
--- /dev/null
+++ b/src/l52util.h
@@ -0,0 +1,46 @@
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
15#define lua_objlen lua_rawlen
16
17int luaL_typerror (lua_State *L, int narg, const char *tname);
18
19void luaL_register (lua_State *L, const char *libname, const luaL_Reg *l);
20
21#else // lua 5.1
22
23// functions form lua 5.2
24
25# define lua_absindex(L, i) (((i)>0)?(i):((i)<=LUA_REGISTRYINDEX?(i):(lua_gettop(L)+(i)+1)))
26# define lua_rawlen lua_objlen
27
28void lua_rawgetp (lua_State *L, int index, const void *p);
29void lua_rawsetp (lua_State *L, int index, const void *p);
30void luaL_setfuncs (lua_State *L, const luaL_Reg *l, int nup);
31
32#endif
33
34int lutil_newmetatablep (lua_State *L, const void *p);
35void lutil_getmetatablep (lua_State *L, const void *p);
36void lutil_setmetatablep (lua_State *L, const void *p);
37
38#define lutil_newudatap(L, TTYPE, TNAME) (TTYPE *)lutil_newudatap_impl(L, sizeof(TTYPE), TNAME)
39int lutil_isudatap (lua_State *L, int ud, const void *p);
40void *lutil_checkudatap (lua_State *L, int ud, const void *p);
41int lutil_createmetap (lua_State *L, const void *p, const luaL_Reg *methods, int nup);
42
43void *lutil_newudatap_impl (lua_State *L, size_t size, const void *p);
44
45#endif
46