aboutsummaryrefslogtreecommitdiff
path: root/src/keeper.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/keeper.cpp')
-rw-r--r--src/keeper.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/keeper.cpp b/src/keeper.cpp
index bea91a7..7deb2b3 100644
--- a/src/keeper.cpp
+++ b/src/keeper.cpp
@@ -75,7 +75,7 @@ class KeyUD
75 LindaLimit limit{ -1 }; 75 LindaLimit limit{ -1 };
76 76
77 // a fifo full userdata has one uservalue, the table that holds the actual fifo contents 77 // a fifo full userdata has one uservalue, the table that holds the actual fifo contents
78 [[nodiscard]] static void* operator new([[maybe_unused]] size_t size_, KeeperState L_) noexcept { return luaG_newuserdatauv<KeyUD>(L_, 1); } 78 [[nodiscard]] static void* operator new([[maybe_unused]] size_t size_, KeeperState L_) noexcept { return luaG_newuserdatauv<KeyUD>(L_, UserValueCount{ 1 }); }
79 // always embedded somewhere else or "in-place constructed" as a full userdata 79 // always embedded somewhere else or "in-place constructed" as a full userdata
80 // can't actually delete the operator because the compiler generates stack unwinding code that could call it in case of exception 80 // can't actually delete the operator because the compiler generates stack unwinding code that could call it in case of exception
81 static void operator delete([[maybe_unused]] void* p_, [[maybe_unused]] KeeperState L_) { LUA_ASSERT(L_, !"should never be called"); } 81 static void operator delete([[maybe_unused]] void* p_, [[maybe_unused]] KeeperState L_) { LUA_ASSERT(L_, !"should never be called"); }
@@ -275,7 +275,7 @@ bool KeyUD::reset(KeeperState const K_)
275 bool const _wasFull{ (limit > 0) && (count >= limit) }; 275 bool const _wasFull{ (limit > 0) && (count >= limit) };
276 // empty the KeyUD: replace uservalue with a virgin table, reset counters, but leave limit unchanged! 276 // empty the KeyUD: replace uservalue with a virgin table, reset counters, but leave limit unchanged!
277 // if we have an actual limit, use it to preconfigure the table 277 // if we have an actual limit, use it to preconfigure the table
278 lua_createtable(K_, (limit <= 0) ? 0 : limit, 0); // K_: KeysDB key val... KeyUD {} 278 lua_createtable(K_, (limit <= 0) ? 0 : limit.value(), 0); // K_: KeysDB key val... KeyUD {}
279 lua_setiuservalue(K_, StackIndex{ -2 }, kContentsTableIndex); // K_: KeysDB key val... KeyUD 279 lua_setiuservalue(K_, StackIndex{ -2 }, kContentsTableIndex); // K_: KeysDB key val... KeyUD
280 first = 1; 280 first = 1;
281 count = 0; 281 count = 0;
@@ -646,7 +646,7 @@ KeeperCallResult keeper_call(KeeperState const K_, keeper_api_t const func_, lua
646 lua_pushlightuserdata(K_, linda_); // L: ... args... K_: func_ linda 646 lua_pushlightuserdata(K_, linda_); // L: ... args... K_: func_ linda
647 if ( 647 if (
648 (_args == 0) || 648 (_args == 0) ||
649 (InterCopyContext{ linda_->U, DestState{ K_ }, SourceState{ L_ }, {}, {}, {}, LookupMode::ToKeeper, {} }.interCopy(_args) == InterCopyResult::Success) 649 (InterCopyContext{ linda_->U, DestState{ K_.value() }, SourceState{ L_ }, {}, {}, {}, LookupMode::ToKeeper, {} }.interCopy(_args) == InterCopyResult::Success)
650 ) { // L: ... args... K_: func_ linda args... 650 ) { // L: ... args... K_: func_ linda args...
651 lua_call(K_, 1 + _args, LUA_MULTRET); // L: ... args... K_: result... 651 lua_call(K_, 1 + _args, LUA_MULTRET); // L: ... args... K_: result...
652 int const _retvals{ lua_gettop(K_) - _top_K }; 652 int const _retvals{ lua_gettop(K_) - _top_K };
@@ -656,7 +656,7 @@ KeeperCallResult keeper_call(KeeperState const K_, keeper_api_t const func_, lua
656 // when attempting to grab the mutex again (WINVER <= 0x400 does this, but locks just fine, I don't know about pthread) 656 // when attempting to grab the mutex again (WINVER <= 0x400 does this, but locks just fine, I don't know about pthread)
657 if ( 657 if (
658 (_retvals == 0) || 658 (_retvals == 0) ||
659 (InterCopyContext{ linda_->U, DestState{ L_ }, SourceState{ K_ }, {}, {}, {}, LookupMode::FromKeeper, {} }.interMove(_retvals) == InterCopyResult::Success) 659 (InterCopyContext{ linda_->U, DestState{ L_ }, SourceState{ K_.value() }, {}, {}, {}, LookupMode::FromKeeper, {} }.interMove(_retvals) == InterCopyResult::Success)
660 ) { // L: ... args... result... K_: result... 660 ) { // L: ... args... result... K_: result...
661 _result.emplace(_retvals); 661 _result.emplace(_retvals);
662 } 662 }
@@ -721,7 +721,7 @@ void Keeper::operator delete[](void* p_, Universe* U_)
721int Keeper::PushLindaStorage(Linda& linda_, DestState const L_) 721int Keeper::PushLindaStorage(Linda& linda_, DestState const L_)
722{ 722{
723 Keeper* const _keeper{ linda_.whichKeeper() }; 723 Keeper* const _keeper{ linda_.whichKeeper() };
724 KeeperState const _K{ _keeper ? _keeper->K : KeeperState{ nullptr } }; 724 KeeperState const _K{ _keeper ? _keeper->K : KeeperState{ static_cast<lua_State*>(nullptr) } };
725 if (_K == nullptr) { 725 if (_K == nullptr) {
726 return 0; 726 return 0;
727 } 727 }
@@ -740,7 +740,7 @@ int Keeper::PushLindaStorage(Linda& linda_, DestState const L_)
740 STACK_GROW(L_, 5); 740 STACK_GROW(L_, 5);
741 STACK_CHECK_START_REL(L_, 0); 741 STACK_CHECK_START_REL(L_, 0);
742 lua_newtable(L_); // _K: KeysDB L_: out 742 lua_newtable(L_); // _K: KeysDB L_: out
743 InterCopyContext _c{ linda_.U, L_, SourceState{ _K }, {}, {}, {}, LookupMode::FromKeeper, {} }; 743 InterCopyContext _c{ linda_.U, L_, SourceState{ _K.value() }, {}, {}, {}, LookupMode::FromKeeper, {} };
744 lua_pushnil(_K); // _K: KeysDB nil L_: out 744 lua_pushnil(_K); // _K: KeysDB nil L_: out
745 while (lua_next(_K, -2)) { // _K: KeysDB key KeyUD L_: out 745 while (lua_next(_K, -2)) { // _K: KeysDB key KeyUD L_: out
746 KeyUD* const _key{ KeyUD::GetPtr(_K, kIdxTop) }; 746 KeyUD* const _key{ KeyUD::GetPtr(_K, kIdxTop) };
@@ -810,7 +810,7 @@ void Keepers::close()
810 } 810 }
811 811
812 auto _closeOneKeeper = [](Keeper& keeper_) { 812 auto _closeOneKeeper = [](Keeper& keeper_) {
813 lua_State* const _K{ std::exchange(keeper_.K, KeeperState{ nullptr }) }; 813 lua_State* const _K{ std::exchange(keeper_.K, KeeperState{ static_cast<lua_State*>(nullptr) }) };
814 if (_K) { 814 if (_K) {
815 lua_close(_K); 815 lua_close(_K);
816 } 816 }
@@ -928,7 +928,7 @@ void Keepers::initialize(Universe& U_, lua_State* L_, size_t const nbKeepers_, i
928 // copy package.path and package.cpath from the source state 928 // copy package.path and package.cpath from the source state
929 if (luaG_getmodule(L, LUA_LOADLIBNAME) != LuaType::NIL) { // L_: settings package _K: 929 if (luaG_getmodule(L, LUA_LOADLIBNAME) != LuaType::NIL) { // L_: settings package _K:
930 // when copying with mode LookupMode::ToKeeper, error message is pushed at the top of the stack, not raised immediately 930 // when copying with mode LookupMode::ToKeeper, error message is pushed at the top of the stack, not raised immediately
931 InterCopyContext _c{ U, DestState{ _K }, SourceState{ L }, {}, SourceIndex{ luaG_absindex(L, kIdxTop) }, {}, LookupMode::ToKeeper, {} }; 931 InterCopyContext _c{ U, DestState{ _K.value() }, SourceState{ L }, {}, SourceIndex{ luaG_absindex(L, kIdxTop) }, {}, LookupMode::ToKeeper, {} };
932 if (_c.interCopyPackage() != InterCopyResult::Success) { // L_: settings ... error_msg _K: 932 if (_c.interCopyPackage() != InterCopyResult::Success) { // L_: settings ... error_msg _K:
933 // if something went wrong, the error message is at the top of the stack 933 // if something went wrong, the error message is at the top of the stack
934 lua_remove(L, -2); // L_: settings error_msg 934 lua_remove(L, -2); // L_: settings error_msg