diff options
author | Benoit Germain <benoit.germain@ubisoft.com> | 2024-06-07 11:46:25 +0200 |
---|---|---|
committer | Benoit Germain <benoit.germain@ubisoft.com> | 2024-06-07 11:46:25 +0200 |
commit | ee32d4281a5e59ce81d7f38f86a49fa8ff64d2c3 (patch) | |
tree | 68c0d74ac40c6ee098abf606e3d660a862acf04f /src/state.cpp | |
parent | 35d7a6bb691d7e0564cda324b3d724caf4901545 (diff) | |
download | lanes-ee32d4281a5e59ce81d7f38f86a49fa8ff64d2c3.tar.gz lanes-ee32d4281a5e59ce81d7f38f86a49fa8ff64d2c3.tar.bz2 lanes-ee32d4281a5e59ce81d7f38f86a49fa8ff64d2c3.zip |
Boyscouting some luaG_ functions
Diffstat (limited to 'src/state.cpp')
-rw-r--r-- | src/state.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/state.cpp b/src/state.cpp index 47e31c3..cafabf1 100644 --- a/src/state.cpp +++ b/src/state.cpp | |||
@@ -183,7 +183,7 @@ namespace state { | |||
183 | STACK_CHECK(L_, 1); | 183 | STACK_CHECK(L_, 1); |
184 | // capture error and raise it in caller state | 184 | // capture error and raise it in caller 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_pushstringview(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_, luaG_type(L_, -1))); | 188 | raise_luaL_error(from_, "%s failed: \"%s\"", kOnStateCreate, lua_isstring(L_, -1) ? lua_tostring(L_, -1) : luaG_typename(L_, luaG_type(L_, -1))); |
189 | } | 189 | } |
@@ -204,7 +204,7 @@ namespace state { | |||
204 | if (U->provideAllocator != nullptr) { // we have a function we can call to obtain an allocator | 204 | if (U->provideAllocator != nullptr) { // we have a function we can call to obtain an allocator |
205 | lua_pushcclosure(from, U->provideAllocator, 0); | 205 | lua_pushcclosure(from, U->provideAllocator, 0); |
206 | lua_call(from, 0, 1); | 206 | lua_call(from, 0, 1); |
207 | AllocatorDefinition* const _def{ lua_tofulluserdata<AllocatorDefinition>(from, -1) }; | 207 | AllocatorDefinition* const _def{ luaG_tofulluserdata<AllocatorDefinition>(from, -1) }; |
208 | lua_State* const _L{ lua_newstate(_def->allocF, _def->allocUD) }; | 208 | lua_State* const _L{ lua_newstate(_def->allocF, _def->allocUD) }; |
209 | lua_pop(from, 1); | 209 | lua_pop(from, 1); |
210 | return _L; | 210 | return _L; |
@@ -364,19 +364,19 @@ namespace state { | |||
364 | kLookupRegKey.pushValue(_L); // L: {} | 364 | kLookupRegKey.pushValue(_L); // L: {} |
365 | lua_pushnil(_L); // L: {} nil | 365 | lua_pushnil(_L); // L: {} nil |
366 | while (lua_next(_L, -2)) { // L: {} k v | 366 | while (lua_next(_L, -2)) { // L: {} k v |
367 | std::ignore = luaG_pushstringview(_L, "["); // L: {} k v "[" | 367 | std::ignore = luaG_pushstring(_L, "["); // L: {} k v "[" |
368 | 368 | ||
369 | lua_getglobal(_L, "tostring"); // L: {} k v "[" tostring | 369 | lua_getglobal(_L, "tostring"); // L: {} k v "[" tostring |
370 | lua_pushvalue(_L, -4); // L: {} k v "[" tostring k | 370 | lua_pushvalue(_L, -4); // L: {} k v "[" tostring k |
371 | lua_call(_L, 1, 1); // L: {} k v "[" 'k' | 371 | lua_call(_L, 1, 1); // L: {} k v "[" 'k' |
372 | 372 | ||
373 | std::ignore = luaG_pushstringview(_L, "] = "); // L: {} k v "[" 'k' "] = " | 373 | std::ignore = luaG_pushstring(_L, "] = "); // L: {} k v "[" 'k' "] = " |
374 | 374 | ||
375 | lua_getglobal(_L, "tostring"); // L: {} k v "[" 'k' "] = " tostring | 375 | lua_getglobal(_L, "tostring"); // L: {} k v "[" 'k' "] = " tostring |
376 | lua_pushvalue(_L, -5); // L: {} k v "[" 'k' "] = " tostring v | 376 | lua_pushvalue(_L, -5); // L: {} k v "[" 'k' "] = " tostring v |
377 | lua_call(_L, 1, 1); // L: {} k v "[" 'k' "] = " 'v' | 377 | lua_call(_L, 1, 1); // L: {} k v "[" 'k' "] = " 'v' |
378 | lua_concat(_L, 4); // L: {} k v "[k] = v" | 378 | lua_concat(_L, 4); // L: {} k v "[k] = v" |
379 | DEBUGSPEW_CODE(DebugSpew(U_) << luaG_tostringview(_L, -1) << std::endl); | 379 | DEBUGSPEW_CODE(DebugSpew(U_) << luaG_tostring(_L, -1) << std::endl); |
380 | lua_pop(_L, 2); // L: {} k | 380 | lua_pop(_L, 2); // L: {} k |
381 | } // lua_next() // L: {} | 381 | } // lua_next() // L: {} |
382 | lua_pop(_L, 1); // L: | 382 | lua_pop(_L, 1); // L: |