diff options
Diffstat (limited to 'src/intercopycontext.cpp')
-rw-r--r-- | src/intercopycontext.cpp | 58 |
1 files changed, 31 insertions, 27 deletions
diff --git a/src/intercopycontext.cpp b/src/intercopycontext.cpp index 67e4e03..6c72b1c 100644 --- a/src/intercopycontext.cpp +++ b/src/intercopycontext.cpp | |||
@@ -450,18 +450,18 @@ void InterCopyContext::copy_cached_func() const | |||
450 | return false; | 450 | return false; |
451 | } else if (!lua_istable(L2, -1)) { // this can happen if someone decides to replace same already registered item (for a example a standard lib function) with a table | 451 | } else if (!lua_istable(L2, -1)) { // this can happen if someone decides to replace same already registered item (for a example a standard lib function) with a table |
452 | lua_getglobal(L1, "decoda_name"); // L1: ... t ... decoda_name | 452 | lua_getglobal(L1, "decoda_name"); // L1: ... t ... decoda_name |
453 | char const* from{ lua_tostring(L1, -1) }; | 453 | char const* _from{ lua_tostring(L1, -1) }; |
454 | lua_pop(L1, 1); // L1: ... t ... | 454 | lua_pop(L1, 1); // L1: ... t ... |
455 | lua_getglobal(L2, "decoda_name"); // L1: ... t ... L2: {} t decoda_name | 455 | lua_getglobal(L2, "decoda_name"); // L1: ... t ... L2: {} t decoda_name |
456 | char const* to{ lua_tostring(L2, -1) }; | 456 | char const* _to{ lua_tostring(L2, -1) }; |
457 | lua_pop(L2, 1); // L1: ... t ... L2: {} t | 457 | lua_pop(L2, 1); // L1: ... t ... L2: {} t |
458 | raise_luaL_error( | 458 | raise_luaL_error( |
459 | getErrL(), | 459 | getErrL(), |
460 | "%s: source table '%s' found as %s in %s destination transfer database.", | 460 | "%s: source table '%s' found as %s in %s destination transfer database.", |
461 | from ? from : "main", | 461 | _from ? _from : "main", |
462 | _fqn, | 462 | _fqn, |
463 | lua_typename(L2, lua_type_as_enum(L2, -1)), | 463 | lua_typename(L2, lua_type_as_enum(L2, -1)), |
464 | to ? to : "main"); | 464 | _to ? _to : "main"); |
465 | } | 465 | } |
466 | lua_remove(L2, -2); // L1: ... t ... L2: t | 466 | lua_remove(L2, -2); // L1: ... t ... L2: t |
467 | break; | 467 | break; |
@@ -1051,24 +1051,28 @@ void InterCopyContext::inter_copy_keyvaluepair() const | |||
1051 | // ################################################################################################# | 1051 | // ################################################################################################# |
1052 | 1052 | ||
1053 | #if USE_DEBUG_SPEW() | 1053 | #if USE_DEBUG_SPEW() |
1054 | static char const* lua_type_names[] = { | 1054 | namespace { |
1055 | "LUA_TNIL" | 1055 | namespace local { |
1056 | , "LUA_TBOOLEAN" | 1056 | static std::string_view const sLuaTypeNames[] = { |
1057 | , "LUA_TLIGHTUSERDATA" | 1057 | "LUA_TNIL" |
1058 | , "LUA_TNUMBER" | 1058 | , "LUA_TBOOLEAN" |
1059 | , "LUA_TSTRING" | 1059 | , "LUA_TLIGHTUSERDATA" |
1060 | , "LUA_TTABLE" | 1060 | , "LUA_TNUMBER" |
1061 | , "LUA_TFUNCTION" | 1061 | , "LUA_TSTRING" |
1062 | , "LUA_TUSERDATA" | 1062 | , "LUA_TTABLE" |
1063 | , "LUA_TTHREAD" | 1063 | , "LUA_TFUNCTION" |
1064 | , "<LUA_NUMTAGS>" // not really a type | 1064 | , "LUA_TUSERDATA" |
1065 | , "LUA_TJITCDATA" // LuaJIT specific | 1065 | , "LUA_TTHREAD" |
1066 | }; | 1066 | , "<LUA_NUMTAGS>" // not really a type |
1067 | static char const* vt_names[] = { | 1067 | , "LUA_TJITCDATA" // LuaJIT specific |
1068 | "VT::NORMAL" | 1068 | }; |
1069 | , "VT::KEY" | 1069 | static std::string_view const sValueTypeNames[] = { |
1070 | , "VT::METATABLE" | 1070 | "VT::NORMAL" |
1071 | }; | 1071 | , "VT::KEY" |
1072 | , "VT::METATABLE" | ||
1073 | }; | ||
1074 | } | ||
1075 | } | ||
1072 | #endif // USE_DEBUG_SPEW() | 1076 | #endif // USE_DEBUG_SPEW() |
1073 | 1077 | ||
1074 | /* | 1078 | /* |
@@ -1092,7 +1096,7 @@ static char const* vt_names[] = { | |||
1092 | DEBUGSPEW_CODE(DebugSpewIndentScope _scope{ U }); | 1096 | DEBUGSPEW_CODE(DebugSpewIndentScope _scope{ U }); |
1093 | 1097 | ||
1094 | LuaType _val_type{ lua_type_as_enum(L1, L1_i) }; | 1098 | LuaType _val_type{ lua_type_as_enum(L1, L1_i) }; |
1095 | DEBUGSPEW_CODE(DebugSpew(U) << lua_type_names[static_cast<int>(_val_type)] << " " << vt_names[static_cast<int>(vt)] << ": "); | 1099 | DEBUGSPEW_CODE(DebugSpew(U) << local::sLuaTypeNames[static_cast<int>(_val_type)] << " " << local::sValueTypeNames[static_cast<int>(vt)] << ": "); |
1096 | 1100 | ||
1097 | // Non-POD can be skipped if its metatable contains { __lanesignore = true } | 1101 | // Non-POD can be skipped if its metatable contains { __lanesignore = true } |
1098 | if (((1 << static_cast<int>(_val_type)) & kPODmask) == 0) { | 1102 | if (((1 << static_cast<int>(_val_type)) & kPODmask) == 0) { |
@@ -1203,9 +1207,9 @@ static char const* vt_names[] = { | |||
1203 | // but don't copy it anyway, as the function names change depending on the slot index! | 1207 | // but don't copy it anyway, as the function names change depending on the slot index! |
1204 | // users should provide an on_state_create function to setup custom loaders instead | 1208 | // users should provide an on_state_create function to setup custom loaders instead |
1205 | // don't copy package.preload in keeper states (they don't know how to translate functions) | 1209 | // don't copy package.preload in keeper states (they don't know how to translate functions) |
1206 | char const* _entries[] = { "path", "cpath", (mode == LookupMode::LaneBody) ? "preload" : nullptr /*, (LUA_VERSION_NUM == 501) ? "loaders" : "searchers"*/, nullptr }; | 1210 | std::string_view const _entries[] = { "path", "cpath", (mode == LookupMode::LaneBody) ? "preload" : "" /*, (LUA_VERSION_NUM == 501) ? "loaders" : "searchers"*/, "" }; |
1207 | for (char const* const _entry : _entries) { | 1211 | for (std::string_view const& _entry : _entries) { |
1208 | if (!_entry) { | 1212 | if (_entry.empty()) { |
1209 | continue; | 1213 | continue; |
1210 | } | 1214 | } |
1211 | DEBUGSPEW_CODE(DebugSpew(U) << "package." << _entry << std::endl); | 1215 | DEBUGSPEW_CODE(DebugSpew(U) << "package." << _entry << std::endl); |
@@ -1218,7 +1222,7 @@ static char const* vt_names[] = { | |||
1218 | STACK_CHECK(L1, 0); | 1222 | STACK_CHECK(L1, 0); |
1219 | } | 1223 | } |
1220 | if (_result == InterCopyResult::Success) { | 1224 | if (_result == InterCopyResult::Success) { |
1221 | lua_setfield(L2, -2, _entry); // set package[entry] | 1225 | lua_setfield(L2, -2, _entry.data()); // set package[entry] |
1222 | } else { | 1226 | } else { |
1223 | lua_pushfstring(L1, "failed to copy package entry %s", _entry); | 1227 | lua_pushfstring(L1, "failed to copy package entry %s", _entry); |
1224 | // raise the error when copying from lane to lane, else just leave it on the stack to be raised later | 1228 | // raise the error when copying from lane to lane, else just leave it on the stack to be raised later |