diff options
author | Benoit Germain <benoit.germain@ubisoft.com> | 2024-06-14 17:00:01 +0200 |
---|---|---|
committer | Benoit Germain <benoit.germain@ubisoft.com> | 2024-06-14 17:00:01 +0200 |
commit | 7d65cec0385b6dcaf3346d3f862efb5eb07ad14a (patch) | |
tree | 230de536a854b62017c54d3dffdd147f68bda0e4 | |
parent | 28ffb99fe2d9a4df1c60d35a39de47992076167f (diff) | |
download | lanes-7d65cec0385b6dcaf3346d3f862efb5eb07ad14a.tar.gz lanes-7d65cec0385b6dcaf3346d3f862efb5eb07ad14a.tar.bz2 lanes-7d65cec0385b6dcaf3346d3f862efb5eb07ad14a.zip |
Handle std::ignore cases that should not be ignored
-rw-r--r-- | src/cancel.cpp | 10 | ||||
-rw-r--r-- | src/intercopycontext.cpp | 5 | ||||
-rw-r--r-- | src/state.cpp | 7 |
3 files changed, 14 insertions, 8 deletions
diff --git a/src/cancel.cpp b/src/cancel.cpp index 4f04857..a62fa96 100644 --- a/src/cancel.cpp +++ b/src/cancel.cpp | |||
@@ -176,17 +176,17 @@ LUAG_FUNC(thread_cancel) | |||
176 | STACK_CHECK_START_REL(L_, 0); | 176 | STACK_CHECK_START_REL(L_, 0); |
177 | switch (_lane->cancel(_op, _hook_count, _until, _wake_lane)) { | 177 | switch (_lane->cancel(_op, _hook_count, _until, _wake_lane)) { |
178 | default: // should never happen unless we added a case and forgot to handle it | 178 | default: // should never happen unless we added a case and forgot to handle it |
179 | LUA_ASSERT(L_, false); | 179 | raise_luaL_error(L_, "should not get here!"); |
180 | break; | 180 | break; |
181 | 181 | ||
182 | case CancelResult::Timeout: | 182 | case CancelResult::Timeout: |
183 | lua_pushboolean(L_, 0); // false | 183 | lua_pushboolean(L_, 0); // false |
184 | lua_pushstring(L_, "timeout"); // false "timeout" | 184 | lua_pushstring(L_, "timeout"); // false "timeout" |
185 | break; | 185 | break; |
186 | 186 | ||
187 | case CancelResult::Cancelled: | 187 | case CancelResult::Cancelled: |
188 | lua_pushboolean(L_, 1); // true | 188 | lua_pushboolean(L_, 1); // true |
189 | std::ignore = _lane->pushThreadStatus(L_); // true status | 189 | std::ignore = _lane->pushThreadStatus(L_); // true "<status>" |
190 | break; | 190 | break; |
191 | } | 191 | } |
192 | STACK_CHECK(L_, 2); | 192 | STACK_CHECK(L_, 2); |
diff --git a/src/intercopycontext.cpp b/src/intercopycontext.cpp index 285ca9b..34a1c95 100644 --- a/src/intercopycontext.cpp +++ b/src/intercopycontext.cpp | |||
@@ -913,7 +913,10 @@ LuaType InterCopyContext::processConversion() const | |||
913 | // perform the custom cloning part | 913 | // perform the custom cloning part |
914 | lua_insert(L2, -2); // L2: ... u mt | 914 | lua_insert(L2, -2); // L2: ... u mt |
915 | // __lanesclone should always exist because we wouldn't be restoring data from a userdata_clone_sentinel closure to begin with | 915 | // __lanesclone should always exist because we wouldn't be restoring data from a userdata_clone_sentinel closure to begin with |
916 | std::ignore = luaG_getfield(L2, -1, "__lanesclone"); // L2: ... u mt __lanesclone | 916 | LuaType const _funcType{ luaG_getfield(L2, -1, "__lanesclone") }; // L2: ... u mt __lanesclone |
917 | if (_funcType != LuaType::FUNCTION) { | ||
918 | raise_luaL_error(getErrL(), "INTERNAL ERROR: __lanesclone is a %s, not a function", luaG_typename(L2, _funcType).data()); | ||
919 | } | ||
917 | lua_remove(L2, -2); // L2: ... u __lanesclone | 920 | lua_remove(L2, -2); // L2: ... u __lanesclone |
918 | lua_pushlightuserdata(L2, _clone); // L2: ... u __lanesclone clone | 921 | lua_pushlightuserdata(L2, _clone); // L2: ... u __lanesclone clone |
919 | lua_pushlightuserdata(L2, _source); // L2: ... u __lanesclone clone source | 922 | lua_pushlightuserdata(L2, _source); // L2: ... u __lanesclone clone source |
diff --git a/src/state.cpp b/src/state.cpp index 18c5ae2..267554e 100644 --- a/src/state.cpp +++ b/src/state.cpp | |||
@@ -167,7 +167,7 @@ namespace state { | |||
167 | DEBUGSPEW_CODE(DebugSpew(U_) << "calling on_state_create()" << std::endl); | 167 | DEBUGSPEW_CODE(DebugSpew(U_) << "calling on_state_create()" << std::endl); |
168 | if (U_->onStateCreateFunc != reinterpret_cast<lua_CFunction>(InitializeOnStateCreate)) { | 168 | if (U_->onStateCreateFunc != reinterpret_cast<lua_CFunction>(InitializeOnStateCreate)) { |
169 | // C function: recreate a closure in the new state, bypassing the lookup scheme | 169 | // C function: recreate a closure in the new state, bypassing the lookup scheme |
170 | lua_pushcfunction(L_, U_->onStateCreateFunc); // on_state_create() | 170 | lua_pushcfunction(L_, U_->onStateCreateFunc); // on_state_create() |
171 | } else { // Lua function located in the config table, copied when we opened "lanes.core" | 171 | } else { // Lua function located in the config table, copied when we opened "lanes.core" |
172 | if (mode_ != LookupMode::LaneBody) { | 172 | if (mode_ != LookupMode::LaneBody) { |
173 | // if attempting to call in a keeper state, do nothing because the function doesn't exist there | 173 | // if attempting to call in a keeper state, do nothing because the function doesn't exist there |
@@ -177,7 +177,10 @@ namespace state { | |||
177 | } | 177 | } |
178 | kConfigRegKey.pushValue(L_); // L_: {} | 178 | kConfigRegKey.pushValue(L_); // L_: {} |
179 | STACK_CHECK(L_, 1); | 179 | STACK_CHECK(L_, 1); |
180 | std::ignore = luaG_getfield(L_, -1, kOnStateCreate); // L_: {} on_state_create() | 180 | LuaType const _funcType{ luaG_getfield(L_, -1, kOnStateCreate) }; // L_: {} on_state_create() |
181 | if (_funcType != LuaType::FUNCTION) { | ||
182 | raise_luaL_error(L_, "INTERNAL ERROR: %s is a %s, not a function", kOnStateCreate.data(), luaG_typename(L_, _funcType).data()); | ||
183 | } | ||
181 | lua_remove(L_, -2); // L_: on_state_create() | 184 | lua_remove(L_, -2); // L_: on_state_create() |
182 | } | 185 | } |
183 | STACK_CHECK(L_, 1); | 186 | STACK_CHECK(L_, 1); |