diff options
Diffstat (limited to 'src/state.cpp')
-rw-r--r-- | src/state.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/state.cpp b/src/state.cpp index 96f7268..6d27256 100644 --- a/src/state.cpp +++ b/src/state.cpp | |||
@@ -42,7 +42,7 @@ THE SOFTWARE. | |||
42 | 42 | ||
43 | // ################################################################################################# | 43 | // ################################################################################################# |
44 | 44 | ||
45 | static constexpr char const* kOnStateCreate{ "on_state_create" }; // update lanes.lua if the name changes! | 45 | static constexpr std::string_view kOnStateCreate{ "on_state_create" }; // update lanes.lua if the name changes! |
46 | 46 | ||
47 | // ################################################################################################# | 47 | // ################################################################################################# |
48 | // ################################################################################################# | 48 | // ################################################################################################# |
@@ -185,7 +185,7 @@ namespace state { | |||
185 | std::string_view const _stateType{ mode_ == LookupMode::LaneBody ? "lane" : "keeper" }; | 185 | std::string_view const _stateType{ mode_ == LookupMode::LaneBody ? "lane" : "keeper" }; |
186 | std::ignore = luaG_pushstring(L_, _stateType); // L_: on_state_create() "<type>" | 186 | std::ignore = luaG_pushstring(L_, _stateType); // L_: on_state_create() "<type>" |
187 | if (lua_pcall(L_, 1, 0, 0) != LUA_OK) { | 187 | if (lua_pcall(L_, 1, 0, 0) != LUA_OK) { |
188 | raise_luaL_error(from_, "%s failed: \"%s\"", kOnStateCreate, lua_isstring(L_, -1) ? lua_tostring(L_, -1) : luaG_typename(L_, -1).data()); | 188 | raise_luaL_error(from_, "%s failed: \"%s\"", kOnStateCreate.data(), lua_isstring(L_, -1) ? luaG_tostring(L_, -1).data() : luaG_typename(L_, -1).data()); |
189 | } | 189 | } |
190 | STACK_CHECK(L_, 0); | 190 | STACK_CHECK(L_, 0); |
191 | } | 191 | } |
@@ -235,12 +235,12 @@ namespace state { | |||
235 | // make sure the function doesn't have upvalues | 235 | // make sure the function doesn't have upvalues |
236 | char const* _upname{ lua_getupvalue(L_, -1, 1) }; // L_: settings on_state_create upval? | 236 | char const* _upname{ lua_getupvalue(L_, -1, 1) }; // L_: settings on_state_create upval? |
237 | if (_upname != nullptr) { // should be "" for C functions with upvalues if any | 237 | if (_upname != nullptr) { // should be "" for C functions with upvalues if any |
238 | raise_luaL_error(L_, "%s shouldn't have upvalues", kOnStateCreate); | 238 | raise_luaL_error(L_, "%s shouldn't have upvalues", kOnStateCreate.data()); |
239 | } | 239 | } |
240 | // remove this C function from the config table so that it doesn't cause problems | 240 | // remove this C function from the config table so that it doesn't cause problems |
241 | // when we transfer the config table in newly created Lua states | 241 | // when we transfer the config table in newly created Lua states |
242 | lua_pushnil(L_); // L_: settings on_state_create nil | 242 | lua_pushnil(L_); // L_: settings on_state_create nil |
243 | lua_setfield(L_, -3, kOnStateCreate); // L_: settings on_state_create | 243 | luaG_setfield(L_, -3, kOnStateCreate); // L_: settings on_state_create |
244 | } else { | 244 | } else { |
245 | // optim: store marker saying we have such a function in the config table | 245 | // optim: store marker saying we have such a function in the config table |
246 | U_->onStateCreateFunc = reinterpret_cast<lua_CFunction>(InitializeOnStateCreate); | 246 | U_->onStateCreateFunc = reinterpret_cast<lua_CFunction>(InitializeOnStateCreate); |