beta-0.89.2
[luatex.git] / source / texk / web2c / luatexdir / lua / lauxlib_bridge.h
blob9f54ffe9103b1dfb92628f56b780afaf39f1ea07
1 /*
2 ** lauxlib_bridge.h,
3 ** Auxiliary functions bridge from luatex lua5.2 luajit 2.0
4 ** See Copyright Notice in lua.h
5 */
8 #ifndef lauxlib_bridge_h
9 #define lauxlib_bridge_h
11 #include "lauxlib.h"
15 /* compatibility with luatex lua5.2 */
17 #define LUA_OK 0
18 #define LUA_OPEQ 0
19 #define LUA_OPLT 1
20 #define LUA_OPLE 2
23 /* http://lua.2524044.n2.nabble.com/converting-modules-in-written-in-C-for-Lua-5-1-to-Lua-5-2-td7642941.html */
24 #define luaL_setmetatable(L, tname) luaL_getmetatable(L, tname);lua_setmetatable(L, -2);
26 /* see http://comments.gmane.org/gmane.comp.programming.swig/18673 */
28 # define lua_rawlen lua_objlen
32 LUALIB_API void *(luaL_testudata) (lua_State *L, int ud, const char *tname);
33 LUALIB_API void luaL_setfuncs (lua_State *L, const luaL_Reg *l, int nup);
34 LUALIB_API char *luaL_prepbuffsize (luaL_Buffer *B, size_t sz) ;
35 LUA_API int lua_compare (lua_State *L, int index1, int index2, int op);
37 #if !defined(lua_lock)
38 #define lua_lock(L) ((void) 0)
39 #define lua_unlock(L) ((void) 0)
40 #endif
42 #define luaL_newlibtable(L,l) \
43 lua_createtable(L, 0, sizeof(l)/sizeof((l)[0]) - 1)
45 #define luaL_newlib(L,l) (luaL_newlibtable(L,l), luaL_setfuncs(L,l,0))
47 /* Is this ok as replacement for lua_copy of lua 5.2.4 ? */
49 #if defined(LUAJIT)
50 LUA_API void lua_copy (lua_State *L, int fromidx, int toidx) {
51 TValue *fr, *to;
52 lua_lock(L);
53 fr = index2adr(L, fromidx);
54 to = index2adr(L, toidx);
55 api_checkvalidindex(L, to);
56 copyTV(L,to,fr);
57 lua_unlock(L);
59 #endif
61 #endif