diff options
Diffstat (limited to 'src/intercopycontext.cpp')
-rw-r--r-- | src/intercopycontext.cpp | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/intercopycontext.cpp b/src/intercopycontext.cpp index 6c72b1c..893305e 100644 --- a/src/intercopycontext.cpp +++ b/src/intercopycontext.cpp | |||
@@ -29,6 +29,7 @@ THE SOFTWARE. | |||
29 | #include "debugspew.h" | 29 | #include "debugspew.h" |
30 | #include "deep.h" | 30 | #include "deep.h" |
31 | #include "keeper.h" | 31 | #include "keeper.h" |
32 | #include "lane.h" | ||
32 | #include "linda.h" | 33 | #include "linda.h" |
33 | #include "universe.h" | 34 | #include "universe.h" |
34 | 35 | ||
@@ -106,11 +107,11 @@ THE SOFTWARE. | |||
106 | if (_fqn.empty() && !lua_istable(L1, L1_i)) { // raise an error if we try to send an unknown function (but not for tables) | 107 | if (_fqn.empty() && !lua_istable(L1, L1_i)) { // raise an error if we try to send an unknown function (but not for tables) |
107 | _fqn = std::string_view{}; // just in case | 108 | _fqn = std::string_view{}; // just in case |
108 | // try to discover the name of the function we want to send | 109 | // try to discover the name of the function we want to send |
109 | lua_getglobal(L1, "decoda_name"); // L1: ... v ... decoda_name | 110 | kLaneNameRegKey.pushValue(L1); // L1: ... v ... lane_name |
110 | char const* _from{ lua_tostring(L1, -1) }; | 111 | char const* _from{ lua_tostring(L1, -1) }; |
111 | lua_pushcfunction(L1, luaG_nameof); // L1: ... v ... decoda_name luaG_nameof | 112 | lua_pushcfunction(L1, luaG_nameof); // L1: ... v ... lane_name luaG_nameof |
112 | lua_pushvalue(L1, L1_i); // L1: ... v ... decoda_name luaG_nameof t | 113 | lua_pushvalue(L1, L1_i); // L1: ... v ... lane_name luaG_nameof t |
113 | lua_call(L1, 1, 2); // L1: ... v ... decoda_name "type" "name"|nil | 114 | lua_call(L1, 1, 2); // L1: ... v ... lane_name "type" "name"|nil |
114 | char const* _typewhat{ (lua_type(L1, -2) == LUA_TSTRING) ? lua_tostring(L1, -2) : luaL_typename(L1, -2) }; | 115 | char const* _typewhat{ (lua_type(L1, -2) == LUA_TSTRING) ? lua_tostring(L1, -2) : luaL_typename(L1, -2) }; |
115 | // second return value can be nil if the table was not found | 116 | // second return value can be nil if the table was not found |
116 | // probable reason: the function was removed from the source Lua state before Lanes was required. | 117 | // probable reason: the function was removed from the source Lua state before Lanes was required. |
@@ -325,10 +326,10 @@ void InterCopyContext::lookup_native_func() const | |||
325 | // nil means we don't know how to transfer stuff: user should do something | 326 | // nil means we don't know how to transfer stuff: user should do something |
326 | // anything other than function or table should not happen! | 327 | // anything other than function or table should not happen! |
327 | if (!lua_isfunction(L2, -1) && !lua_istable(L2, -1)) { | 328 | if (!lua_isfunction(L2, -1) && !lua_istable(L2, -1)) { |
328 | lua_getglobal(L1, "decoda_name"); // L1: ... f ... decoda_name | 329 | kLaneNameRegKey.pushValue(L1); // L1: ... f ... lane_name |
329 | char const* const _from{ lua_tostring(L1, -1) }; | 330 | char const* const _from{ lua_tostring(L1, -1) }; |
330 | lua_pop(L1, 1); // L1: ... f ... | 331 | lua_pop(L1, 1); // L1: ... f ... |
331 | lua_getglobal(L2, "decoda_name"); // L1: ... f ... L2: {} f decoda_name | 332 | kLaneNameRegKey.pushValue(L2); // L1: ... f ... L2: {} f lane_name |
332 | char const* const _to{ lua_tostring(L2, -1) }; | 333 | char const* const _to{ lua_tostring(L2, -1) }; |
333 | lua_pop(L2, 1); // L2: {} f | 334 | lua_pop(L2, 1); // L2: {} f |
334 | // when mode_ == LookupMode::FromKeeper, L is a keeper state and L2 is not, therefore L2 is the state where we want to raise the error | 335 | // when mode_ == LookupMode::FromKeeper, L is a keeper state and L2 is not, therefore L2 is the state where we want to raise the error |
@@ -449,10 +450,10 @@ void InterCopyContext::copy_cached_func() const | |||
449 | STACK_CHECK(L2, 0); | 450 | STACK_CHECK(L2, 0); |
450 | return false; | 451 | 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 | 452 | } 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 | 453 | kLaneNameRegKey.pushValue(L1); // L1: ... t ... lane_name |
453 | char const* _from{ lua_tostring(L1, -1) }; | 454 | char const* _from{ lua_tostring(L1, -1) }; |
454 | lua_pop(L1, 1); // L1: ... t ... | 455 | lua_pop(L1, 1); // L1: ... t ... |
455 | lua_getglobal(L2, "decoda_name"); // L1: ... t ... L2: {} t decoda_name | 456 | kLaneNameRegKey.pushValue(L2); // L1: ... t ... L2: {} t lane_name |
456 | char const* _to{ lua_tostring(L2, -1) }; | 457 | char const* _to{ lua_tostring(L2, -1) }; |
457 | lua_pop(L2, 1); // L1: ... t ... L2: {} t | 458 | lua_pop(L2, 1); // L1: ... t ... L2: {} t |
458 | raise_luaL_error( | 459 | raise_luaL_error( |