aboutsummaryrefslogtreecommitdiff
path: root/src/keeper.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/keeper.cpp')
-rw-r--r--src/keeper.cpp472
1 files changed, 236 insertions, 236 deletions
diff --git a/src/keeper.cpp b/src/keeper.cpp
index 51f6388..33da736 100644
--- a/src/keeper.cpp
+++ b/src/keeper.cpp
@@ -67,9 +67,9 @@ class keeper_fifo
67 // can't actually delete the operator because the compiler generates stack unwinding code that could call it in case of exception 67 // can't actually delete the operator because the compiler generates stack unwinding code that could call it in case of exception
68 static void operator delete([[maybe_unused]] void* p_, KeeperState L_) { LUA_ASSERT(L_, !"should never be called"); } 68 static void operator delete([[maybe_unused]] void* p_, KeeperState L_) { LUA_ASSERT(L_, !"should never be called"); }
69 69
70 [[nodiscard]] static keeper_fifo* getPtr(lua_State* L, int idx_) 70 [[nodiscard]] static keeper_fifo* getPtr(lua_State* L_, int idx_)
71 { 71 {
72 return lua_tofulluserdata<keeper_fifo>(L, idx_); 72 return lua_tofulluserdata<keeper_fifo>(L_, idx_);
73 } 73 }
74}; 74};
75 75
@@ -78,16 +78,16 @@ static constexpr int kContentsTableIndex{ 1 };
78// ################################################################################################# 78// #################################################################################################
79 79
80// replaces the fifo ud by its uservalue on the stack 80// replaces the fifo ud by its uservalue on the stack
81[[nodiscard]] static keeper_fifo* prepare_fifo_access(lua_State* L, int idx_) 81[[nodiscard]] static keeper_fifo* prepare_fifo_access(lua_State* L_, int idx_)
82{ 82{
83 keeper_fifo* const fifo{ keeper_fifo::getPtr(L, idx_) }; 83 keeper_fifo* const fifo{ keeper_fifo::getPtr(L_, idx_) };
84 if (fifo != nullptr) 84 if (fifo != nullptr)
85 { 85 {
86 idx_ = lua_absindex(L, idx_); 86 idx_ = lua_absindex(L_, idx_);
87 STACK_GROW(L, 1); 87 STACK_GROW(L_, 1);
88 // we can replace the fifo userdata in the stack without fear of it being GCed, there are other references around 88 // we can replace the fifo userdata in the stack without fear of it being GCed, there are other references around
89 lua_getiuservalue(L, idx_, kContentsTableIndex); 89 lua_getiuservalue(L_, idx_, kContentsTableIndex);
90 lua_replace(L, idx_); 90 lua_replace(L_, idx_);
91 } 91 }
92 return fifo; 92 return fifo;
93} 93}
@@ -96,15 +96,15 @@ static constexpr int kContentsTableIndex{ 1 };
96 96
97// in: nothing 97// in: nothing
98// out: { first = 1, count = 0, limit = -1} 98// out: { first = 1, count = 0, limit = -1}
99[[nodiscard]] static keeper_fifo* fifo_new(KeeperState L) 99[[nodiscard]] static keeper_fifo* fifo_new(KeeperState L_)
100{ 100{
101 STACK_GROW(L, 2); 101 STACK_GROW(L_, 2);
102 STACK_CHECK_START_REL(L, 0); 102 STACK_CHECK_START_REL(L_, 0);
103 keeper_fifo* const fifo{ new (L) keeper_fifo{} }; 103 keeper_fifo* const fifo{ new (L_) keeper_fifo{} };
104 STACK_CHECK(L, 1); 104 STACK_CHECK(L_, 1);
105 lua_newtable(L); 105 lua_newtable(L_);
106 lua_setiuservalue(L, -2, kContentsTableIndex); 106 lua_setiuservalue(L_, -2, kContentsTableIndex);
107 STACK_CHECK(L, 1); 107 STACK_CHECK(L_, 1);
108 return fifo; 108 return fifo;
109} 109}
110 110
@@ -112,15 +112,15 @@ static constexpr int kContentsTableIndex{ 1 };
112 112
113// in: expect fifo ... on top of the stack 113// in: expect fifo ... on top of the stack
114// out: nothing, removes all pushed values from the stack 114// out: nothing, removes all pushed values from the stack
115static void fifo_push(lua_State* L, keeper_fifo* fifo_, int count_) 115static void fifo_push(lua_State* L_, keeper_fifo* fifo_, int count_)
116{ 116{
117 int const idx{ lua_gettop(L) - count_ }; 117 int const idx{ lua_gettop(L_) - count_ };
118 int const start{ fifo_->first + fifo_->count - 1 }; 118 int const start{ fifo_->first + fifo_->count - 1 };
119 // pop all additional arguments, storing them in the fifo 119 // pop all additional arguments, storing them in the fifo
120 for (int i = count_; i >= 1; --i) 120 for (int i = count_; i >= 1; --i)
121 { 121 {
122 // store in the fifo the value at the top of the stack at the specified index, popping it from the stack 122 // store in the fifo the value at the top of the stack at the specified index, popping it from the stack
123 lua_rawseti(L, idx, start + i); 123 lua_rawseti(L_, idx, start + i);
124 } 124 }
125 fifo_->count += count_; 125 fifo_->count += count_;
126} 126}
@@ -132,12 +132,12 @@ static void fifo_push(lua_State* L, keeper_fifo* fifo_, int count_)
132// expects exactly 1 value on the stack! 132// expects exactly 1 value on the stack!
133// currently only called with a count of 1, but this may change in the future 133// currently only called with a count of 1, but this may change in the future
134// function assumes that there is enough data in the fifo to satisfy the request 134// function assumes that there is enough data in the fifo to satisfy the request
135static void fifo_peek(lua_State* L, keeper_fifo* fifo_, int count_) 135static void fifo_peek(lua_State* L_, keeper_fifo* fifo_, int count_)
136{ 136{
137 STACK_GROW(L, count_); 137 STACK_GROW(L_, count_);
138 for (int i = 0; i < count_; ++i) 138 for (int i = 0; i < count_; ++i)
139 { 139 {
140 lua_rawgeti(L, 1, (fifo_->first + i)); 140 lua_rawgeti(L_, 1, (fifo_->first + i));
141 } 141 }
142} 142}
143 143
@@ -145,29 +145,29 @@ static void fifo_peek(lua_State* L, keeper_fifo* fifo_, int count_)
145 145
146// in: fifo 146// in: fifo
147// out: remove the fifo from the stack, push as many items as required on the stack (function assumes they exist in sufficient number) 147// out: remove the fifo from the stack, push as many items as required on the stack (function assumes they exist in sufficient number)
148static void fifo_pop( lua_State* L, keeper_fifo* fifo_, int count_) 148static void fifo_pop( lua_State* L_, keeper_fifo* fifo_, int count_)
149{ 149{
150 LUA_ASSERT(L, lua_istable(L, -1)); 150 LUA_ASSERT(L_, lua_istable(L_, -1));
151 int const fifo_idx{ lua_gettop(L) }; // ... fifotbl 151 int const fifo_idx{ lua_gettop(L_) }; // ... fifotbl
152 // each iteration pushes a value on the stack! 152 // each iteration pushes a value on the stack!
153 STACK_GROW(L, count_ + 2); 153 STACK_GROW(L_, count_ + 2);
154 // skip first item, we will push it last 154 // skip first item, we will push it last
155 for (int i = 1; i < count_; ++i) 155 for (int i = 1; i < count_; ++i)
156 { 156 {
157 int const at{ fifo_->first + i }; 157 int const at{ fifo_->first + i };
158 // push item on the stack 158 // push item on the stack
159 lua_rawgeti(L, fifo_idx, at); // ... fifotbl val 159 lua_rawgeti(L_, fifo_idx, at); // ... fifotbl val
160 // remove item from the fifo 160 // remove item from the fifo
161 lua_pushnil(L); // ... fifotbl val nil 161 lua_pushnil(L_); // ... fifotbl val nil
162 lua_rawseti(L, fifo_idx, at); // ... fifotbl val 162 lua_rawseti(L_, fifo_idx, at); // ... fifotbl val
163 } 163 }
164 // now process first item 164 // now process first item
165 { 165 {
166 int const at{ fifo_->first }; 166 int const at{ fifo_->first };
167 lua_rawgeti(L, fifo_idx, at); // ... fifotbl vals val 167 lua_rawgeti(L_, fifo_idx, at); // ... fifotbl vals val
168 lua_pushnil(L); // ... fifotbl vals val nil 168 lua_pushnil(L_); // ... fifotbl vals val nil
169 lua_rawseti(L, fifo_idx, at); // ... fifotbl vals val 169 lua_rawseti(L_, fifo_idx, at); // ... fifotbl vals val
170 lua_replace(L, fifo_idx); // ... vals 170 lua_replace(L_, fifo_idx); // ... vals
171 } 171 }
172 172
173 // avoid ever-growing indexes by resetting each time we detect the fifo is empty 173 // avoid ever-growing indexes by resetting each time we detect the fifo is empty
@@ -184,26 +184,26 @@ static void fifo_pop( lua_State* L, keeper_fifo* fifo_, int count_)
184// out: fifos[ud] 184// out: fifos[ud]
185// xxh64 of string "kFifosRegKey" generated at https://www.pelock.com/products/hash-calculator 185// xxh64 of string "kFifosRegKey" generated at https://www.pelock.com/products/hash-calculator
186static constexpr RegistryUniqueKey kFifosRegKey{ 0x37F11CE5A6D191AAull }; 186static constexpr RegistryUniqueKey kFifosRegKey{ 0x37F11CE5A6D191AAull };
187static void push_table(lua_State* L, int idx_) 187static void push_table(lua_State* L_, int idx_)
188{ 188{
189 STACK_GROW(L, 5); 189 STACK_GROW(L_, 5);
190 STACK_CHECK_START_REL(L, 0); 190 STACK_CHECK_START_REL(L_, 0);
191 idx_ = lua_absindex(L, idx_); 191 idx_ = lua_absindex(L_, idx_);
192 kFifosRegKey.pushValue(L); // ud fifos 192 kFifosRegKey.pushValue(L_); // ud fifos
193 lua_pushvalue(L, idx_); // ud fifos ud 193 lua_pushvalue(L_, idx_); // ud fifos ud
194 lua_rawget(L, -2); // ud fifos fifos[ud] 194 lua_rawget(L_, -2); // ud fifos fifos[ud]
195 STACK_CHECK(L, 2); 195 STACK_CHECK(L_, 2);
196 if (lua_isnil(L, -1)) 196 if (lua_isnil(L_, -1))
197 { 197 {
198 lua_pop(L, 1); // ud fifos 198 lua_pop(L_, 1); // ud fifos
199 // add a new fifos table for this linda 199 // add a new fifos table for this linda
200 lua_newtable(L); // ud fifos fifos[ud] 200 lua_newtable(L_); // ud fifos fifos[ud]
201 lua_pushvalue(L, idx_); // ud fifos fifos[ud] ud 201 lua_pushvalue(L_, idx_); // ud fifos fifos[ud] ud
202 lua_pushvalue(L, -2); // ud fifos fifos[ud] ud fifos[ud] 202 lua_pushvalue(L_, -2); // ud fifos fifos[ud] ud fifos[ud]
203 lua_rawset(L, -4); // ud fifos fifos[ud] 203 lua_rawset(L_, -4); // ud fifos fifos[ud]
204 } 204 }
205 lua_remove(L, -2); // ud fifos[ud] 205 lua_remove(L_, -2); // ud fifos[ud]
206 STACK_CHECK(L, 1); 206 STACK_CHECK(L_, 1);
207} 207}
208 208
209// ################################################################################################# 209// #################################################################################################
@@ -263,16 +263,16 @@ int keeper_push_linda_storage(Linda& linda_, DestState L)
263// ################################################################################################# 263// #################################################################################################
264 264
265// in: linda_ud 265// in: linda_ud
266int keepercall_clear(lua_State* L) 266int keepercall_clear(lua_State* L_)
267{ 267{
268 STACK_GROW(L, 3); 268 STACK_GROW(L_, 3);
269 STACK_CHECK_START_REL(L, 0); 269 STACK_CHECK_START_REL(L_, 0);
270 kFifosRegKey.pushValue(L); // ud fifos 270 kFifosRegKey.pushValue(L_); // ud fifos
271 lua_pushvalue(L, 1); // ud fifos ud 271 lua_pushvalue(L_, 1); // ud fifos ud
272 lua_pushnil(L); // ud fifos ud nil 272 lua_pushnil(L_); // ud fifos ud nil
273 lua_rawset(L, -3); // ud fifos 273 lua_rawset(L_, -3); // ud fifos
274 lua_pop(L, 1); // ud 274 lua_pop(L_, 1); // ud
275 STACK_CHECK(L, 0); 275 STACK_CHECK(L_, 0);
276 return 0; 276 return 0;
277} 277}
278 278
@@ -280,35 +280,35 @@ int keepercall_clear(lua_State* L)
280 280
281// in: linda_ud, key, ... 281// in: linda_ud, key, ...
282// out: true|false 282// out: true|false
283int keepercall_send(lua_State* L) 283int keepercall_send(lua_State* L_)
284{ 284{
285 int const n{ lua_gettop(L) - 2 }; 285 int const n{ lua_gettop(L_) - 2 };
286 push_table(L, 1); // ud key ... fifos 286 push_table(L_, 1); // ud key ... fifos
287 // get the fifo associated to this key in this linda, create it if it doesn't exist 287 // get the fifo associated to this key in this linda, create it if it doesn't exist
288 lua_pushvalue(L, 2); // ud key ... fifos key 288 lua_pushvalue(L_, 2); // ud key ... fifos key
289 lua_rawget(L, -2); // ud key ... fifos fifo 289 lua_rawget(L_, -2); // ud key ... fifos fifo
290 if (lua_isnil(L, -1)) 290 if (lua_isnil(L_, -1))
291 { 291 {
292 lua_pop(L, 1); // ud key ... fifos 292 lua_pop(L_, 1); // ud key ... fifos
293 std::ignore = fifo_new(KeeperState{ L }); // ud key ... fifos fifo 293 std::ignore = fifo_new(KeeperState{ L_ }); // ud key ... fifos fifo
294 lua_pushvalue(L, 2); // ud key ... fifos fifo key 294 lua_pushvalue(L_, 2); // ud key ... fifos fifo key
295 lua_pushvalue(L, -2); // ud key ... fifos fifo key fifo 295 lua_pushvalue(L_, -2); // ud key ... fifos fifo key fifo
296 lua_rawset(L, -4); // ud key ... fifos fifo 296 lua_rawset(L_, -4); // ud key ... fifos fifo
297 } 297 }
298 lua_remove(L, -2); // ud key ... fifo 298 lua_remove(L_, -2); // ud key ... fifo
299 keeper_fifo* fifo{ keeper_fifo::getPtr(L, -1) }; 299 keeper_fifo* fifo{ keeper_fifo::getPtr(L_, -1) };
300 if (fifo->limit >= 0 && fifo->count + n > fifo->limit) 300 if (fifo->limit >= 0 && fifo->count + n > fifo->limit)
301 { 301 {
302 lua_settop(L, 0); // 302 lua_settop(L_, 0); //
303 lua_pushboolean(L, 0); // false 303 lua_pushboolean(L_, 0); // false
304 } 304 }
305 else 305 else
306 { 306 {
307 fifo = prepare_fifo_access(L, -1); // ud fifotbl 307 fifo = prepare_fifo_access(L_, -1); // ud fifotbl
308 lua_replace(L, 2); // ud fifotbl ... 308 lua_replace(L_, 2); // ud fifotbl ...
309 fifo_push(L, fifo, n); // ud fifotbl 309 fifo_push(L_, fifo, n); // ud fifotbl
310 lua_settop(L, 0); // 310 lua_settop(L_, 0); //
311 lua_pushboolean(L, 1); // true 311 lua_pushboolean(L_, 1); // true
312 } 312 }
313 return 1; 313 return 1;
314} 314}
@@ -317,33 +317,33 @@ int keepercall_send(lua_State* L)
317 317
318// in: linda_ud, key [, key]? 318// in: linda_ud, key [, key]?
319// out: (key, val) or nothing 319// out: (key, val) or nothing
320int keepercall_receive(lua_State* L) 320int keepercall_receive(lua_State* L_)
321{ 321{
322 int const top{ lua_gettop(L) }; 322 int const top{ lua_gettop(L_) };
323 push_table(L, 1); // ud keys fifos 323 push_table(L_, 1); // ud keys fifos
324 lua_replace(L, 1); // fifos keys 324 lua_replace(L_, 1); // fifos keys
325 for (int i = 2; i <= top; ++i) 325 for (int i = 2; i <= top; ++i)
326 { 326 {
327 lua_pushvalue(L, i); // fifos keys key[i] 327 lua_pushvalue(L_, i); // fifos keys key[i]
328 lua_rawget(L, 1); // fifos keys fifo 328 lua_rawget(L_, 1); // fifos keys fifo
329 keeper_fifo* const fifo{ prepare_fifo_access(L, -1) }; // fifos keys fifotbl 329 keeper_fifo* const fifo{ prepare_fifo_access(L_, -1) }; // fifos keys fifotbl
330 if (fifo != nullptr && fifo->count > 0) 330 if (fifo != nullptr && fifo->count > 0)
331 { 331 {
332 fifo_pop(L, fifo, 1); // fifos keys val 332 fifo_pop(L_, fifo, 1); // fifos keys val
333 if (!lua_isnil(L, -1)) 333 if (!lua_isnil(L_, -1))
334 { 334 {
335 lua_replace(L, 1); // val keys 335 lua_replace(L_, 1); // val keys
336 lua_settop(L, i); // val keys key[i] 336 lua_settop(L_, i); // val keys key[i]
337 if (i != 2) 337 if (i != 2)
338 { 338 {
339 lua_replace(L, 2); // val key keys 339 lua_replace(L_, 2); // val key keys
340 lua_settop(L, 2); // val key 340 lua_settop(L_, 2); // val key
341 } 341 }
342 lua_insert(L, 1); // key, val 342 lua_insert(L_, 1); // key, val
343 return 2; 343 return 2;
344 } 344 }
345 } 345 }
346 lua_settop(L, top); // data keys 346 lua_settop(L_, top); // data keys
347 } 347 }
348 // nothing to receive 348 // nothing to receive
349 return 0; 349 return 0;
@@ -352,29 +352,29 @@ int keepercall_receive(lua_State* L)
352// ################################################################################################# 352// #################################################################################################
353 353
354// in: linda_ud key mincount [maxcount] 354// in: linda_ud key mincount [maxcount]
355int keepercall_receive_batched(lua_State* L) 355int keepercall_receive_batched(lua_State* L_)
356{ 356{
357 int const min_count{ static_cast<int>(lua_tointeger(L, 3)) }; 357 int const min_count{ static_cast<int>(lua_tointeger(L_, 3)) };
358 if (min_count > 0) 358 if (min_count > 0)
359 { 359 {
360 int const max_count{ static_cast<int>(luaL_optinteger(L, 4, min_count)) }; 360 int const max_count{ static_cast<int>(luaL_optinteger(L_, 4, min_count)) };
361 lua_settop(L, 2); // ud key 361 lua_settop(L_, 2); // ud key
362 lua_insert(L, 1); // key ud 362 lua_insert(L_, 1); // key ud
363 push_table(L, 2); // key ud fifos 363 push_table(L_, 2); // key ud fifos
364 lua_remove(L, 2); // key fifos 364 lua_remove(L_, 2); // key fifos
365 lua_pushvalue(L, 1); // key fifos key 365 lua_pushvalue(L_, 1); // key fifos key
366 lua_rawget(L, 2); // key fifos fifo 366 lua_rawget(L_, 2); // key fifos fifo
367 lua_remove(L, 2); // key fifo 367 lua_remove(L_, 2); // key fifo
368 keeper_fifo* const fifo{ prepare_fifo_access(L, 2) }; // key fifotbl 368 keeper_fifo* const fifo{ prepare_fifo_access(L_, 2) }; // key fifotbl
369 if (fifo != nullptr && fifo->count >= min_count) 369 if (fifo != nullptr && fifo->count >= min_count)
370 { 370 {
371 fifo_pop(L, fifo, std::min( max_count, fifo->count)); // key ... 371 fifo_pop(L_, fifo, std::min( max_count, fifo->count)); // key ...
372 } 372 }
373 else 373 else
374 { 374 {
375 lua_settop(L, 0); // 375 lua_settop(L_, 0); //
376 } 376 }
377 return lua_gettop(L); 377 return lua_gettop(L_);
378 } 378 }
379 else 379 else
380 { 380 {
@@ -386,23 +386,23 @@ int keepercall_receive_batched(lua_State* L)
386 386
387// in: linda_ud key n 387// in: linda_ud key n
388// out: true or nil 388// out: true or nil
389int keepercall_limit(lua_State* L) 389int keepercall_limit(lua_State* L_)
390{ 390{
391 int const limit{ static_cast<int>(lua_tointeger(L, 3)) }; 391 int const limit{ static_cast<int>(lua_tointeger(L_, 3)) };
392 push_table(L, 1); // ud key n fifos 392 push_table(L_, 1); // ud key n fifos
393 lua_replace(L, 1); // fifos key n 393 lua_replace(L_, 1); // fifos key n
394 lua_pop(L, 1); // fifos key 394 lua_pop(L_, 1); // fifos key
395 lua_pushvalue(L, -1); // fifos key key 395 lua_pushvalue(L_, -1); // fifos key key
396 lua_rawget(L, -3); // fifos key fifo|nil 396 lua_rawget(L_, -3); // fifos key fifo|nil
397 keeper_fifo* fifo{ keeper_fifo::getPtr(L, -1) }; 397 keeper_fifo* fifo{ keeper_fifo::getPtr(L_, -1) };
398 if (fifo == nullptr) 398 if (fifo == nullptr)
399 { // fifos key nil 399 { // fifos key nil
400 lua_pop(L, 1); // fifos key 400 lua_pop(L_, 1); // fifos key
401 fifo = fifo_new(KeeperState{ L }); // fifos key fifo 401 fifo = fifo_new(KeeperState{ L_ }); // fifos key fifo
402 lua_rawset(L, -3); // fifos 402 lua_rawset(L_, -3); // fifos
403 } 403 }
404 // remove any clutter on the stack 404 // remove any clutter on the stack
405 lua_settop(L, 0); 405 lua_settop(L_, 0);
406 // return true if we decide that blocked threads waiting to write on that key should be awakened 406 // return true if we decide that blocked threads waiting to write on that key should be awakened
407 // this is the case if we detect the key was full but it is no longer the case 407 // this is the case if we detect the key was full but it is no longer the case
408 if ( 408 if (
@@ -410,49 +410,49 @@ int keepercall_limit(lua_State* L)
410 && ((limit < 0) || (fifo->count < limit)) // the key is not full if unlimited or count is lower than the new limit 410 && ((limit < 0) || (fifo->count < limit)) // the key is not full if unlimited or count is lower than the new limit
411 ) 411 )
412 { 412 {
413 lua_pushboolean(L, 1); // true 413 lua_pushboolean(L_, 1); // true
414 } 414 }
415 // set the new limit 415 // set the new limit
416 fifo->limit = limit; 416 fifo->limit = limit;
417 // return 0 or 1 value 417 // return 0 or 1 value
418 return lua_gettop(L); 418 return lua_gettop(L_);
419} 419}
420 420
421// ################################################################################################# 421// #################################################################################################
422 422
423// in: linda_ud key [[val] ...] 423// in: linda_ud key [[val] ...]
424//out: true if the linda was full but it's no longer the case, else nothing 424//out: true if the linda was full but it's no longer the case, else nothing
425int keepercall_set(lua_State* L) 425int keepercall_set(lua_State* L_)
426{ 426{
427 bool should_wake_writers{ false }; 427 bool should_wake_writers{ false };
428 STACK_GROW(L, 6); 428 STACK_GROW(L_, 6);
429 429
430 // retrieve fifos associated with the linda 430 // retrieve fifos associated with the linda
431 push_table(L, 1); // ud key [val [, ...]] fifos 431 push_table(L_, 1); // ud key [val [, ...]] fifos
432 lua_replace(L, 1); // fifos key [val [, ...]] 432 lua_replace(L_, 1); // fifos key [val [, ...]]
433 433
434 // make sure we have a value on the stack 434 // make sure we have a value on the stack
435 if (lua_gettop(L) == 2) // fifos key 435 if (lua_gettop(L_) == 2) // fifos key
436 { 436 {
437 lua_pushvalue(L, -1); // fifos key key 437 lua_pushvalue(L_, -1); // fifos key key
438 lua_rawget(L, 1); // fifos key fifo|nil 438 lua_rawget(L_, 1); // fifos key fifo|nil
439 // empty the fifo for the specified key: replace uservalue with a virgin table, reset counters, but leave limit unchanged! 439 // empty the fifo for the specified key: replace uservalue with a virgin table, reset counters, but leave limit unchanged!
440 keeper_fifo* const fifo{ keeper_fifo::getPtr(L, -1) }; 440 keeper_fifo* const fifo{ keeper_fifo::getPtr(L_, -1) };
441 if (fifo != nullptr) // might be nullptr if we set a nonexistent key to nil 441 if (fifo != nullptr) // might be nullptr if we set a nonexistent key to nil
442 { // fifos key fifo 442 { // fifos key fifo
443 if (fifo->limit < 0) // fifo limit value is the default (unlimited): we can totally remove it 443 if (fifo->limit < 0) // fifo limit value is the default (unlimited): we can totally remove it
444 { 444 {
445 lua_pop(L, 1); // fifos key 445 lua_pop(L_, 1); // fifos key
446 lua_pushnil(L); // fifos key nil 446 lua_pushnil(L_); // fifos key nil
447 lua_rawset(L, -3); // fifos 447 lua_rawset(L_, -3); // fifos
448 } 448 }
449 else 449 else
450 { 450 {
451 // we create room if the fifo was full but it is no longer the case 451 // we create room if the fifo was full but it is no longer the case
452 should_wake_writers = (fifo->limit > 0) && (fifo->count >= fifo->limit); 452 should_wake_writers = (fifo->limit > 0) && (fifo->count >= fifo->limit);
453 lua_remove(L, -2); // fifos fifo 453 lua_remove(L_, -2); // fifos fifo
454 lua_newtable(L); // fifos fifo {} 454 lua_newtable(L_); // fifos fifo {}
455 lua_setiuservalue(L, -2, kContentsTableIndex); // fifos fifo 455 lua_setiuservalue(L_, -2, kContentsTableIndex); // fifos fifo
456 fifo->first = 1; 456 fifo->first = 1;
457 fifo->count = 0; 457 fifo->count = 0;
458 } 458 }
@@ -460,59 +460,59 @@ int keepercall_set(lua_State* L)
460 } 460 }
461 else // set/replace contents stored at the specified key? 461 else // set/replace contents stored at the specified key?
462 { 462 {
463 int const count{ lua_gettop(L) - 2 }; // number of items we want to store 463 int const count{ lua_gettop(L_) - 2 }; // number of items we want to store
464 lua_pushvalue(L, 2); // fifos key [val [, ...]] key 464 lua_pushvalue(L_, 2); // fifos key [val [, ...]] key
465 lua_rawget(L, 1); // fifos key [val [, ...]] fifo|nil 465 lua_rawget(L_, 1); // fifos key [val [, ...]] fifo|nil
466 keeper_fifo* fifo{ keeper_fifo::getPtr(L, -1) }; 466 keeper_fifo* fifo{ keeper_fifo::getPtr(L_, -1) };
467 if (fifo == nullptr) // can be nullptr if we store a value at a new key 467 if (fifo == nullptr) // can be nullptr if we store a value at a new key
468 { // fifos key [val [, ...]] nil 468 { // fifos key [val [, ...]] nil
469 // no need to wake writers in that case, because a writer can't wait on an inexistent key 469 // no need to wake writers in that case, because a writer can't wait on an inexistent key
470 lua_pop(L, 1); // fifos key [val [, ...]] 470 lua_pop(L_, 1); // fifos key [val [, ...]]
471 std::ignore = fifo_new(KeeperState{ L }); // fifos key [val [, ...]] fifo 471 std::ignore = fifo_new(KeeperState{ L_ }); // fifos key [val [, ...]] fifo
472 lua_pushvalue(L, 2); // fifos key [val [, ...]] fifo key 472 lua_pushvalue(L_, 2); // fifos key [val [, ...]] fifo key
473 lua_pushvalue(L, -2); // fifos key [val [, ...]] fifo key fifo 473 lua_pushvalue(L_, -2); // fifos key [val [, ...]] fifo key fifo
474 lua_rawset(L, 1); // fifos key [val [, ...]] fifo 474 lua_rawset(L_, 1); // fifos key [val [, ...]] fifo
475 } 475 }
476 else // the fifo exists, we just want to update its contents 476 else // the fifo exists, we just want to update its contents
477 { // fifos key [val [, ...]] fifo 477 { // fifos key [val [, ...]] fifo
478 // we create room if the fifo was full but it is no longer the case 478 // we create room if the fifo was full but it is no longer the case
479 should_wake_writers = (fifo->limit > 0) && (fifo->count >= fifo->limit) && (count < fifo->limit); 479 should_wake_writers = (fifo->limit > 0) && (fifo->count >= fifo->limit) && (count < fifo->limit);
480 // empty the fifo for the specified key: replace uservalue with a virgin table, reset counters, but leave limit unchanged! 480 // empty the fifo for the specified key: replace uservalue with a virgin table, reset counters, but leave limit unchanged!
481 lua_newtable(L); // fifos key [val [, ...]] fifo {} 481 lua_newtable(L_); // fifos key [val [, ...]] fifo {}
482 lua_setiuservalue(L, -2, kContentsTableIndex); // fifos key [val [, ...]] fifo 482 lua_setiuservalue(L_, -2, kContentsTableIndex); // fifos key [val [, ...]] fifo
483 fifo->first = 1; 483 fifo->first = 1;
484 fifo->count = 0; 484 fifo->count = 0;
485 } 485 }
486 fifo = prepare_fifo_access(L, -1); // fifos key [val [, ...]] fifotbl 486 fifo = prepare_fifo_access(L_, -1); // fifos key [val [, ...]] fifotbl
487 // move the fifo below the values we want to store 487 // move the fifo below the values we want to store
488 lua_insert(L, 3); // fifos key fifotbl [val [, ...]] 488 lua_insert(L_, 3); // fifos key fifotbl [val [, ...]]
489 fifo_push(L, fifo, count); // fifos key fifotbl 489 fifo_push(L_, fifo, count); // fifos key fifotbl
490 } 490 }
491 return should_wake_writers ? (lua_pushboolean(L, 1), 1) : 0; 491 return should_wake_writers ? (lua_pushboolean(L_, 1), 1) : 0;
492} 492}
493 493
494// ################################################################################################# 494// #################################################################################################
495 495
496// in: linda_ud key [count] 496// in: linda_ud key [count]
497// out: at most <count> values 497// out: at most <count> values
498int keepercall_get(lua_State* L) 498int keepercall_get(lua_State* L_)
499{ 499{
500 int count{ 1 }; 500 int count{ 1 };
501 if (lua_gettop(L) == 3) // ud key count 501 if (lua_gettop(L_) == 3) // ud key count
502 { 502 {
503 count = static_cast<int>(lua_tointeger(L, 3)); 503 count = static_cast<int>(lua_tointeger(L_, 3));
504 lua_pop(L, 1); // ud key 504 lua_pop(L_, 1); // ud key
505 } 505 }
506 push_table(L, 1); // ud key fifos 506 push_table(L_, 1); // ud key fifos
507 lua_replace(L, 1); // fifos key 507 lua_replace(L_, 1); // fifos key
508 lua_rawget(L, 1); // fifos fifo 508 lua_rawget(L_, 1); // fifos fifo
509 keeper_fifo* const fifo{ prepare_fifo_access(L, -1) }; // fifos fifotbl 509 keeper_fifo* const fifo{ prepare_fifo_access(L_, -1) }; // fifos fifotbl
510 if (fifo != nullptr && fifo->count > 0) 510 if (fifo != nullptr && fifo->count > 0)
511 { 511 {
512 lua_remove(L, 1); // fifotbl 512 lua_remove(L_, 1); // fifotbl
513 count = std::min(count, fifo->count); 513 count = std::min(count, fifo->count);
514 // read <count> value off the fifo 514 // read <count> value off the fifo
515 fifo_peek(L, fifo, count); // fifotbl ... 515 fifo_peek(L_, fifo, count); // fifotbl ...
516 return count; 516 return count;
517 } 517 }
518 // no fifo was ever registered for this key, or it is empty 518 // no fifo was ever registered for this key, or it is empty
@@ -522,69 +522,69 @@ int keepercall_get(lua_State* L)
522// ################################################################################################# 522// #################################################################################################
523 523
524// in: linda_ud [, key [, ...]] 524// in: linda_ud [, key [, ...]]
525int keepercall_count(lua_State* L) 525int keepercall_count(lua_State* L_)
526{ 526{
527 push_table(L, 1); // ud keys fifos 527 push_table(L_, 1); // ud keys fifos
528 switch (lua_gettop(L)) 528 switch (lua_gettop(L_))
529 { 529 {
530 // no key is specified: return a table giving the count of all known keys 530 // no key is specified: return a table giving the count of all known keys
531 case 2: // ud fifos 531 case 2: // ud fifos
532 lua_newtable(L); // ud fifos out 532 lua_newtable(L_); // ud fifos out
533 lua_replace(L, 1); // out fifos 533 lua_replace(L_, 1); // out fifos
534 lua_pushnil(L); // out fifos nil 534 lua_pushnil(L_); // out fifos nil
535 while (lua_next(L, 2)) // out fifos key fifo 535 while (lua_next(L_, 2)) // out fifos key fifo
536 { 536 {
537 keeper_fifo* const fifo{ keeper_fifo::getPtr(L, -1) }; 537 keeper_fifo* const fifo{ keeper_fifo::getPtr(L_, -1) };
538 lua_pop(L, 1); // out fifos key 538 lua_pop(L_, 1); // out fifos key
539 lua_pushvalue(L, -1); // out fifos key key 539 lua_pushvalue(L_, -1); // out fifos key key
540 lua_pushinteger(L, fifo->count); // out fifos key key count 540 lua_pushinteger(L_, fifo->count); // out fifos key key count
541 lua_rawset(L, -5); // out fifos key 541 lua_rawset(L_, -5); // out fifos key
542 } 542 }
543 lua_pop(L, 1); // out 543 lua_pop(L_, 1); // out
544 break; 544 break;
545 545
546 // 1 key is specified: return its count 546 // 1 key is specified: return its count
547 case 3: // ud key fifos 547 case 3: // ud key fifos
548 lua_replace(L, 1); // fifos key 548 lua_replace(L_, 1); // fifos key
549 lua_rawget(L, -2); // fifos fifo|nil 549 lua_rawget(L_, -2); // fifos fifo|nil
550 if (lua_isnil(L, -1)) // the key is unknown 550 if (lua_isnil(L_, -1)) // the key is unknown
551 { // fifos nil 551 { // fifos nil
552 lua_remove(L, -2); // nil 552 lua_remove(L_, -2); // nil
553 } 553 }
554 else // the key is known 554 else // the key is known
555 { // fifos fifo 555 { // fifos fifo
556 keeper_fifo* const fifo{ keeper_fifo::getPtr(L, -1) }; 556 keeper_fifo* const fifo{ keeper_fifo::getPtr(L_, -1) };
557 lua_pushinteger(L, fifo->count); // fifos fifo count 557 lua_pushinteger(L_, fifo->count); // fifos fifo count
558 lua_replace(L, -3); // count fifo 558 lua_replace(L_, -3); // count fifo
559 lua_pop(L, 1); // count 559 lua_pop(L_, 1); // count
560 } 560 }
561 break; 561 break;
562 562
563 // a variable number of keys is specified: return a table of their counts 563 // a variable number of keys is specified: return a table of their counts
564 default: // ud keys fifos 564 default: // ud keys fifos
565 lua_newtable(L); // ud keys... fifos out 565 lua_newtable(L_); // ud keys... fifos out
566 lua_replace(L, 1); // out keys... fifos 566 lua_replace(L_, 1); // out keys... fifos
567 // shifts all keys up in the stack. potentially slow if there are a lot of them, but then it should be bearable 567 // shifts all keys up in the stack. potentially slow if there are a lot of them, but then it should be bearable
568 lua_insert(L, 2); // out fifos keys... 568 lua_insert(L_, 2); // out fifos keys...
569 while (lua_gettop(L) > 2) 569 while (lua_gettop(L_) > 2)
570 { 570 {
571 lua_pushvalue(L, -1); // out fifos keys... key 571 lua_pushvalue(L_, -1); // out fifos keys... key
572 lua_rawget(L, 2); // out fifos keys... fifo|nil 572 lua_rawget(L_, 2); // out fifos keys... fifo|nil
573 keeper_fifo* const fifo{ keeper_fifo::getPtr(L, -1) }; 573 keeper_fifo* const fifo{ keeper_fifo::getPtr(L_, -1) };
574 lua_pop(L, 1); // out fifos keys... 574 lua_pop(L_, 1); // out fifos keys...
575 if (fifo != nullptr) // the key is known 575 if (fifo != nullptr) // the key is known
576 { 576 {
577 lua_pushinteger(L, fifo->count); // out fifos keys... count 577 lua_pushinteger(L_, fifo->count); // out fifos keys... count
578 lua_rawset(L, 1); // out fifos keys... 578 lua_rawset(L_, 1); // out fifos keys...
579 } 579 }
580 else // the key is unknown 580 else // the key is unknown
581 { 581 {
582 lua_pop(L, 1); // out fifos keys... 582 lua_pop(L_, 1); // out fifos keys...
583 } 583 }
584 } // all keys are exhausted // out fifos 584 } // all keys are exhausted // out fifos
585 lua_pop(L, 1); // out 585 lua_pop(L_, 1); // out
586 } 586 }
587 LUA_ASSERT(L, lua_gettop(L) == 1); 587 LUA_ASSERT(L_, lua_gettop(L_) == 1);
588 return 1; 588 return 1;
589} 589}
590 590
@@ -651,23 +651,23 @@ void close_keepers(Universe* U)
651 * function never fails. 651 * function never fails.
652 * settings table is expected at position 1 on the stack 652 * settings table is expected at position 1 on the stack
653 */ 653 */
654void init_keepers(Universe* U, lua_State* L) 654void init_keepers(Universe* U, lua_State* L_)
655{ 655{
656 LUA_ASSERT(L, lua_gettop(L) == 1 && lua_istable(L, 1)); 656 LUA_ASSERT(L_, lua_gettop(L_) == 1 && lua_istable(L_, 1));
657 STACK_CHECK_START_REL(L, 0); // L K 657 STACK_CHECK_START_REL(L_, 0); // L_ K
658 lua_getfield(L, 1, "nb_keepers"); // settings nb_keepers 658 lua_getfield(L_, 1, "nb_keepers"); // settings nb_keepers
659 int const nb_keepers{ static_cast<int>(lua_tointeger(L, -1)) }; 659 int const nb_keepers{ static_cast<int>(lua_tointeger(L_, -1)) };
660 lua_pop(L, 1); // settings 660 lua_pop(L_, 1); // settings
661 if (nb_keepers < 1) 661 if (nb_keepers < 1)
662 { 662 {
663 raise_luaL_error(L, "Bad number of keepers (%d)", nb_keepers); 663 raise_luaL_error(L_, "Bad number of keepers (%d)", nb_keepers);
664 } 664 }
665 STACK_CHECK(L, 0); 665 STACK_CHECK(L_, 0);
666 666
667 lua_getfield(L, 1, "keepers_gc_threshold"); // settings keepers_gc_threshold 667 lua_getfield(L_, 1, "keepers_gc_threshold"); // settings keepers_gc_threshold
668 int const keepers_gc_threshold{ static_cast<int>(lua_tointeger(L, -1)) }; 668 int const keepers_gc_threshold{ static_cast<int>(lua_tointeger(L_, -1)) };
669 lua_pop(L, 1); // settings 669 lua_pop(L_, 1); // settings
670 STACK_CHECK(L, 0); 670 STACK_CHECK(L_, 0);
671 671
672 // Keepers contains an array of 1 Keeper, adjust for the actual number of keeper states 672 // Keepers contains an array of 1 Keeper, adjust for the actual number of keeper states
673 { 673 {
@@ -675,7 +675,7 @@ void init_keepers(Universe* U, lua_State* L)
675 U->keepers = static_cast<Keepers*>(U->internal_allocator.alloc(bytes)); 675 U->keepers = static_cast<Keepers*>(U->internal_allocator.alloc(bytes));
676 if (U->keepers == nullptr) 676 if (U->keepers == nullptr)
677 { 677 {
678 raise_luaL_error(L, "init_keepers() failed while creating keeper array; out of memory"); 678 raise_luaL_error(L_, "init_keepers() failed while creating keeper array; out of memory");
679 } 679 }
680 U->keepers->Keepers::Keepers(); 680 U->keepers->Keepers::Keepers();
681 U->keepers->gc_threshold = keepers_gc_threshold; 681 U->keepers->gc_threshold = keepers_gc_threshold;
@@ -689,10 +689,10 @@ void init_keepers(Universe* U, lua_State* L)
689 for (int i = 0; i < nb_keepers; ++i) // settings 689 for (int i = 0; i < nb_keepers; ++i) // settings
690 { 690 {
691 // note that we will leak K if we raise an error later 691 // note that we will leak K if we raise an error later
692 KeeperState const K{ create_state(U, L) }; 692 KeeperState const K{ create_state(U, L_) };
693 if (K == nullptr) 693 if (K == nullptr)
694 { 694 {
695 raise_luaL_error(L, "init_keepers() failed while creating keeper states; out of memory"); 695 raise_luaL_error(L_, "init_keepers() failed while creating keeper states; out of memory");
696 } 696 }
697 697
698 U->keepers->keeper_array[i].L = K; 698 U->keepers->keeper_array[i].L = K;
@@ -717,35 +717,35 @@ void init_keepers(Universe* U, lua_State* L)
717 STACK_CHECK(K, 0); 717 STACK_CHECK(K, 0);
718 718
719 // copy package.path and package.cpath from the source state (TODO: use _R._LOADED.package instead of _G.package) 719 // copy package.path and package.cpath from the source state (TODO: use _R._LOADED.package instead of _G.package)
720 lua_getglobal(L, "package"); // settings package 720 lua_getglobal(L_, "package"); // settings package
721 if (!lua_isnil(L, -1)) 721 if (!lua_isnil(L_, -1))
722 { 722 {
723 // when copying with mode LookupMode::ToKeeper, error message is pushed at the top of the stack, not raised immediately 723 // when copying with mode LookupMode::ToKeeper, error message is pushed at the top of the stack, not raised immediately
724 InterCopyContext c{ U, DestState{ K }, SourceState{ L }, {}, SourceIndex{ lua_absindex(L, -1) }, {}, LookupMode::ToKeeper, {} }; 724 InterCopyContext c{ U, DestState{ K }, SourceState{ L_ }, {}, SourceIndex{ lua_absindex(L_, -1) }, {}, LookupMode::ToKeeper, {} };
725 if (c.inter_copy_package() != InterCopyResult::Success) 725 if (c.inter_copy_package() != InterCopyResult::Success)
726 { 726 {
727 // if something went wrong, the error message is at the top of the stack 727 // if something went wrong, the error message is at the top of the stack
728 lua_remove(L, -2); // settings error_msg 728 lua_remove(L_, -2); // settings error_msg
729 raise_lua_error(L); 729 raise_lua_error(L_);
730 } 730 }
731 } 731 }
732 lua_pop(L, 1); // settings 732 lua_pop(L_, 1); // settings
733 STACK_CHECK(L, 0); 733 STACK_CHECK(L_, 0);
734 STACK_CHECK(K, 0); 734 STACK_CHECK(K, 0);
735 735
736 // attempt to call on_state_create(), if we have one and it is a C function 736 // attempt to call on_state_create(), if we have one and it is a C function
737 // (only support a C function because we can't transfer executable Lua code in keepers) 737 // (only support a C function because we can't transfer executable Lua code in keepers)
738 // will raise an error in L in case of problem 738 // will raise an error in L_ in case of problem
739 call_on_state_create(U, K, L, LookupMode::ToKeeper); 739 call_on_state_create(U, K, L_, LookupMode::ToKeeper);
740 740
741 // to see VM name in Decoda debugger 741 // to see VM name in Decoda debugger
742 lua_pushfstring(K, "Keeper #%d", i + 1); // "Keeper #n" 742 lua_pushfstring(K, "Keeper #%d", i + 1); // "Keeper #n"
743 lua_setglobal(K, "decoda_name"); // 743 lua_setglobal(K, "decoda_name"); //
744 // create the fifos table in the keeper state 744 // create the fifos table in the keeper state
745 kFifosRegKey.setValue(K, [](lua_State* L) { lua_newtable(L); }); 745 kFifosRegKey.setValue(K, [](lua_State* L_) { lua_newtable(L_); });
746 STACK_CHECK(K, 0); 746 STACK_CHECK(K, 0);
747 } 747 }
748 STACK_CHECK(L, 0); 748 STACK_CHECK(L_, 0);
749} 749}
750 750
751// ################################################################################################# 751// #################################################################################################
@@ -776,25 +776,25 @@ void Linda::releaseKeeper(Keeper* K_) const
776 776
777// ################################################################################################# 777// #################################################################################################
778 778
779void keeper_toggle_nil_sentinels(lua_State* L, int val_i_, LookupMode const mode_) 779void keeper_toggle_nil_sentinels(lua_State* L_, int val_i_, 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 = val_i_; i <= n; ++i)
783 { 783 {
784 if (mode_ == LookupMode::ToKeeper) 784 if (mode_ == LookupMode::ToKeeper)
785 { 785 {
786 if (lua_isnil(L, i)) 786 if (lua_isnil(L_, i))
787 { 787 {
788 kNilSentinel.pushKey(L); 788 kNilSentinel.pushKey(L_);
789 lua_replace(L, i); 789 lua_replace(L_, i);
790 } 790 }
791 } 791 }
792 else 792 else
793 { 793 {
794 if (kNilSentinel.equals(L, i)) 794 if (kNilSentinel.equals(L_, i))
795 { 795 {
796 lua_pushnil(L); 796 lua_pushnil(L_);
797 lua_replace(L, i); 797 lua_replace(L_, i);
798 } 798 }
799 } 799 }
800 } 800 }
@@ -811,20 +811,20 @@ void keeper_toggle_nil_sentinels(lua_State* L, int val_i_, LookupMode const mode
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*/
814KeeperCallResult keeper_call(Universe* U, KeeperState K, keeper_api_t func_, lua_State* L, void* linda, int starting_index) 814KeeperCallResult 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)
828 ) 828 )
829 { // func_ linda args... 829 { // func_ linda args...
830 lua_call(K, 1 + args, LUA_MULTRET); // result... 830 lua_call(K, 1 + args, LUA_MULTRET); // result...
@@ -835,8 +835,8 @@ KeeperCallResult keeper_call(Universe* U, KeeperState K, keeper_api_t func_, lua
835 // when attempting to grab the mutex again (WINVER <= 0x400 does this, but locks just fine, I don't know about pthread) 835 // when attempting to grab the mutex again (WINVER <= 0x400 does this, but locks just fine, I don't know about pthread)
836 if ( 836 if (
837 (retvals == 0) || 837 (retvals == 0) ||
838 (InterCopyContext{ U, DestState{ L }, SourceState{ K }, {}, {}, {}, LookupMode::FromKeeper, {} }.inter_move(retvals) == InterCopyResult::Success) 838 (InterCopyContext{ U, DestState{ L_ }, SourceState{ K }, {}, {}, {}, LookupMode::FromKeeper, {} }.inter_move(retvals) == InterCopyResult::Success)
839 ) // K->L 839 ) // K->L_
840 { 840 {
841 result.emplace(retvals); 841 result.emplace(retvals);
842 } 842 }
@@ -862,7 +862,7 @@ KeeperCallResult keeper_call(Universe* U, KeeperState K, keeper_api_t func_, lua
862 int const gc_usage_after{ lua_gc(K, LUA_GCCOUNT, 0) }; 862 int const gc_usage_after{ lua_gc(K, LUA_GCCOUNT, 0) };
863 if (gc_usage_after > gc_threshold) [[unlikely]] 863 if (gc_usage_after > gc_threshold) [[unlikely]]
864 { 864 {
865 raise_luaL_error(L, "Keeper GC threshold is too low, need at least %d", gc_usage_after); 865 raise_luaL_error(L_, "Keeper GC threshold is too low, need at least %d", gc_usage_after);
866 } 866 }
867 } 867 }
868 } 868 }