aboutsummaryrefslogtreecommitdiff
path: root/src/compat.cpp
diff options
context:
space:
mode:
authorBenoit Germain <benoit.germain@ubisoft.com>2024-05-03 11:25:07 +0200
committerBenoit Germain <benoit.germain@ubisoft.com>2024-05-03 11:25:07 +0200
commit4995040204ca27b13ed4e52ad01d76111ae6b081 (patch)
treed4b78ee5382918c76a653d0483e904f1378404e6 /src/compat.cpp
parenta2824ef0c87034d535d3b12e6d582dfcf2265f27 (diff)
downloadlanes-4995040204ca27b13ed4e52ad01d76111ae6b081.tar.gz
lanes-4995040204ca27b13ed4e52ad01d76111ae6b081.tar.bz2
lanes-4995040204ca27b13ed4e52ad01d76111ae6b081.zip
Some code factorization
Diffstat (limited to 'src/compat.cpp')
-rw-r--r--src/compat.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/compat.cpp b/src/compat.cpp
index 6ceed8f..1d38917 100644
--- a/src/compat.cpp
+++ b/src/compat.cpp
@@ -7,17 +7,17 @@
7 7
8// ################################################################################################# 8// #################################################################################################
9 9
10// a small helper to obtain the "package" module table from the registry instead of relying on the presence of _G.package 10// a small helper to obtain a module's table from the registry instead of relying on the presence of _G["<name>"]
11int luaG_getpackage(lua_State* L_) 11LuaType luaG_getmodule(lua_State* L_, char const* name_)
12{ 12{
13 STACK_CHECK_START_REL(L_, 0); 13 STACK_CHECK_START_REL(L_, 0);
14 int type{ lua503_getfield(L_, LUA_REGISTRYINDEX, LUA_LOADED_TABLE) }; // L_: _R._LOADED|nil 14 LuaType type{ static_cast<LuaType>(lua503_getfield(L_, LUA_REGISTRYINDEX, LUA_LOADED_TABLE)) };// L_: _R._LOADED|nil
15 if (type != LUA_TTABLE) { // L_: _R._LOADED|nil 15 if (type != LuaType::TABLE) { // L_: _R._LOADED|nil
16 STACK_CHECK(L_, 1); 16 STACK_CHECK(L_, 1);
17 return type; 17 return type;
18 } 18 }
19 type = lua503_getfield(L_, -1, LUA_LOADLIBNAME); // L_: _R._LOADED package|nil 19 type = static_cast<LuaType>(lua503_getfield(L_, -1, name_)); // L_: _R._LOADED {module}|nil
20 lua_remove(L_, -2); // L_: package|nil 20 lua_remove(L_, -2); // L_: {module}|nil
21 STACK_CHECK(L_, 1); 21 STACK_CHECK(L_, 1);
22 return type; 22 return type;
23} 23}