diff options
| author | Benoit Germain <benoit.germain@ubisoft.com> | 2024-06-26 12:16:07 +0200 |
|---|---|---|
| committer | Benoit Germain <benoit.germain@ubisoft.com> | 2024-06-26 12:16:07 +0200 |
| commit | 1029bf5bcc7c2bb506ddc02a78a12c6993680413 (patch) | |
| tree | 423d5d8c76899550f795a53247150ec89d0fb573 /src | |
| parent | 57176e9b135b037fd33b8291d12416b9485b759b (diff) | |
| download | lanes-1029bf5bcc7c2bb506ddc02a78a12c6993680413.tar.gz lanes-1029bf5bcc7c2bb506ddc02a78a12c6993680413.tar.bz2 lanes-1029bf5bcc7c2bb506ddc02a78a12c6993680413.zip | |
Fix (harmless) bad internal usage of luaopen_lanes_core
Diffstat (limited to 'src')
| -rw-r--r-- | src/state.cpp | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/src/state.cpp b/src/state.cpp index b50d135..322def8 100644 --- a/src/state.cpp +++ b/src/state.cpp | |||
| @@ -46,15 +46,6 @@ namespace { | |||
| 46 | // ############################################################################################# | 46 | // ############################################################################################# |
| 47 | // ############################################################################################# | 47 | // ############################################################################################# |
| 48 | 48 | ||
| 49 | [[nodiscard]] static int require_lanes_core(lua_State* const L_) | ||
| 50 | { | ||
| 51 | // leaves a copy of 'lanes.core' module table on the stack | ||
| 52 | luaL_requiref(L_, kLanesCoreLibName, luaopen_lanes_core, 0); | ||
| 53 | return 1; | ||
| 54 | } | ||
| 55 | |||
| 56 | // ############################################################################################# | ||
| 57 | |||
| 58 | namespace local { | 49 | namespace local { |
| 59 | static luaL_Reg const sLibs[] = { | 50 | static luaL_Reg const sLibs[] = { |
| 60 | { "base", nullptr }, // ignore "base" is always valid, but opened separately | 51 | { "base", nullptr }, // ignore "base" is always valid, but opened separately |
| @@ -89,7 +80,7 @@ namespace { | |||
| 89 | { LUA_JITLIBNAME, luaopen_jit }, | 80 | { LUA_JITLIBNAME, luaopen_jit }, |
| 90 | #endif // LUAJIT_FLAVOR() != 0 | 81 | #endif // LUAJIT_FLAVOR() != 0 |
| 91 | 82 | ||
| 92 | { kLanesCoreLibName, require_lanes_core } // So that we can open it like any base library (possible since we have access to the init function) | 83 | { kLanesCoreLibName, luaopen_lanes_core } // So that we can open it like any base library (possible since we have access to the init function) |
| 93 | }; | 84 | }; |
| 94 | 85 | ||
| 95 | } // namespace local | 86 | } // namespace local |
| @@ -108,10 +99,10 @@ namespace { | |||
| 108 | DEBUGSPEW_CODE(DebugSpew(Universe::Get(L_)) << "opening '" << _name << "' library" << std::endl); | 99 | DEBUGSPEW_CODE(DebugSpew(Universe::Get(L_)) << "opening '" << _name << "' library" << std::endl); |
| 109 | STACK_CHECK_START_REL(L_, 0); | 100 | STACK_CHECK_START_REL(L_, 0); |
| 110 | // open the library as if through require(), and create a global as well if necessary (the library table is left on the stack) | 101 | // open the library as if through require(), and create a global as well if necessary (the library table is left on the stack) |
| 111 | bool const isLanesCore{ _libfunc == require_lanes_core }; // don't want to create a global for "lanes.core" | 102 | bool const _isLanesCore{ _libfunc == luaopen_lanes_core }; // don't want to create a global for "lanes.core" |
| 112 | luaL_requiref(L_, _name.data(), _libfunc, !isLanesCore); // L_: {lib} | 103 | luaL_requiref(L_, _name.data(), _libfunc, !_isLanesCore); // L_: {lib} |
| 113 | // lanes.core doesn't declare a global, so scan it here and now | 104 | // lanes.core doesn't declare a global, so scan it here and now |
| 114 | if (isLanesCore) { | 105 | if (_isLanesCore) { |
| 115 | tools::PopulateFuncLookupTable(L_, -1, _name); | 106 | tools::PopulateFuncLookupTable(L_, -1, _name); |
| 116 | } | 107 | } |
| 117 | lua_pop(L_, 1); // L_: | 108 | lua_pop(L_, 1); // L_: |
