aboutsummaryrefslogtreecommitdiff
path: root/src/compat.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/compat.h')
-rw-r--r--src/compat.h25
1 files changed, 20 insertions, 5 deletions
diff --git a/src/compat.h b/src/compat.h
index 496986b..6048974 100644
--- a/src/compat.h
+++ b/src/compat.h
@@ -5,9 +5,10 @@
5#include "lualib.h" 5#include "lualib.h"
6#include "lauxlib.h" 6#include "lauxlib.h"
7 7
8// code is now using Lua 5.2 API 8// code is now preferring Lua 5.3 API
9// add Lua 5.2 API when building for Lua 5.1 9// add some Lua 5.3-style API when building for Lua 5.1
10#if LUA_VERSION_NUM == 501 10#if LUA_VERSION_NUM == 501
11#define lua501_equal lua_equal
11#define lua_absindex( L, idx) (((idx) >= 0 || (idx) <= LUA_REGISTRYINDEX) ? (idx) : lua_gettop(L) + (idx) +1) 12#define lua_absindex( L, idx) (((idx) >= 0 || (idx) <= LUA_REGISTRYINDEX) ? (idx) : lua_gettop(L) + (idx) +1)
12#define lua_pushglobaltable(L) lua_pushvalue( L, LUA_GLOBALSINDEX) 13#define lua_pushglobaltable(L) lua_pushvalue( L, LUA_GLOBALSINDEX)
13#define lua_setuservalue lua_setfenv 14#define lua_setuservalue lua_setfenv
@@ -17,17 +18,31 @@
17#define LUA_OK 0 18#define LUA_OK 0
18#define LUA_ERRGCMM 666 // doesn't exist in Lua 5.1, we don't care about the actual value 19#define LUA_ERRGCMM 666 // doesn't exist in Lua 5.1, we don't care about the actual value
19void luaL_requiref (lua_State* L, const char* modname, lua_CFunction openf, int glb); // implementation copied from Lua 5.2 sources 20void luaL_requiref (lua_State* L, const char* modname, lua_CFunction openf, int glb); // implementation copied from Lua 5.2 sources
21#define lua503_dump( L, writer, data, strip) lua_dump( L, writer, data)
20#endif // LUA_VERSION_NUM == 501 22#endif // LUA_VERSION_NUM == 501
21 23
22// wrap Lua 5.2 calls under Lua 5.1 API when it is simpler that way 24// wrap Lua 5.2 calls under Lua 5.1 API when it is simpler that way
23#if LUA_VERSION_NUM == 502 25#if LUA_VERSION_NUM == 502
24#ifndef lua_equal // already defined when compatibility is active in luaconf.h 26#ifndef lua501_equal // already defined when compatibility is active in luaconf.h
25#define lua_equal( L, a, b) lua_compare( L, a, b, LUA_OPEQ) 27#define lua501_equal( L, a, b) lua_compare( L, a, b, LUA_OPEQ)
26#endif // lua_equal 28#endif // lua501_equal
27#ifndef lua_lessthan // already defined when compatibility is active in luaconf.h 29#ifndef lua_lessthan // already defined when compatibility is active in luaconf.h
28#define lua_lessthan( L, a, b) lua_compare( L, a, b, LUA_OPLT) 30#define lua_lessthan( L, a, b) lua_compare( L, a, b, LUA_OPLT)
29#endif // lua_lessthan 31#endif // lua_lessthan
30#define luaG_registerlibfuncs( L, _funcs) luaL_setfuncs( L, _funcs, 0) 32#define luaG_registerlibfuncs( L, _funcs) luaL_setfuncs( L, _funcs, 0)
33#define lua503_dump( L, writer, data, strip) lua_dump( L, writer, data)
31#endif // LUA_VERSION_NUM == 502 34#endif // LUA_VERSION_NUM == 502
32 35
36// wrap Lua 5.3 calls under Lua 5.1 API when it is simpler that way
37#if LUA_VERSION_NUM == 503
38#ifndef lua501_equal // already defined when compatibility is active in luaconf.h
39#define lua501_equal( L, a, b) lua_compare( L, a, b, LUA_OPEQ)
40#endif // lua501_equal
41#ifndef lua_lessthan // already defined when compatibility is active in luaconf.h
42#define lua_lessthan( L, a, b) lua_compare( L, a, b, LUA_OPLT)
43#endif // lua_lessthan
44#define luaG_registerlibfuncs( L, _funcs) luaL_setfuncs( L, _funcs, 0)
45#define lua503_dump lua_dump
46#endif // LUA_VERSION_NUM == 503
47
33#endif // __COMPAT_H__ 48#endif // __COMPAT_H__