From 882f337c483743e94e376f6d7fb17ffac3fee92a Mon Sep 17 00:00:00 2001 From: ThePhD Date: Thu, 26 Oct 2017 13:15:02 -0400 Subject: [PATCH] vet propagation handlers --- single/sol/sol.hpp | 30 +++++++++++++++++++----------- sol/protected_function.hpp | 4 +++- sol/types.hpp | 22 ++++++++++++++-------- 3 files changed, 36 insertions(+), 20 deletions(-) diff --git a/single/sol/sol.hpp b/single/sol/sol.hpp index 7a3ad9ed..73ace2c3 100644 --- a/single/sol/sol.hpp +++ b/single/sol/sol.hpp @@ -20,8 +20,8 @@ // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // This file was generated with a script. -// Generated 2017-10-26 17:02:46.122060 UTC -// This header was generated with sol v2.18.5 (revision d107cb8) +// Generated 2017-10-26 17:14:51.531340 UTC +// This header was generated with sol v2.18.5 (revision 540d322) // https://github.com/ThePhD/sol2 #ifndef SOL_SINGLE_INCLUDE_HPP @@ -4395,10 +4395,12 @@ namespace sol { #else template int static_trampoline(lua_State* L) { - try { - return f(L); - } #if !defined(SOL_EXCEPTIONS_SAFE_PROPAGATION) + try { +#endif + return f(L); +#if !defined(SOL_EXCEPTIONS_SAFE_PROPAGATION) + } catch (const char* s) { lua_pushstring(L, s); } @@ -4408,8 +4410,9 @@ namespace sol { catch (...) { lua_pushstring(L, "caught (...) exception"); } -#endif + return lua_error(L); +#endif } #ifdef SOL_NOEXCEPT_FUNCTION_TYPE @@ -4439,10 +4442,12 @@ namespace sol { if (meta::bind_traits>::is_noexcept) { return f(L, std::forward(args)...); } - try { - return f(L, std::forward(args)...); - } #if !defined(SOL_EXCEPTIONS_SAFE_PROPAGATION) + try { +#endif + return f(L, std::forward(args)...); +#if !defined(SOL_EXCEPTIONS_SAFE_PROPAGATION) + } catch (const char* s) { lua_pushstring(L, s); } @@ -4452,8 +4457,9 @@ namespace sol { catch (...) { lua_pushstring(L, "caught (...) exception"); } -#endif + return lua_error(L); +#endif } inline int c_trampoline(lua_State* L, lua_CFunction f) { @@ -13099,15 +13105,17 @@ namespace sol { stack::push(lua_state(), error); } }; +#if !defined(SOL_EXCEPTIONS_SAFE_PROPAGATION) try { +#endif #endif // No Exceptions firstreturn = (std::max)(1, static_cast(stacksize - n - static_cast(h.valid()))); code = luacall(n, LUA_MULTRET, h); poststacksize = lua_gettop(lua_state()) - static_cast(h.valid()); returncount = poststacksize - (firstreturn - 1); #ifndef SOL_NO_EXCEPTIONS - } #if !defined(SOL_EXCEPTIONS_SAFE_PROPAGATION) + } // Handle C++ errors thrown from C++ functions bound inside of lua catch (const char* error) { onexcept(error); diff --git a/sol/protected_function.hpp b/sol/protected_function.hpp index 3b865b1a..72cb9877 100644 --- a/sol/protected_function.hpp +++ b/sol/protected_function.hpp @@ -150,15 +150,17 @@ namespace sol { stack::push(lua_state(), error); } }; +#if !defined(SOL_EXCEPTIONS_SAFE_PROPAGATION) try { +#endif #endif // No Exceptions firstreturn = (std::max)(1, static_cast(stacksize - n - static_cast(h.valid()))); code = luacall(n, LUA_MULTRET, h); poststacksize = lua_gettop(lua_state()) - static_cast(h.valid()); returncount = poststacksize - (firstreturn - 1); #ifndef SOL_NO_EXCEPTIONS - } #if !defined(SOL_EXCEPTIONS_SAFE_PROPAGATION) + } // Handle C++ errors thrown from C++ functions bound inside of lua catch (const char* error) { onexcept(error); diff --git a/sol/types.hpp b/sol/types.hpp index f36d14db..b9c70235 100644 --- a/sol/types.hpp +++ b/sol/types.hpp @@ -70,10 +70,12 @@ namespace sol { #else template int static_trampoline(lua_State* L) { - try { - return f(L); - } #if !defined(SOL_EXCEPTIONS_SAFE_PROPAGATION) + try { +#endif + return f(L); +#if !defined(SOL_EXCEPTIONS_SAFE_PROPAGATION) + } catch (const char* s) { lua_pushstring(L, s); } @@ -83,8 +85,9 @@ namespace sol { catch (...) { lua_pushstring(L, "caught (...) exception"); } -#endif + return lua_error(L); +#endif } #ifdef SOL_NOEXCEPT_FUNCTION_TYPE @@ -114,10 +117,12 @@ namespace sol { if (meta::bind_traits>::is_noexcept) { return f(L, std::forward(args)...); } - try { - return f(L, std::forward(args)...); - } #if !defined(SOL_EXCEPTIONS_SAFE_PROPAGATION) + try { +#endif + return f(L, std::forward(args)...); +#if !defined(SOL_EXCEPTIONS_SAFE_PROPAGATION) + } catch (const char* s) { lua_pushstring(L, s); } @@ -127,8 +132,9 @@ namespace sol { catch (...) { lua_pushstring(L, "caught (...) exception"); } -#endif + return lua_error(L); +#endif } inline int c_trampoline(lua_State* L, lua_CFunction f) {