LuaBridge3
LuaBridge3 copied to clipboard
Introduce expected, safety when calling Stack::get without exceptions
This PR aims at improving safety of interacting with Stack objects:
- Introduced the
luabridge::expected
type, that works similarly as http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p0323r10.html, in order to hold the result ofluabridge::LuaRef::cast<T>
and for holding the result of aluabridge::LuaResult
instead of raising an exception (or going UB with exceptions disabled). - The previous
T luabridge::LuaRef::cast<T>
has been preserved with a more explicit nameT luabridge::LuaRef::unsafe_cast<T>
-
luabridge::get
has been added to mimicluabridge::push
. - Free function
luabridge::LuaRef luabridge::getGlobalRef
has been added.
Breaking changes
-
luabridge::Stack<T>::get
now takes astd::error_code&
as last parameter and should never callluaL_error
directly, allowing to be used safely in methods likeluabridge::getGlobal
orluabridge::get
. -
T luabridge::LuaRef::cast<T>
becameluabridge::expected<T, std::error_code> LuaRef::cast<T>
-
T luabridge::getGlobal
becameluabridge::expected<T, std::error_code> luabridge::getGlobal
WIP
- [ ] Adapt Stack
to handle std::error_code - [ ] fix Userdata::get to handle std::error_code
- [ ] fix remaing Stack::get to never call luaL_error