aboutsummaryrefslogtreecommitdiff
path: root/src/state.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/state.cpp')
-rw-r--r--src/state.cpp34
1 files changed, 17 insertions, 17 deletions
diff --git a/src/state.cpp b/src/state.cpp
index b52bdb5..2678280 100644
--- a/src/state.cpp
+++ b/src/state.cpp
@@ -203,14 +203,14 @@ static void copy_one_time_settings( Universe* U, lua_State* L, lua_State* L2)
203 DEBUGSPEW_CODE( fprintf( stderr, INDENT_BEGIN "copy_one_time_settings()\n" INDENT_END)); 203 DEBUGSPEW_CODE( fprintf( stderr, INDENT_BEGIN "copy_one_time_settings()\n" INDENT_END));
204 DEBUGSPEW_CODE( ++ U->debugspew_indent_depth); 204 DEBUGSPEW_CODE( ++ U->debugspew_indent_depth);
205 205
206 CONFIG_REGKEY.query_registry(L); // config 206 CONFIG_REGKEY.pushValue(L); // config
207 // copy settings from from source to destination registry 207 // copy settings from from source to destination registry
208 if( luaG_inter_move( U, L, L2, 1, eLM_LaneBody) < 0) // // config 208 if( luaG_inter_move( U, L, L2, 1, eLM_LaneBody) < 0) // // config
209 { 209 {
210 (void) luaL_error( L, "failed to copy settings when loading lanes.core"); 210 (void) luaL_error( L, "failed to copy settings when loading lanes.core");
211 } 211 }
212 // set L2:_R[CONFIG_REGKEY] = settings 212 // set L2:_R[CONFIG_REGKEY] = settings
213 CONFIG_REGKEY.set_registry(L2, [](lua_State* L) { lua_insert(L, -2); }); // config 213 CONFIG_REGKEY.setValue(L2, [](lua_State* L) { lua_insert(L, -2); }); // config
214 STACK_CHECK( L2, 0); 214 STACK_CHECK( L2, 0);
215 STACK_CHECK( L, 0); 215 STACK_CHECK( L, 0);
216 DEBUGSPEW_CODE( -- U->debugspew_indent_depth); 216 DEBUGSPEW_CODE( -- U->debugspew_indent_depth);
@@ -273,43 +273,43 @@ lua_State* create_state( Universe* U, lua_State* from_)
273 273
274 if (L == nullptr) 274 if (L == nullptr)
275 { 275 {
276 (void) luaL_error( from_, "luaG_newstate() failed while creating state; out of memory"); 276 std::ignore = luaL_error( from_, "luaG_newstate() failed while creating state; out of memory");
277 } 277 }
278 return L; 278 return L;
279} 279}
280 280
281void call_on_state_create( Universe* U, lua_State* L, lua_State* from_, LookupMode mode_) 281void call_on_state_create(Universe* U, lua_State* L, lua_State* from_, LookupMode mode_)
282{ 282{
283 if (U->on_state_create_func != nullptr) 283 if (U->on_state_create_func != nullptr)
284 { 284 {
285 STACK_CHECK_START_REL(L, 0); 285 STACK_CHECK_START_REL(L, 0);
286 DEBUGSPEW_CODE( fprintf( stderr, INDENT_BEGIN "calling on_state_create()\n" INDENT_END)); 286 DEBUGSPEW_CODE(fprintf(stderr, INDENT_BEGIN "calling on_state_create()\n" INDENT_END));
287 if( U->on_state_create_func != (lua_CFunction) initialize_on_state_create) 287 if (U->on_state_create_func != (lua_CFunction) initialize_on_state_create)
288 { 288 {
289 // C function: recreate a closure in the new state, bypassing the lookup scheme 289 // C function: recreate a closure in the new state, bypassing the lookup scheme
290 lua_pushcfunction( L, U->on_state_create_func); // on_state_create() 290 lua_pushcfunction(L, U->on_state_create_func); // on_state_create()
291 } 291 }
292 else // Lua function located in the config table, copied when we opened "lanes.core" 292 else // Lua function located in the config table, copied when we opened "lanes.core"
293 { 293 {
294 if( mode_ != eLM_LaneBody) 294 if (mode_ != eLM_LaneBody)
295 { 295 {
296 // if attempting to call in a keeper state, do nothing because the function doesn't exist there 296 // if attempting to call in a keeper state, do nothing because the function doesn't exist there
297 // this doesn't count as an error though 297 // this doesn't count as an error though
298 STACK_CHECK(L, 0); 298 STACK_CHECK(L, 0);
299 return; 299 return;
300 } 300 }
301 CONFIG_REGKEY.query_registry(L); // {} 301 CONFIG_REGKEY.pushValue(L); // {}
302 STACK_CHECK( L, 1); 302 STACK_CHECK(L, 1);
303 lua_getfield( L, -1, "on_state_create"); // {} on_state_create() 303 lua_getfield(L, -1, "on_state_create"); // {} on_state_create()
304 lua_remove( L, -2); // on_state_create() 304 lua_remove(L, -2); // on_state_create()
305 } 305 }
306 STACK_CHECK( L, 1); 306 STACK_CHECK(L, 1);
307 // capture error and raise it in caller state 307 // capture error and raise it in caller state
308 if( lua_pcall( L, 0, 0, 0) != LUA_OK) 308 if (lua_pcall(L, 0, 0, 0) != LUA_OK)
309 { 309 {
310 luaL_error( from_, "on_state_create failed: \"%s\"", lua_isstring( L, -1) ? lua_tostring( L, -1) : lua_typename( L, lua_type( L, -1))); 310 luaL_error(from_, "on_state_create failed: \"%s\"", lua_isstring(L, -1) ? lua_tostring(L, -1) : lua_typename(L, lua_type(L, -1)));
311 } 311 }
312 STACK_CHECK( L, 0); 312 STACK_CHECK(L, 0);
313 } 313 }
314} 314}
315 315
@@ -339,7 +339,7 @@ lua_State* luaG_newstate( Universe* U, lua_State* from_, char const* libs_)
339 STACK_CHECK(L, 0); 339 STACK_CHECK(L, 0);
340 340
341 // we'll need this every time we transfer some C function from/to this state 341 // we'll need this every time we transfer some C function from/to this state
342 LOOKUP_REGKEY.set_registry(L, [](lua_State* L) { lua_newtable(L); }); 342 LOOKUP_REGKEY.setValue(L, [](lua_State* L) { lua_newtable(L); });
343 STACK_CHECK(L, 0); 343 STACK_CHECK(L, 0);
344 344
345 // neither libs (not even 'base') nor special init func: we are done 345 // neither libs (not even 'base') nor special init func: we are done