diff options
author | Benoit Germain <benoit.germain@ubisoft.com> | 2024-05-20 12:13:13 +0200 |
---|---|---|
committer | Benoit Germain <benoit.germain@ubisoft.com> | 2024-05-20 12:13:13 +0200 |
commit | 5e5f08558010890206e1d2d11045870c35eb23cf (patch) | |
tree | ed4ae3ce5e5cc1a15eaf5bb1f4e7527d86f10351 /src | |
parent | 4d0d86f197eda7215a259286d8791efe27df8bde (diff) | |
download | lanes-5e5f08558010890206e1d2d11045870c35eb23cf.tar.gz lanes-5e5f08558010890206e1d2d11045870c35eb23cf.tar.bz2 lanes-5e5f08558010890206e1d2d11045870c35eb23cf.zip |
Fixed forgotten int → LuaError
Diffstat (limited to 'src')
-rw-r--r-- | src/deep.cpp | 5 | ||||
-rw-r--r-- | src/lanes.cpp | 7 | ||||
-rw-r--r-- | src/linda.cpp | 4 | ||||
-rw-r--r-- | src/state.cpp | 4 |
4 files changed, 10 insertions, 10 deletions
diff --git a/src/deep.cpp b/src/deep.cpp index 5515a62..1685ebb 100644 --- a/src/deep.cpp +++ b/src/deep.cpp | |||
@@ -256,11 +256,10 @@ char const* DeepFactory::PushDeepProxy(DestState L_, DeepPrelude* prelude_, int | |||
256 | lua_rawget(L_, -2); // L_: DPC proxy metatable require() "module" _R._LOADED module | 256 | lua_rawget(L_, -2); // L_: DPC proxy metatable require() "module" _R._LOADED module |
257 | int const alreadyloaded = lua_toboolean(L_, -1); | 257 | int const alreadyloaded = lua_toboolean(L_, -1); |
258 | if (!alreadyloaded) { // not loaded | 258 | if (!alreadyloaded) { // not loaded |
259 | int require_result; | ||
260 | lua_pop(L_, 2); // L_: DPC proxy metatable require() "module" | 259 | lua_pop(L_, 2); // L_: DPC proxy metatable require() "module" |
261 | // require "modname" | 260 | // require "modname" |
262 | require_result = lua_pcall(L_, 1, 0, 0); // L_: DPC proxy metatable error? | 261 | LuaError const _require_result{ lua_pcall(L_, 1, 0, 0) }; // L_: DPC proxy metatable error? |
263 | if (require_result != LUA_OK) { | 262 | if (_require_result != LuaError::OK) { |
264 | // failed, return the error message | 263 | // failed, return the error message |
265 | lua_pushfstring(L_, "error while requiring '%s' identified by DeepFactory::moduleName: ", _modname.data()); | 264 | lua_pushfstring(L_, "error while requiring '%s' identified by DeepFactory::moduleName: ", _modname.data()); |
266 | lua_insert(L_, -2); // L_: DPC proxy metatable prefix error | 265 | lua_insert(L_, -2); // L_: DPC proxy metatable prefix error |
diff --git a/src/lanes.cpp b/src/lanes.cpp index aa614b7..a68c3aa 100644 --- a/src/lanes.cpp +++ b/src/lanes.cpp | |||
@@ -406,7 +406,8 @@ LUAG_FUNC(lane_new) | |||
406 | raise_luaL_error(L_, "cannot pre-require modules without loading 'package' library first"); | 406 | raise_luaL_error(L_, "cannot pre-require modules without loading 'package' library first"); |
407 | } else { | 407 | } else { |
408 | lua_pushlstring(_L2, _name, _len); // L_: [fixed] args... n "modname" L2: require() name | 408 | lua_pushlstring(_L2, _name, _len); // L_: [fixed] args... n "modname" L2: require() name |
409 | if (lua_pcall(_L2, 1, 1, 0) != LUA_OK) { // L_: [fixed] args... n "modname" L2: ret/errcode | 409 | LuaError const _rc{ lua_pcall(_L2, 1, 1, 0) }; // L_: [fixed] args... n "modname" L2: ret/errcode |
410 | if (_rc != LuaError::OK) { | ||
410 | // propagate error to main state if any | 411 | // propagate error to main state if any |
411 | InterCopyContext _c{ _U, DestState{ L_ }, SourceState{ _L2 }, {}, {}, {}, {}, {} }; | 412 | InterCopyContext _c{ _U, DestState{ L_ }, SourceState{ _L2 }, {}, {}, {}, {}, {} }; |
412 | std::ignore = _c.inter_move(1); // L_: [fixed] args... n "modname" error L2: | 413 | std::ignore = _c.inter_move(1); // L_: [fixed] args... n "modname" error L2: |
@@ -870,8 +871,8 @@ LANES_API int luaopen_lanes_core(lua_State* L_) | |||
870 | 871 | ||
871 | [[nodiscard]] static int default_luaopen_lanes(lua_State* L_) | 872 | [[nodiscard]] static int default_luaopen_lanes(lua_State* L_) |
872 | { | 873 | { |
873 | int const _rc{ luaL_loadfile(L_, "lanes.lua") || lua_pcall(L_, 0, 1, 0) }; | 874 | LuaError const _rc{ luaL_loadfile(L_, "lanes.lua") || lua_pcall(L_, 0, 1, 0) }; |
874 | if (_rc != LUA_OK) { | 875 | if (_rc != LuaError::OK) { |
875 | raise_luaL_error(L_, "failed to initialize embedded Lanes"); | 876 | raise_luaL_error(L_, "failed to initialize embedded Lanes"); |
876 | } | 877 | } |
877 | return 1; | 878 | return 1; |
diff --git a/src/linda.cpp b/src/linda.cpp index 01b089e..76607a4 100644 --- a/src/linda.cpp +++ b/src/linda.cpp | |||
@@ -165,7 +165,7 @@ int Linda::ProtectedCall(lua_State* L_, lua_CFunction f_) | |||
165 | lua_pushcfunction(L_, f_); | 165 | lua_pushcfunction(L_, f_); |
166 | lua_insert(L_, 1); | 166 | lua_insert(L_, 1); |
167 | // do a protected call | 167 | // do a protected call |
168 | int const _rc{ lua_pcall(L_, lua_gettop(L_) - 1, LUA_MULTRET, 0) }; | 168 | LuaError const _rc{ lua_pcall(L_, lua_gettop(L_) - 1, LUA_MULTRET, 0) }; |
169 | // whatever happens, the keeper state stack must be empty when we are done | 169 | // whatever happens, the keeper state stack must be empty when we are done |
170 | lua_settop(_KL, 0); | 170 | lua_settop(_KL, 0); |
171 | 171 | ||
@@ -173,7 +173,7 @@ int Linda::ProtectedCall(lua_State* L_, lua_CFunction f_) | |||
173 | _linda->releaseKeeper(_K); | 173 | _linda->releaseKeeper(_K); |
174 | 174 | ||
175 | // if there was an error, forward it | 175 | // if there was an error, forward it |
176 | if (_rc != LUA_OK) { | 176 | if (_rc != LuaError::OK) { |
177 | raise_lua_error(L_); | 177 | raise_lua_error(L_); |
178 | } | 178 | } |
179 | // return whatever the actual operation provided | 179 | // return whatever the actual operation provided |
diff --git a/src/state.cpp b/src/state.cpp index a6c9859..e258f9e 100644 --- a/src/state.cpp +++ b/src/state.cpp | |||
@@ -67,12 +67,12 @@ THE SOFTWARE. | |||
67 | 67 | ||
68 | _U->requireMutex.lock(); | 68 | _U->requireMutex.lock(); |
69 | // starting with Lua 5.4, require may return a second optional value, so we need LUA_MULTRET | 69 | // starting with Lua 5.4, require may return a second optional value, so we need LUA_MULTRET |
70 | int _rc{ lua_pcall(L_, _args, LUA_MULTRET, 0 /*errfunc*/) }; // L_: err|result(s) | 70 | LuaError const _rc{ lua_pcall(L_, _args, LUA_MULTRET, 0 /*errfunc*/) }; // L_: err|result(s) |
71 | _U->requireMutex.unlock(); | 71 | _U->requireMutex.unlock(); |
72 | 72 | ||
73 | // the required module (or an error message) is left on the stack as returned value by original require function | 73 | // the required module (or an error message) is left on the stack as returned value by original require function |
74 | 74 | ||
75 | if (_rc != LUA_OK) { // LUA_ERRRUN / LUA_ERRMEM ? | 75 | if (_rc != LuaError::OK) { // LUA_ERRRUN / LUA_ERRMEM ? |
76 | raise_lua_error(L_); | 76 | raise_lua_error(L_); |
77 | } | 77 | } |
78 | // should be 1 for Lua <= 5.3, 1 or 2 starting with Lua 5.4 | 78 | // should be 1 for Lua <= 5.3, 1 or 2 starting with Lua 5.4 |