aboutsummaryrefslogtreecommitdiff
path: root/src/compat.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/compat.h')
-rw-r--r--src/compat.h42
1 files changed, 21 insertions, 21 deletions
diff --git a/src/compat.h b/src/compat.h
index 8d10e78..037a3ba 100644
--- a/src/compat.h
+++ b/src/compat.h
@@ -1,7 +1,8 @@
1#pragma once 1#pragma once
2 2
3#ifdef __cplusplus 3#ifdef __cplusplus
4extern "C" { 4extern "C"
5{
5#endif // __cplusplus 6#endif // __cplusplus
6#include "lua.h" 7#include "lua.h"
7#include "lualib.h" 8#include "lualib.h"
@@ -22,16 +23,15 @@ extern "C" {
22#define LUAJIT_FLAVOR() 0 23#define LUAJIT_FLAVOR() 0
23#endif // LUA_JITLIBNAME 24#endif // LUA_JITLIBNAME
24 25
25
26// code is now preferring Lua 5.4 API 26// code is now preferring Lua 5.4 API
27 27
28// add some Lua 5.3-style API when building for Lua 5.1 28// add some Lua 5.3-style API when building for Lua 5.1
29#if LUA_VERSION_NUM == 501 29#if LUA_VERSION_NUM == 501
30 30
31#define lua501_equal lua_equal 31#define lua501_equal lua_equal
32#define lua_absindex( L, idx) (((idx) >= 0 || (idx) <= LUA_REGISTRYINDEX) ? (idx) : lua_gettop(L) + (idx) +1) 32#define lua_absindex(L, idx) (((idx) >= 0 || (idx) <= LUA_REGISTRYINDEX) ? (idx) : lua_gettop(L) + (idx) + 1)
33#if LUAJIT_VERSION_NUM < 20200 // moonjit is 5.1 plus bits of 5.2 that we don't need to wrap 33#if LUAJIT_VERSION_NUM < 20200 // moonjit is 5.1 plus bits of 5.2 that we don't need to wrap
34#define lua_pushglobaltable(L) lua_pushvalue( L, LUA_GLOBALSINDEX) 34#define lua_pushglobaltable(L) lua_pushvalue(L, LUA_GLOBALSINDEX)
35#endif // LUAJIT_VERSION_NUM 35#endif // LUAJIT_VERSION_NUM
36#define lua_setuservalue lua_setfenv 36#define lua_setuservalue lua_setfenv
37#define lua_getuservalue lua_getfenv 37#define lua_getuservalue lua_getfenv
@@ -39,8 +39,8 @@ extern "C" {
39#define luaG_registerlibfuncs(L, _funcs) luaL_register(L, nullptr, _funcs) 39#define luaG_registerlibfuncs(L, _funcs) luaL_register(L, nullptr, _funcs)
40#define LUA_OK 0 40#define LUA_OK 0
41#define LUA_ERRGCMM 666 // doesn't exist in Lua 5.1, we don't care about the actual value 41#define LUA_ERRGCMM 666 // doesn't exist in Lua 5.1, we don't care about the actual value
42void luaL_requiref (lua_State* L, const char* modname, lua_CFunction openf, int glb); // implementation copied from Lua 5.2 sources 42void luaL_requiref(lua_State* L, const char* modname, lua_CFunction openf, int glb); // implementation copied from Lua 5.2 sources
43#define lua504_dump( L, writer, data, strip) lua_dump( L, writer, data) 43#define lua504_dump(L, writer, data, strip) lua_dump(L, writer, data)
44#define LUA_LOADED_TABLE "_LOADED" // // doesn't exist in Lua 5.1 44#define LUA_LOADED_TABLE "_LOADED" // // doesn't exist in Lua 5.1
45 45
46#endif // LUA_VERSION_NUM == 501 46#endif // LUA_VERSION_NUM == 501
@@ -49,13 +49,13 @@ void luaL_requiref (lua_State* L, const char* modname, lua_CFunction openf, int
49#if LUA_VERSION_NUM == 502 49#if LUA_VERSION_NUM == 502
50 50
51#ifndef lua501_equal // already defined when compatibility is active in luaconf.h 51#ifndef lua501_equal // already defined when compatibility is active in luaconf.h
52#define lua501_equal( L, a, b) lua_compare( L, a, b, LUA_OPEQ) 52#define lua501_equal(L, a, b) lua_compare(L, a, b, LUA_OPEQ)
53#endif // lua501_equal 53#endif // lua501_equal
54#ifndef lua_lessthan // already defined when compatibility is active in luaconf.h 54#ifndef lua_lessthan // already defined when compatibility is active in luaconf.h
55#define lua_lessthan( L, a, b) lua_compare( L, a, b, LUA_OPLT) 55#define lua_lessthan(L, a, b) lua_compare(L, a, b, LUA_OPLT)
56#endif // lua_lessthan 56#endif // lua_lessthan
57#define luaG_registerlibfuncs( L, _funcs) luaL_setfuncs( L, _funcs, 0) 57#define luaG_registerlibfuncs(L, _funcs) luaL_setfuncs(L, _funcs, 0)
58#define lua504_dump( L, writer, data, strip) lua_dump( L, writer, data) 58#define lua504_dump(L, writer, data, strip) lua_dump(L, writer, data)
59#define LUA_LOADED_TABLE "_LOADED" // // doesn't exist in Lua 5.2 59#define LUA_LOADED_TABLE "_LOADED" // // doesn't exist in Lua 5.2
60 60
61#endif // LUA_VERSION_NUM == 502 61#endif // LUA_VERSION_NUM == 502
@@ -64,22 +64,22 @@ void luaL_requiref (lua_State* L, const char* modname, lua_CFunction openf, int
64#if LUA_VERSION_NUM == 503 64#if LUA_VERSION_NUM == 503
65 65
66#ifndef lua501_equal // already defined when compatibility is active in luaconf.h 66#ifndef lua501_equal // already defined when compatibility is active in luaconf.h
67#define lua501_equal( L, a, b) lua_compare( L, a, b, LUA_OPEQ) 67#define lua501_equal(L, a, b) lua_compare(L, a, b, LUA_OPEQ)
68#endif // lua501_equal 68#endif // lua501_equal
69#ifndef lua_lessthan // already defined when compatibility is active in luaconf.h 69#ifndef lua_lessthan // already defined when compatibility is active in luaconf.h
70#define lua_lessthan( L, a, b) lua_compare( L, a, b, LUA_OPLT) 70#define lua_lessthan(L, a, b) lua_compare(L, a, b, LUA_OPLT)
71#endif // lua_lessthan 71#endif // lua_lessthan
72#define luaG_registerlibfuncs( L, _funcs) luaL_setfuncs( L, _funcs, 0) 72#define luaG_registerlibfuncs(L, _funcs) luaL_setfuncs(L, _funcs, 0)
73#define lua504_dump lua_dump 73#define lua504_dump lua_dump
74#define luaL_optint(L,n,d) ((int)luaL_optinteger(L, (n), (d))) 74#define luaL_optint(L, n, d) ((int) luaL_optinteger(L, (n), (d)))
75 75
76#endif // LUA_VERSION_NUM == 503 76#endif // LUA_VERSION_NUM == 503
77 77
78#if LUA_VERSION_NUM < 504 78#if LUA_VERSION_NUM < 504
79 79
80void *lua_newuserdatauv( lua_State* L, size_t sz, int nuvalue); 80void* lua_newuserdatauv(lua_State* L, size_t sz, int nuvalue);
81int lua_getiuservalue( lua_State* L, int idx, int n); 81int lua_getiuservalue(lua_State* L, int idx, int n);
82int lua_setiuservalue( lua_State* L, int idx, int n); 82int lua_setiuservalue(lua_State* L, int idx, int n);
83 83
84#endif // LUA_VERSION_NUM < 504 84#endif // LUA_VERSION_NUM < 504
85 85
@@ -87,14 +87,14 @@ int lua_setiuservalue( lua_State* L, int idx, int n);
87#if LUA_VERSION_NUM == 504 87#if LUA_VERSION_NUM == 504
88 88
89#ifndef lua501_equal // already defined when compatibility is active in luaconf.h 89#ifndef lua501_equal // already defined when compatibility is active in luaconf.h
90#define lua501_equal( L, a, b) lua_compare( L, a, b, LUA_OPEQ) 90#define lua501_equal(L, a, b) lua_compare(L, a, b, LUA_OPEQ)
91#endif // lua501_equal 91#endif // lua501_equal
92#ifndef lua_lessthan // already defined when compatibility is active in luaconf.h 92#ifndef lua_lessthan // already defined when compatibility is active in luaconf.h
93#define lua_lessthan( L, a, b) lua_compare( L, a, b, LUA_OPLT) 93#define lua_lessthan(L, a, b) lua_compare(L, a, b, LUA_OPLT)
94#endif // lua_lessthan 94#endif // lua_lessthan
95#define luaG_registerlibfuncs( L, _funcs) luaL_setfuncs( L, _funcs, 0) 95#define luaG_registerlibfuncs(L, _funcs) luaL_setfuncs(L, _funcs, 0)
96#define lua504_dump lua_dump 96#define lua504_dump lua_dump
97#define luaL_optint(L,n,d) ((int)luaL_optinteger(L, (n), (d))) 97#define luaL_optint(L, n, d) ((int) luaL_optinteger(L, (n), (d)))
98#define LUA_ERRGCMM 666 // doesn't exist in Lua 5.4, we don't care about the actual value 98#define LUA_ERRGCMM 666 // doesn't exist in Lua 5.4, we don't care about the actual value
99 99
100#endif // LUA_VERSION_NUM == 504 100#endif // LUA_VERSION_NUM == 504