diff options
Diffstat (limited to 'src/compat.cpp')
-rw-r--r-- | src/compat.cpp | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/src/compat.cpp b/src/compat.cpp index 41a206a..591e19f 100644 --- a/src/compat.cpp +++ b/src/compat.cpp | |||
@@ -12,35 +12,35 @@ | |||
12 | // ################################################################################################# | 12 | // ################################################################################################# |
13 | 13 | ||
14 | // Copied from Lua 5.2 loadlib.c | 14 | // Copied from Lua 5.2 loadlib.c |
15 | 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_) |
16 | { | 16 | { |
17 | lua_getfield(L_, idx, fname); | 17 | lua_getfield(L_, idx_, fname_); |
18 | if (lua_istable(L_, -1)) | 18 | if (lua_istable(L_, -1)) |
19 | return 1; /* table already there */ | 19 | return 1; /* table already there */ |
20 | else { | 20 | else { |
21 | lua_pop(L_, 1); /* remove previous result */ | 21 | lua_pop(L_, 1); /* remove previous result */ |
22 | idx = lua_absindex(L_, idx); | 22 | idx_ = lua_absindex(L_, idx_); |
23 | lua_newtable(L_); | 23 | lua_newtable(L_); |
24 | lua_pushvalue(L_, -1); /* copy to be left at top */ | 24 | lua_pushvalue(L_, -1); /* copy to be left at top */ |
25 | lua_setfield(L_, idx, fname); /* assign new table to field */ | 25 | lua_setfield(L_, idx_, fname_); /* assign new table to field */ |
26 | return 0; /* false, because did not find table there */ | 26 | return 0; /* false, because did not find table there */ |
27 | } | 27 | } |
28 | } | 28 | } |
29 | 29 | ||
30 | // ################################################################################################# | 30 | // ################################################################################################# |
31 | 31 | ||
32 | void luaL_requiref(lua_State* L_, const char* modname, lua_CFunction openf, int glb) | 32 | void luaL_requiref(lua_State* L_, const char* modname_, lua_CFunction openf_, int glb_) |
33 | { | 33 | { |
34 | lua_pushcfunction(L_, openf); | 34 | lua_pushcfunction(L_, openf_); |
35 | lua_pushstring(L_, modname); /* argument to open function */ | 35 | lua_pushstring(L_, modname_); /* argument to open function */ |
36 | lua_call(L_, 1, 1); /* open module */ | 36 | lua_call(L_, 1, 1); /* open module */ |
37 | luaL_getsubtable(L_, LUA_REGISTRYINDEX, LUA_LOADED_TABLE); | 37 | luaL_getsubtable(L_, LUA_REGISTRYINDEX, LUA_LOADED_TABLE); |
38 | lua_pushvalue(L_, -2); /* make copy of module (call result) */ | 38 | lua_pushvalue(L_, -2); /* make copy of module (call result) */ |
39 | lua_setfield(L_, -2, modname); /* _LOADED[modname] = module */ | 39 | lua_setfield(L_, -2, modname_); /* _LOADED[modname] = module */ |
40 | lua_pop(L_, 1); /* remove _LOADED table */ | 40 | lua_pop(L_, 1); /* remove _LOADED table */ |
41 | if (glb) { | 41 | if (glb_) { |
42 | lua_pushvalue(L_, -1); /* copy of 'mod' */ | 42 | lua_pushvalue(L_, -1); /* copy of 'mod' */ |
43 | lua_setglobal(L_, modname); /* _G[modname] = module */ | 43 | lua_setglobal(L_, modname_); /* _G[modname] = module */ |
44 | } | 44 | } |
45 | } | 45 | } |
46 | #endif // LUA_VERSION_NUM | 46 | #endif // LUA_VERSION_NUM |
@@ -51,23 +51,23 @@ void luaL_requiref(lua_State* L_, const char* modname, lua_CFunction openf, int | |||
51 | // ################################################################################################# | 51 | // ################################################################################################# |
52 | // ################################################################################################# | 52 | // ################################################################################################# |
53 | 53 | ||
54 | void* lua_newuserdatauv(lua_State* L_, size_t sz, int nuvalue) | 54 | void* lua_newuserdatauv(lua_State* L_, size_t sz_, int nuvalue_) |
55 | { | 55 | { |
56 | LUA_ASSERT(L_, nuvalue <= 1); | 56 | LUA_ASSERT(L_, nuvalue_ <= 1); |
57 | return lua_newuserdata(L_, sz); | 57 | return lua_newuserdata(L_, sz_); |
58 | } | 58 | } |
59 | 59 | ||
60 | // ################################################################################################# | 60 | // ################################################################################################# |
61 | 61 | ||
62 | // push on stack uservalue #n of full userdata at idx | 62 | // push on stack uservalue #n of full userdata at idx |
63 | int lua_getiuservalue(lua_State* L_, int idx, int n) | 63 | int lua_getiuservalue(lua_State* L_, int idx_, int n_) |
64 | { | 64 | { |
65 | // full userdata can have only 1 uservalue before 5.4 | 65 | // full userdata can have only 1 uservalue before 5.4 |
66 | if (n > 1) { | 66 | if (n_ > 1) { |
67 | lua_pushnil(L_); | 67 | lua_pushnil(L_); |
68 | return LUA_TNONE; | 68 | return LUA_TNONE; |
69 | } | 69 | } |
70 | lua_getuservalue(L_, idx); | 70 | lua_getuservalue(L_, idx_); |
71 | 71 | ||
72 | #if LUA_VERSION_NUM == 501 | 72 | #if LUA_VERSION_NUM == 501 |
73 | /* default environment is not a nil (see lua_getfenv) */ | 73 | /* default environment is not a nil (see lua_getfenv) */ |
@@ -88,9 +88,9 @@ int lua_getiuservalue(lua_State* L_, int idx, int n) | |||
88 | 88 | ||
89 | // 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. | 89 | // 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. |
90 | // Returns 0 if the userdata does not have that value. | 90 | // Returns 0 if the userdata does not have that value. |
91 | int lua_setiuservalue(lua_State* L_, int idx, int n) | 91 | int lua_setiuservalue(lua_State* L_, int idx_, int n_) |
92 | { | 92 | { |
93 | if (n > 1 | 93 | if (n_ > 1 |
94 | #if LUA_VERSION_NUM == 501 | 94 | #if LUA_VERSION_NUM == 501 |
95 | || lua_type(L_, -1) != LUA_TTABLE | 95 | || lua_type(L_, -1) != LUA_TTABLE |
96 | #endif | 96 | #endif |
@@ -99,7 +99,7 @@ int lua_setiuservalue(lua_State* L_, int idx, int n) | |||
99 | return 0; | 99 | return 0; |
100 | } | 100 | } |
101 | 101 | ||
102 | lua_setuservalue(L_, idx); | 102 | lua_setuservalue(L_, idx_); |
103 | return 1; // I guess anything non-0 is ok | 103 | return 1; // I guess anything non-0 is ok |
104 | } | 104 | } |
105 | 105 | ||