diff options
Diffstat (limited to 'src/keeper.cpp')
-rw-r--r-- | src/keeper.cpp | 58 |
1 files changed, 29 insertions, 29 deletions
diff --git a/src/keeper.cpp b/src/keeper.cpp index 33da736..cbdd0c9 100644 --- a/src/keeper.cpp +++ b/src/keeper.cpp | |||
@@ -209,13 +209,13 @@ static void push_table(lua_State* L_, int idx_) | |||
209 | // ################################################################################################# | 209 | // ################################################################################################# |
210 | 210 | ||
211 | // only used by linda:dump() and linda:__towatch() for debugging purposes | 211 | // only used by linda:dump() and linda:__towatch() for debugging purposes |
212 | int keeper_push_linda_storage(Linda& linda_, DestState L) | 212 | int keeper_push_linda_storage(Linda& linda_, DestState L_) |
213 | { | 213 | { |
214 | Keeper* const K{ linda_.whichKeeper() }; | 214 | Keeper* const K{ linda_.whichKeeper() }; |
215 | SourceState const KL{ K ? K->L : nullptr }; | 215 | SourceState const KL{ K ? K->L : nullptr }; |
216 | if (KL == nullptr) | 216 | if (KL == nullptr) |
217 | return 0; | 217 | return 0; |
218 | STACK_GROW(KL, 4); // KEEPER MAIN | 218 | STACK_GROW(KL, 4); // KEEPER MAIN |
219 | STACK_CHECK_START_REL(KL, 0); | 219 | STACK_CHECK_START_REL(KL, 0); |
220 | kFifosRegKey.pushValue(KL); // fifos | 220 | kFifosRegKey.pushValue(KL); // fifos |
221 | lua_pushlightuserdata(KL, &linda_); // fifos ud | 221 | lua_pushlightuserdata(KL, &linda_); // fifos ud |
@@ -228,33 +228,33 @@ int keeper_push_linda_storage(Linda& linda_, DestState L) | |||
228 | return 0; | 228 | return 0; |
229 | } | 229 | } |
230 | // move data from keeper to destination state | 230 | // move data from keeper to destination state |
231 | STACK_GROW(L, 5); | 231 | STACK_GROW(L_, 5); |
232 | STACK_CHECK_START_REL(L, 0); | 232 | STACK_CHECK_START_REL(L_, 0); |
233 | lua_newtable(L); // out | 233 | lua_newtable(L_); // out |
234 | InterCopyContext c{ linda_.U, L, KL, {}, {}, {}, LookupMode::FromKeeper, {} }; | 234 | InterCopyContext c{ linda_.U, L_, KL, {}, {}, {}, LookupMode::FromKeeper, {} }; |
235 | lua_pushnil(KL); // storage nil | 235 | lua_pushnil(KL); // storage nil |
236 | while (lua_next(KL, -2)) // storage key fifo | 236 | while (lua_next(KL, -2)) // storage key fifo |
237 | { | 237 | { |
238 | keeper_fifo* fifo = prepare_fifo_access(KL, -1); // storage key fifotbl | 238 | keeper_fifo* fifo = prepare_fifo_access(KL, -1); // storage key fifotbl |
239 | lua_pushvalue(KL, -2); // storage key fifotbl key | 239 | lua_pushvalue(KL, -2); // storage key fifotbl key |
240 | std::ignore = c.inter_move(1); // storage key fifotbl // out key | 240 | std::ignore = c.inter_move(1); // storage key fifotbl // out key |
241 | STACK_CHECK(L, 2); | 241 | STACK_CHECK(L_, 2); |
242 | lua_newtable(L); // out key keyout | 242 | lua_newtable(L_); // out key keyout |
243 | std::ignore = c.inter_move(1); // storage key // out key keyout fifotbl | 243 | std::ignore = c.inter_move(1); // storage key // out key keyout fifotbl |
244 | lua_pushinteger(L, fifo->first); // out key keyout fifotbl first | 244 | lua_pushinteger(L_, fifo->first); // out key keyout fifotbl first |
245 | STACK_CHECK(L, 5); | 245 | STACK_CHECK(L_, 5); |
246 | lua_setfield(L, -3, "first"); // out key keyout fifotbl | 246 | lua_setfield(L_, -3, "first"); // out key keyout fifotbl |
247 | lua_pushinteger(L, fifo->count); // out key keyout fifobtl count | 247 | lua_pushinteger(L_, fifo->count); // out key keyout fifobtl count |
248 | STACK_CHECK(L, 5); | 248 | STACK_CHECK(L_, 5); |
249 | lua_setfield(L, -3, "count"); // out key keyout fifotbl | 249 | lua_setfield(L_, -3, "count"); // out key keyout fifotbl |
250 | lua_pushinteger(L, fifo->limit); // out key keyout fifotbl limit | 250 | lua_pushinteger(L_, fifo->limit); // out key keyout fifotbl limit |
251 | STACK_CHECK(L, 5); | 251 | STACK_CHECK(L_, 5); |
252 | lua_setfield(L, -3, "limit"); // out key keyout fifotbl | 252 | lua_setfield(L_, -3, "limit"); // out key keyout fifotbl |
253 | lua_setfield(L, -2, "fifo"); // out key keyout | 253 | lua_setfield(L_, -2, "fifo"); // out key keyout |
254 | lua_rawset(L, -3); // out | 254 | lua_rawset(L_, -3); // out |
255 | STACK_CHECK(L, 1); | 255 | STACK_CHECK(L_, 1); |
256 | } | 256 | } |
257 | STACK_CHECK(L, 1); | 257 | STACK_CHECK(L_, 1); |
258 | lua_pop(KL, 1); // | 258 | lua_pop(KL, 1); // |
259 | STACK_CHECK(KL, 0); | 259 | STACK_CHECK(KL, 0); |
260 | return 1; | 260 | return 1; |
@@ -776,10 +776,10 @@ void Linda::releaseKeeper(Keeper* K_) const | |||
776 | 776 | ||
777 | // ################################################################################################# | 777 | // ################################################################################################# |
778 | 778 | ||
779 | void keeper_toggle_nil_sentinels(lua_State* L_, int val_i_, LookupMode const mode_) | 779 | void keeper_toggle_nil_sentinels(lua_State* L_, int start_, LookupMode const mode_) |
780 | { | 780 | { |
781 | int const n{ lua_gettop(L_) }; | 781 | int const n{ lua_gettop(L_) }; |
782 | for (int i = val_i_; i <= n; ++i) | 782 | for (int i = start_; i <= n; ++i) |
783 | { | 783 | { |
784 | if (mode_ == LookupMode::ToKeeper) | 784 | if (mode_ == LookupMode::ToKeeper) |
785 | { | 785 | { |
@@ -811,17 +811,17 @@ void keeper_toggle_nil_sentinels(lua_State* L_, int val_i_, LookupMode const mod | |||
811 | * | 811 | * |
812 | * Returns: number of return values (pushed to 'L'), unset in case of error | 812 | * Returns: number of return values (pushed to 'L'), unset in case of error |
813 | */ | 813 | */ |
814 | KeeperCallResult keeper_call(Universe* U, KeeperState K, keeper_api_t func_, lua_State* L_, void* linda, int starting_index) | 814 | KeeperCallResult keeper_call(Universe* U, KeeperState K, keeper_api_t func_, lua_State* L_, void* linda_, int starting_index_) |
815 | { | 815 | { |
816 | KeeperCallResult result; | 816 | KeeperCallResult result; |
817 | int const args{ starting_index ? (lua_gettop(L_) - starting_index + 1) : 0 }; | 817 | int const args{ starting_index_ ? (lua_gettop(L_) - starting_index_ + 1) : 0 }; |
818 | int const top_K{ lua_gettop(K) }; | 818 | int const top_K{ lua_gettop(K) }; |
819 | // if we didn't do anything wrong, the keeper stack should be clean | 819 | // if we didn't do anything wrong, the keeper stack should be clean |
820 | LUA_ASSERT(L_, lua_gettop(K) == 0); | 820 | LUA_ASSERT(L_, lua_gettop(K) == 0); |
821 | 821 | ||
822 | STACK_GROW(K, 2); | 822 | STACK_GROW(K, 2); |
823 | PUSH_KEEPER_FUNC(K, func_); // func_ | 823 | PUSH_KEEPER_FUNC(K, func_); // func_ |
824 | lua_pushlightuserdata(K, linda); // func_ linda | 824 | lua_pushlightuserdata(K, linda_); // func_ linda |
825 | if ( | 825 | if ( |
826 | (args == 0) || | 826 | (args == 0) || |
827 | (InterCopyContext{ U, DestState{ K }, SourceState{ L_ }, {}, {}, {}, LookupMode::ToKeeper, {} }.inter_copy(args) == InterCopyResult::Success) | 827 | (InterCopyContext{ U, DestState{ K }, SourceState{ L_ }, {}, {}, {}, LookupMode::ToKeeper, {} }.inter_copy(args) == InterCopyResult::Success) |