diff options
Diffstat (limited to 'src/keeper.cpp')
-rw-r--r-- | src/keeper.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/keeper.cpp b/src/keeper.cpp index acb8619..7000372 100644 --- a/src/keeper.cpp +++ b/src/keeper.cpp | |||
@@ -298,10 +298,14 @@ int keeper_push_linda_storage(Linda& linda_, DestState L_) | |||
298 | KeyUD* const _key{ KeyUD::GetPtr(_K, -1) }; | 298 | KeyUD* const _key{ KeyUD::GetPtr(_K, -1) }; |
299 | _key->prepareAccess(_K, -1); // _K: KeysDB key fifo L_: out | 299 | _key->prepareAccess(_K, -1); // _K: KeysDB key fifo L_: out |
300 | lua_pushvalue(_K, -2); // _K: KeysDB key fifo key L_: out | 300 | lua_pushvalue(_K, -2); // _K: KeysDB key fifo key L_: out |
301 | std::ignore = _c.inter_move(1); // _K: KeysDB key fifo L_: out key | 301 | if (_c.interMove(1) != InterCopyResult::Success) { // _K: KeysDB key fifo L_: out key |
302 | raise_luaL_error(L_, "Internal error reading Keeper contents"); | ||
303 | } | ||
302 | STACK_CHECK(L_, 2); | 304 | STACK_CHECK(L_, 2); |
303 | lua_newtable(L_); // _K: KeysDB key fifo L_: out key keyout | 305 | lua_newtable(L_); // _K: KeysDB key fifo L_: out key keyout |
304 | std::ignore = _c.inter_move(1); // _K: KeysDB key L_: out key keyout fifo | 306 | if (_c.interMove(1) != InterCopyResult::Success) { // _K: KeysDB key L_: out key keyout fifo |
307 | raise_luaL_error(L_, "Internal error reading Keeper contents"); | ||
308 | } | ||
305 | // keyout.first | 309 | // keyout.first |
306 | lua_pushinteger(L_, _key->first); // _K: KeysDB key L_: out key keyout fifo first | 310 | lua_pushinteger(L_, _key->first); // _K: KeysDB key L_: out key keyout fifo first |
307 | STACK_CHECK(L_, 5); | 311 | STACK_CHECK(L_, 5); |
@@ -642,7 +646,7 @@ KeeperCallResult keeper_call(KeeperState K_, keeper_api_t func_, lua_State* L_, | |||
642 | lua_pushlightuserdata(K_, linda_); // L: ... args... K_: func_ linda | 646 | lua_pushlightuserdata(K_, linda_); // L: ... args... K_: func_ linda |
643 | if ( | 647 | if ( |
644 | (_args == 0) || | 648 | (_args == 0) || |
645 | (InterCopyContext{ linda_->U, DestState{ K_ }, SourceState{ L_ }, {}, {}, {}, LookupMode::ToKeeper, {} }.inter_copy(_args) == InterCopyResult::Success) | 649 | (InterCopyContext{ linda_->U, DestState{ K_ }, SourceState{ L_ }, {}, {}, {}, LookupMode::ToKeeper, {} }.interCopy(_args) == InterCopyResult::Success) |
646 | ) { // L: ... args... K_: func_ linda args... | 650 | ) { // L: ... args... K_: func_ linda args... |
647 | lua_call(K_, 1 + _args, LUA_MULTRET); // L: ... args... K_: result... | 651 | lua_call(K_, 1 + _args, LUA_MULTRET); // L: ... args... K_: result... |
648 | int const _retvals{ lua_gettop(K_) - _top_K }; | 652 | int const _retvals{ lua_gettop(K_) - _top_K }; |
@@ -652,7 +656,7 @@ KeeperCallResult keeper_call(KeeperState K_, keeper_api_t func_, lua_State* L_, | |||
652 | // 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) |
653 | if ( | 657 | if ( |
654 | (_retvals == 0) || | 658 | (_retvals == 0) || |
655 | (InterCopyContext{ linda_->U, DestState{ L_ }, SourceState{ K_ }, {}, {}, {}, LookupMode::FromKeeper, {} }.inter_move(_retvals) == InterCopyResult::Success) | 659 | (InterCopyContext{ linda_->U, DestState{ L_ }, SourceState{ K_ }, {}, {}, {}, LookupMode::FromKeeper, {} }.interMove(_retvals) == InterCopyResult::Success) |
656 | ) { // L: ... args... result... K_: result... | 660 | ) { // L: ... args... result... K_: result... |
657 | _result.emplace(_retvals); | 661 | _result.emplace(_retvals); |
658 | } | 662 | } |
@@ -848,7 +852,7 @@ void Keepers::initialize(Universe& U_, lua_State* L_, int const nbKeepers_, int | |||
848 | if (luaG_getmodule(L, LUA_LOADLIBNAME) != LuaType::NIL) { // L_: settings package _K: | 852 | if (luaG_getmodule(L, LUA_LOADLIBNAME) != LuaType::NIL) { // L_: settings package _K: |
849 | // when copying with mode LookupMode::ToKeeper, error message is pushed at the top of the stack, not raised immediately | 853 | // when copying with mode LookupMode::ToKeeper, error message is pushed at the top of the stack, not raised immediately |
850 | InterCopyContext _c{ U, DestState{ _K }, SourceState{ L }, {}, SourceIndex{ luaG_absindex(L, -1) }, {}, LookupMode::ToKeeper, {} }; | 854 | InterCopyContext _c{ U, DestState{ _K }, SourceState{ L }, {}, SourceIndex{ luaG_absindex(L, -1) }, {}, LookupMode::ToKeeper, {} }; |
851 | if (_c.inter_copy_package() != InterCopyResult::Success) { // L_: settings ... error_msg _K: | 855 | if (_c.interCopyPackage() != InterCopyResult::Success) { // L_: settings ... error_msg _K: |
852 | // if something went wrong, the error message is at the top of the stack | 856 | // if something went wrong, the error message is at the top of the stack |
853 | lua_remove(L, -2); // L_: settings error_msg | 857 | lua_remove(L, -2); // L_: settings error_msg |
854 | raise_lua_error(L); | 858 | raise_lua_error(L); |