diff options
| author | Benoit Germain <benoit.germain@ubisoft.com> | 2026-03-02 18:28:54 +0100 |
|---|---|---|
| committer | Benoit Germain <benoit.germain@ubisoft.com> | 2026-03-02 18:28:54 +0100 |
| commit | 2b5086f4e794b0b83b1493de80eb6e4b6c67797b (patch) | |
| tree | 7f69cb1c884e3e24524354fd696794256db93e41 /src | |
| parent | 4eb317406d5e9d0337510a3d965f0ed7f313d7f2 (diff) | |
| download | lanes-2b5086f4e794b0b83b1493de80eb6e4b6c67797b.tar.gz lanes-2b5086f4e794b0b83b1493de80eb6e4b6c67797b.tar.bz2 lanes-2b5086f4e794b0b83b1493de80eb6e4b6c67797b.zip | |
lane_new internal code cleanup step 6: TransferArguments
Diffstat (limited to 'src')
| -rw-r--r-- | src/lanes.cpp | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/src/lanes.cpp b/src/lanes.cpp index b0e0bcf..17380f6 100644 --- a/src/lanes.cpp +++ b/src/lanes.cpp | |||
| @@ -397,6 +397,21 @@ namespace { | |||
| 397 | } | 397 | } |
| 398 | return _errorHandlerCount; | 398 | return _errorHandlerCount; |
| 399 | } | 399 | } |
| 400 | |||
| 401 | // Inter-move nargs_ values from L_ into L2_. No-op when nargs_ is zero. | ||
| 402 | static void TransferArguments(Universe* const U_, lua_State* const L_, lua_State* const L2_, int const nargs_) | ||
| 403 | { | ||
| 404 | if (nargs_ == 0) { | ||
| 405 | return; | ||
| 406 | } | ||
| 407 | DEBUGSPEW_CODE(DebugSpew(U_) << "lane_new: transfer lane arguments" << std::endl); | ||
| 408 | DEBUGSPEW_CODE(DebugSpewIndentScope _scope{ U_ }); | ||
| 409 | InterCopyContext _c{ U_, DestState{ L2_ }, SourceState{ L_ }, {}, {}, {}, {}, {} }; | ||
| 410 | InterCopyResult const _res{ _c.interMove(nargs_) }; // L_: [fixed] L2: eh? func args... | ||
| 411 | if (_res != InterCopyResult::Success) { | ||
| 412 | raise_luaL_error(L_, "tried to copy unsupported types"); | ||
| 413 | } | ||
| 414 | } | ||
| 400 | } // namespace local | 415 | } // namespace local |
| 401 | } // namespace | 416 | } // namespace |
| 402 | 417 | ||
| @@ -599,15 +614,7 @@ LUAG_FUNC(lane_new) | |||
| 599 | LUA_ASSERT(L_, lua_isfunction(_L2, _errorHandlerCount + 1)); | 614 | LUA_ASSERT(L_, lua_isfunction(_L2, _errorHandlerCount + 1)); |
| 600 | 615 | ||
| 601 | // revive arguments | 616 | // revive arguments |
| 602 | if (_nargs > 0) { | 617 | local::TransferArguments(_U, L_, _L2, _nargs); |
| 603 | DEBUGSPEW_CODE(DebugSpew(_U) << "lane_new: transfer lane arguments" << std::endl); | ||
| 604 | DEBUGSPEW_CODE(DebugSpewIndentScope _scope{ _U }); | ||
| 605 | InterCopyContext _c{ _U, DestState{ _L2 }, SourceState{ L_ }, {}, {}, {}, {}, {} }; | ||
| 606 | InterCopyResult const res{ _c.interMove(_nargs) }; // L_: [fixed] L2: eh? func args... | ||
| 607 | if (res != InterCopyResult::Success) { | ||
| 608 | raise_luaL_error(L_, "tried to copy unsupported types"); | ||
| 609 | } | ||
| 610 | } | ||
| 611 | STACK_CHECK(L_, -_nargs); | 618 | STACK_CHECK(L_, -_nargs); |
| 612 | LUA_ASSERT(L_, lua_gettop(L_) == kFixedArgsIdx); | 619 | LUA_ASSERT(L_, lua_gettop(L_) == kFixedArgsIdx); |
| 613 | STACK_CHECK(_L2, _errorHandlerCount + 1 + _nargs); | 620 | STACK_CHECK(_L2, _errorHandlerCount + 1 + _nargs); |
