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::expectedtype, 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::LuaResultinstead 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::gethas been added to mimicluabridge::push. - Free function
luabridge::LuaRef luabridge::getGlobalRefhas been added.
Breaking changes
-
luabridge::Stack<T>::getnow takes astd::error_code&as last parameter and should never callluaL_errordirectly, allowing to be used safely in methods likeluabridge::getGlobalorluabridge::get. -
T luabridge::LuaRef::cast<T>becameluabridge::expected<T, std::error_code> LuaRef::cast<T> -
T luabridge::getGlobalbecameluabridge::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