diff options
Diffstat (limited to 'src/compat.h')
-rw-r--r-- | src/compat.h | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/src/compat.h b/src/compat.h index 998edef..eaa9f85 100644 --- a/src/compat.h +++ b/src/compat.h | |||
@@ -5,7 +5,8 @@ | |||
5 | #include "lualib.h" | 5 | #include "lualib.h" |
6 | #include "lauxlib.h" | 6 | #include "lauxlib.h" |
7 | 7 | ||
8 | // code is now preferring Lua 5.3 API | 8 | // code is now preferring Lua 5.4 API |
9 | |||
9 | // add some Lua 5.3-style API when building for Lua 5.1 | 10 | // add some Lua 5.3-style API when building for Lua 5.1 |
10 | #if LUA_VERSION_NUM == 501 | 11 | #if LUA_VERSION_NUM == 501 |
11 | #define lua501_equal lua_equal | 12 | #define lua501_equal lua_equal |
@@ -18,7 +19,8 @@ | |||
18 | #define LUA_OK 0 | 19 | #define LUA_OK 0 |
19 | #define LUA_ERRGCMM 666 // doesn't exist in Lua 5.1, we don't care about the actual value | 20 | #define LUA_ERRGCMM 666 // doesn't exist in Lua 5.1, we don't care about the actual value |
20 | void luaL_requiref (lua_State* L, const char* modname, lua_CFunction openf, int glb); // implementation copied from Lua 5.2 sources | 21 | void 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) | 22 | #define lua504_dump( L, writer, data, strip) lua_dump( L, writer, data) |
23 | #define LUA_LOADED_TABLE "_LOADED" // // doesn't exist in Lua 5.1 | ||
22 | #endif // LUA_VERSION_NUM == 501 | 24 | #endif // LUA_VERSION_NUM == 501 |
23 | 25 | ||
24 | // wrap Lua 5.2 calls under Lua 5.1 API when it is simpler that way | 26 | // wrap Lua 5.2 calls under Lua 5.1 API when it is simpler that way |
@@ -30,7 +32,8 @@ void luaL_requiref (lua_State* L, const char* modname, lua_CFunction openf, int | |||
30 | #define lua_lessthan( L, a, b) lua_compare( L, a, b, LUA_OPLT) | 32 | #define lua_lessthan( L, a, b) lua_compare( L, a, b, LUA_OPLT) |
31 | #endif // lua_lessthan | 33 | #endif // lua_lessthan |
32 | #define luaG_registerlibfuncs( L, _funcs) luaL_setfuncs( L, _funcs, 0) | 34 | #define luaG_registerlibfuncs( L, _funcs) luaL_setfuncs( L, _funcs, 0) |
33 | #define lua503_dump( L, writer, data, strip) lua_dump( L, writer, data) | 35 | #define lua504_dump( L, writer, data, strip) lua_dump( L, writer, data) |
36 | #define LUA_LOADED_TABLE "_LOADED" // // doesn't exist in Lua 5.2 | ||
34 | #endif // LUA_VERSION_NUM == 502 | 37 | #endif // LUA_VERSION_NUM == 502 |
35 | 38 | ||
36 | // wrap Lua 5.3 calls under Lua 5.1 API when it is simpler that way | 39 | // wrap Lua 5.3 calls under Lua 5.1 API when it is simpler that way |
@@ -42,8 +45,27 @@ void luaL_requiref (lua_State* L, const char* modname, lua_CFunction openf, int | |||
42 | #define lua_lessthan( L, a, b) lua_compare( L, a, b, LUA_OPLT) | 45 | #define lua_lessthan( L, a, b) lua_compare( L, a, b, LUA_OPLT) |
43 | #endif // lua_lessthan | 46 | #endif // lua_lessthan |
44 | #define luaG_registerlibfuncs( L, _funcs) luaL_setfuncs( L, _funcs, 0) | 47 | #define luaG_registerlibfuncs( L, _funcs) luaL_setfuncs( L, _funcs, 0) |
45 | #define lua503_dump lua_dump | 48 | #define lua504_dump lua_dump |
46 | #define luaL_optint(L,n,d) ((int)luaL_optinteger(L, (n), (d))) | 49 | #define luaL_optint(L,n,d) ((int)luaL_optinteger(L, (n), (d))) |
47 | #endif // LUA_VERSION_NUM == 503 | 50 | #endif // LUA_VERSION_NUM == 503 |
48 | 51 | ||
52 | #if LUA_VERSION_NUM < 504 | ||
53 | void *lua_newuserdatauv( lua_State* L, size_t sz, int nuvalue); | ||
54 | int lua_getiuservalue( lua_State* L, int idx, int n); | ||
55 | int lua_setiuservalue( lua_State* L, int idx, int n); | ||
56 | #endif // LUA_VERSION_NUM < 504 | ||
57 | |||
58 | // wrap Lua 5.4 calls under Lua 5.1 API when it is simpler that way | ||
59 | #if LUA_VERSION_NUM == 504 | ||
60 | #ifndef lua501_equal // already defined when compatibility is active in luaconf.h | ||
61 | #define lua501_equal( L, a, b) lua_compare( L, a, b, LUA_OPEQ) | ||
62 | #endif // lua501_equal | ||
63 | #ifndef lua_lessthan // already defined when compatibility is active in luaconf.h | ||
64 | #define lua_lessthan( L, a, b) lua_compare( L, a, b, LUA_OPLT) | ||
65 | #endif // lua_lessthan | ||
66 | #define luaG_registerlibfuncs( L, _funcs) luaL_setfuncs( L, _funcs, 0) | ||
67 | #define lua504_dump lua_dump | ||
68 | #define luaL_optint(L,n,d) ((int)luaL_optinteger(L, (n), (d))) | ||
69 | #endif // LUA_VERSION_NUM == 504 | ||
70 | |||
49 | #endif // __COMPAT_H__ | 71 | #endif // __COMPAT_H__ |