diff options
Diffstat (limited to 'src/compat.cpp')
-rw-r--r-- | src/compat.cpp | 39 |
1 files changed, 18 insertions, 21 deletions
diff --git a/src/compat.cpp b/src/compat.cpp index 73d0f6b..9f652a7 100644 --- a/src/compat.cpp +++ b/src/compat.cpp | |||
@@ -1,20 +1,17 @@ | |||
1 | /* | 1 | // ################################################################################################# |
2 | * ############################################################################################### | 2 | // ###################################### Lua 5.1 / 5.2 / 5.3 ###################################### |
3 | * ####################################### Lua 5.1/5.2/5.3 ####################################### | 3 | // ################################################################################################# |
4 | * ############################################################################################### | 4 | |
5 | */ | ||
6 | #include "compat.h" | 5 | #include "compat.h" |
7 | #include "macros_and_utils.h" | 6 | #include "macros_and_utils.h" |
8 | 7 | ||
9 | /* | 8 | // ################################################################################################# |
10 | ** Copied from Lua 5.2 loadlib.c | 9 | // ################################################################################################# |
11 | */ | ||
12 | // ################################################################################################ | ||
13 | // ################################################################################################ | ||
14 | #if LUA_VERSION_NUM == 501 | 10 | #if LUA_VERSION_NUM == 501 |
15 | // ################################################################################################ | 11 | // ################################################################################################# |
16 | // ################################################################################################ | 12 | // ################################################################################################# |
17 | 13 | ||
14 | // Copied from Lua 5.2 loadlib.c | ||
18 | static int luaL_getsubtable(lua_State* L, int idx, const char* fname) | 15 | static int luaL_getsubtable(lua_State* L, int idx, const char* fname) |
19 | { | 16 | { |
20 | lua_getfield(L, idx, fname); | 17 | lua_getfield(L, idx, fname); |
@@ -31,7 +28,7 @@ static int luaL_getsubtable(lua_State* L, int idx, const char* fname) | |||
31 | } | 28 | } |
32 | } | 29 | } |
33 | 30 | ||
34 | // ################################################################################################ | 31 | // ################################################################################################# |
35 | 32 | ||
36 | void luaL_requiref(lua_State *L, const char *modname, lua_CFunction openf, int glb) | 33 | void luaL_requiref(lua_State *L, const char *modname, lua_CFunction openf, int glb) |
37 | { | 34 | { |
@@ -50,11 +47,11 @@ void luaL_requiref(lua_State *L, const char *modname, lua_CFunction openf, int g | |||
50 | } | 47 | } |
51 | #endif // LUA_VERSION_NUM | 48 | #endif // LUA_VERSION_NUM |
52 | 49 | ||
53 | // ################################################################################################ | 50 | // ################################################################################################# |
54 | // ################################################################################################ | 51 | // ################################################################################################# |
55 | #if LUA_VERSION_NUM < 504 | 52 | #if LUA_VERSION_NUM < 504 |
56 | // ################################################################################################ | 53 | // ################################################################################################# |
57 | // ################################################################################################ | 54 | // ################################################################################################# |
58 | 55 | ||
59 | void* lua_newuserdatauv( lua_State* L, size_t sz, int nuvalue) | 56 | void* lua_newuserdatauv( lua_State* L, size_t sz, int nuvalue) |
60 | { | 57 | { |
@@ -62,13 +59,13 @@ void* lua_newuserdatauv( lua_State* L, size_t sz, int nuvalue) | |||
62 | return lua_newuserdata(L, sz); | 59 | return lua_newuserdata(L, sz); |
63 | } | 60 | } |
64 | 61 | ||
65 | // ################################################################################################ | 62 | // ################################################################################################# |
66 | 63 | ||
67 | // push on stack uservalue #n of full userdata at idx | 64 | // push on stack uservalue #n of full userdata at idx |
68 | int lua_getiuservalue(lua_State* L, int idx, int n) | 65 | int lua_getiuservalue(lua_State* L, int idx, int n) |
69 | { | 66 | { |
70 | // full userdata can have only 1 uservalue before 5.4 | 67 | // full userdata can have only 1 uservalue before 5.4 |
71 | if( n > 1) | 68 | if (n > 1) |
72 | { | 69 | { |
73 | lua_pushnil(L); | 70 | lua_pushnil(L); |
74 | return LUA_TNONE; | 71 | return LUA_TNONE; |
@@ -91,13 +88,13 @@ int lua_getiuservalue(lua_State* L, int idx, int n) | |||
91 | return lua_type(L, -1); | 88 | return lua_type(L, -1); |
92 | } | 89 | } |
93 | 90 | ||
94 | // ################################################################################################ | 91 | // ################################################################################################# |
95 | 92 | ||
96 | // Pops a value from the stack and sets it as the new n-th user value associated to the full userdata at the given index. | 93 | // Pops a value from the stack and sets it as the new n-th user value associated to the full userdata at the given index. |
97 | // Returns 0 if the userdata does not have that value. | 94 | // Returns 0 if the userdata does not have that value. |
98 | int lua_setiuservalue(lua_State* L, int idx, int n) | 95 | int lua_setiuservalue(lua_State* L, int idx, int n) |
99 | { | 96 | { |
100 | if( n > 1 | 97 | if (n > 1 |
101 | #if LUA_VERSION_NUM == 501 | 98 | #if LUA_VERSION_NUM == 501 |
102 | || lua_type(L, -1) != LUA_TTABLE | 99 | || lua_type(L, -1) != LUA_TTABLE |
103 | #endif | 100 | #endif |