aboutsummaryrefslogtreecommitdiff
path: root/src/compat.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/compat.cpp')
-rw-r--r--src/compat.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/compat.cpp b/src/compat.cpp
index 9807390..73d0f6b 100644
--- a/src/compat.cpp
+++ b/src/compat.cpp
@@ -15,7 +15,7 @@
15// ################################################################################################ 15// ################################################################################################
16// ################################################################################################ 16// ################################################################################################
17 17
18[[nodiscard]] static int luaL_getsubtable(lua_State* L, int idx, const char* fname) 18static int luaL_getsubtable(lua_State* L, int idx, const char* fname)
19{ 19{
20 lua_getfield(L, idx, fname); 20 lua_getfield(L, idx, fname);
21 if (lua_istable(L, -1)) 21 if (lua_istable(L, -1))
@@ -38,7 +38,7 @@ void luaL_requiref(lua_State *L, const char *modname, lua_CFunction openf, int g
38 lua_pushcfunction(L, openf); 38 lua_pushcfunction(L, openf);
39 lua_pushstring(L, modname); /* argument to open function */ 39 lua_pushstring(L, modname); /* argument to open function */
40 lua_call(L, 1, 1); /* open module */ 40 lua_call(L, 1, 1); /* open module */
41 std::ignore = luaL_getsubtable(L, LUA_REGISTRYINDEX, LUA_LOADED_TABLE); 41 luaL_getsubtable(L, LUA_REGISTRYINDEX, LUA_LOADED_TABLE);
42 lua_pushvalue(L, -2); /* make copy of module (call result) */ 42 lua_pushvalue(L, -2); /* make copy of module (call result) */
43 lua_setfield(L, -2, modname); /* _LOADED[modname] = module */ 43 lua_setfield(L, -2, modname); /* _LOADED[modname] = module */
44 lua_pop(L, 1); /* remove _LOADED table */ 44 lua_pop(L, 1); /* remove _LOADED table */
@@ -93,7 +93,8 @@ int lua_getiuservalue(lua_State* L, int idx, int n)
93 93
94// ################################################################################################ 94// ################################################################################################
95 95
96// pop stack top, sets it a uservalue #n of full userdata at idx 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.
97// Returns 0 if the userdata does not have that value.
97int lua_setiuservalue(lua_State* L, int idx, int n) 98int lua_setiuservalue(lua_State* L, int idx, int n)
98{ 99{
99 if( n > 1 100 if( n > 1
@@ -106,7 +107,7 @@ int lua_setiuservalue(lua_State* L, int idx, int n)
106 return 0; 107 return 0;
107 } 108 }
108 109
109 std::ignore = lua_setuservalue(L, idx); 110 lua_setuservalue(L, idx);
110 return 1; // I guess anything non-0 is ok 111 return 1; // I guess anything non-0 is ok
111} 112}
112 113