aboutsummaryrefslogtreecommitdiff
path: root/src/lanes.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/lanes.cpp')
-rw-r--r--src/lanes.cpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/lanes.cpp b/src/lanes.cpp
index a68c3aa..74e2507 100644
--- a/src/lanes.cpp
+++ b/src/lanes.cpp
@@ -395,9 +395,8 @@ LUAG_FUNC(lane_new)
395 raise_luaL_error(L_, "required module list should be a list of strings"); 395 raise_luaL_error(L_, "required module list should be a list of strings");
396 } else { 396 } else {
397 // require the module in the target state, and populate the lookup table there too 397 // require the module in the target state, and populate the lookup table there too
398 size_t _len{ 0 }; 398 std::string_view const _name{ lua_tostringview(L_, -1) };
399 char const* _name{ lua_tolstring(L_, -1, &_len) }; 399 DEBUGSPEW_CODE(fprintf(stderr, INDENT_BEGIN "lane_new: require '%s'\n" INDENT_END(_U), _name.data()));
400 DEBUGSPEW_CODE(fprintf(stderr, INDENT_BEGIN "lane_new: require '%s'\n" INDENT_END(_U), name));
401 400
402 // require the module in the target lane 401 // require the module in the target lane
403 lua_getglobal(_L2, "require"); // L_: [fixed] args... n "modname" L2: require()? 402 lua_getglobal(_L2, "require"); // L_: [fixed] args... n "modname" L2: require()?
@@ -405,7 +404,7 @@ LUAG_FUNC(lane_new)
405 lua_pop(_L2, 1); // L_: [fixed] args... n "modname" L2: 404 lua_pop(_L2, 1); // L_: [fixed] args... n "modname" L2:
406 raise_luaL_error(L_, "cannot pre-require modules without loading 'package' library first"); 405 raise_luaL_error(L_, "cannot pre-require modules without loading 'package' library first");
407 } else { 406 } else {
408 lua_pushlstring(_L2, _name, _len); // L_: [fixed] args... n "modname" L2: require() name 407 lua_pushlstring(_L2, _name.data(), _name.size()); // L_: [fixed] args... n "modname" L2: require() name
409 LuaError const _rc{ lua_pcall(_L2, 1, 1, 0) }; // L_: [fixed] args... n "modname" L2: ret/errcode 408 LuaError const _rc{ lua_pcall(_L2, 1, 1, 0) }; // L_: [fixed] args... n "modname" L2: ret/errcode
410 if (_rc != LuaError::OK) { 409 if (_rc != LuaError::OK) {
411 // propagate error to main state if any 410 // propagate error to main state if any
@@ -415,7 +414,7 @@ LUAG_FUNC(lane_new)
415 } 414 }
416 // here the module was successfully required // L_: [fixed] args... n "modname" L2: ret 415 // here the module was successfully required // L_: [fixed] args... n "modname" L2: ret
417 // after requiring the module, register the functions it exported in our name<->function database 416 // after requiring the module, register the functions it exported in our name<->function database
418 populate_func_lookup_table(_L2, -1, _name); 417 populate_func_lookup_table(_L2, -1, _name.data());
419 lua_pop(_L2, 1); // L_: [fixed] args... n "modname" L2: 418 lua_pop(_L2, 1); // L_: [fixed] args... n "modname" L2:
420 } 419 }
421 } 420 }