Skip to content

Commit

Permalink
fix lua::create_lambda and lua::create_lambda_nothrow
Browse files Browse the repository at this point in the history
  • Loading branch information
MihailRis committed Jan 13, 2025
1 parent 390d54c commit b9707e1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/logic/scripting/lua/lua_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,9 @@ KeyCallback lua::create_simple_handler(State* L) {
scripting::common_func lua::create_lambda(State* L) {
auto funcptr = create_lambda_handler(L);
return [=](const std::vector<dv::value>& args) -> dv::value {
int top = gettop(L) + 1;
if (!get_from(L, LAMBDAS_TABLE, *funcptr, false))
return nullptr;
int top = gettop(L) + 1;
for (const auto& arg : args) {
pushvalue(L, arg);
}
Expand All @@ -290,9 +290,9 @@ scripting::common_func lua::create_lambda(State* L) {
scripting::common_func lua::create_lambda_nothrow(State* L) {
auto funcptr = create_lambda_handler(L);
return [=](const std::vector<dv::value>& args) -> dv::value {
int top = gettop(L) - 1;
if (!get_from(L, LAMBDAS_TABLE, *funcptr, false))
return nullptr;
int top = gettop(L) - 1;
for (const auto& arg : args) {
pushvalue(L, arg);
}
Expand Down
5 changes: 5 additions & 0 deletions src/logic/scripting/lua/lua_wrapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ namespace lua {
}

inline void pop(lua::State* L, int n = 1) {
#ifndef NDEBUG
if (lua_gettop(L) < n) {
abort();
}
#endif
lua_pop(L, n);
}
inline void insert(lua::State* L, int idx) {
Expand Down

0 comments on commit b9707e1

Please sign in to comment.