mirror of
https://github.com/ThePhD/sol2.git
synced 2024-03-22 13:10:44 +08:00
attempt to wrangle exception handling on multiple systems
This commit is contained in:
parent
e667e69d89
commit
2d31d84070
|
@ -20,8 +20,8 @@
|
||||||
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
// This file was generated with a script.
|
// This file was generated with a script.
|
||||||
// Generated 2017-11-09 22:36:14.826447 UTC
|
// Generated 2017-11-11 12:41:27.450855 UTC
|
||||||
// This header was generated with sol v2.18.6 (revision 90bbead)
|
// This header was generated with sol v2.18.6 (revision e667e69)
|
||||||
// https://github.com/ThePhD/sol2
|
// https://github.com/ThePhD/sol2
|
||||||
|
|
||||||
#ifndef SOL_SINGLE_INCLUDE_HPP
|
#ifndef SOL_SINGLE_INCLUDE_HPP
|
||||||
|
@ -4408,13 +4408,16 @@ namespace sol {
|
||||||
try {
|
try {
|
||||||
return f(L);
|
return f(L);
|
||||||
}
|
}
|
||||||
catch (const char* s) {
|
catch (const char* cs) {
|
||||||
lua_pushstring(L, s);
|
lua_pushstring(L, cs);
|
||||||
|
}
|
||||||
|
catch (const std::string& s) {
|
||||||
|
lua_pushlstring(L, s.c_str(), s.size());
|
||||||
}
|
}
|
||||||
catch (const std::exception& e) {
|
catch (const std::exception& e) {
|
||||||
lua_pushstring(L, e.what());
|
lua_pushstring(L, e.what());
|
||||||
}
|
}
|
||||||
#if defined(SOL_EXCEPTIONS_SAFE_PROPAGATION) && defined(SOL_LUAJIT)
|
#if !defined(SOL_EXCEPTIONS_SAFE_PROPAGATION)
|
||||||
// LuaJIT cannot have the catchall when the safe propagation is on
|
// LuaJIT cannot have the catchall when the safe propagation is on
|
||||||
// but LuaJIT will swallow all C++ errors
|
// but LuaJIT will swallow all C++ errors
|
||||||
// if we don't at least catch std::exception ones
|
// if we don't at least catch std::exception ones
|
||||||
|
@ -4423,7 +4426,7 @@ namespace sol {
|
||||||
}
|
}
|
||||||
#endif // LuaJIT cannot have the catchall, but we must catch std::exceps for it
|
#endif // LuaJIT cannot have the catchall, but we must catch std::exceps for it
|
||||||
return lua_error(L);
|
return lua_error(L);
|
||||||
#endif
|
#endif // Safe exceptions
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef SOL_NOEXCEPT_FUNCTION_TYPE
|
#ifdef SOL_NOEXCEPT_FUNCTION_TYPE
|
||||||
|
@ -4465,7 +4468,7 @@ namespace sol {
|
||||||
catch (const std::exception& e) {
|
catch (const std::exception& e) {
|
||||||
lua_pushstring(L, e.what());
|
lua_pushstring(L, e.what());
|
||||||
}
|
}
|
||||||
#if defined(SOL_EXCEPTIONS_SAFE_PROPAGATION) && !defined(SOL_LUAJIT)
|
#if !defined(SOL_EXCEPTIONS_SAFE_PROPAGATION)
|
||||||
// LuaJIT cannot have the catchall when the safe propagation is on
|
// LuaJIT cannot have the catchall when the safe propagation is on
|
||||||
// but LuaJIT will swallow all C++ errors
|
// but LuaJIT will swallow all C++ errors
|
||||||
// if we don't at least catch std::exception ones
|
// if we don't at least catch std::exception ones
|
||||||
|
@ -13543,16 +13546,16 @@ namespace sol {
|
||||||
stack::push(lua_state(), error);
|
stack::push(lua_state(), error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
#if !defined(SOL_EXCEPTIONS_SAFE_PROPAGATION) || defined(SOL_LUAJIT)
|
#if defined(SOL_EXCEPTIONS_SAFE_PROPAGATION) && !defined(SOL_LUAJIT)
|
||||||
try {
|
try {
|
||||||
#endif
|
#endif // Safe Exception Propagation
|
||||||
#endif // No Exceptions
|
#endif // No Exceptions
|
||||||
firstreturn = (std::max)(1, static_cast<int>(stacksize - n - static_cast<int>(h.valid())));
|
firstreturn = (std::max)(1, static_cast<int>(stacksize - n - static_cast<int>(h.valid())));
|
||||||
code = luacall(n, LUA_MULTRET, h);
|
code = luacall(n, LUA_MULTRET, h);
|
||||||
poststacksize = lua_gettop(lua_state()) - static_cast<int>(h.valid());
|
poststacksize = lua_gettop(lua_state()) - static_cast<int>(h.valid());
|
||||||
returncount = poststacksize - (firstreturn - 1);
|
returncount = poststacksize - (firstreturn - 1);
|
||||||
#ifndef SOL_NO_EXCEPTIONS
|
#ifndef SOL_NO_EXCEPTIONS
|
||||||
#if !defined(SOL_EXCEPTIONS_SAFE_PROPAGATION) || defined(SOL_LUAJIT)
|
#if defined(SOL_EXCEPTIONS_SAFE_PROPAGATION) && !defined(SOL_LUAJIT)
|
||||||
}
|
}
|
||||||
// Handle C++ errors thrown from C++ functions bound inside of lua
|
// Handle C++ errors thrown from C++ functions bound inside of lua
|
||||||
catch (const char* error) {
|
catch (const char* error) {
|
||||||
|
@ -13560,12 +13563,17 @@ namespace sol {
|
||||||
firstreturn = lua_gettop(lua_state());
|
firstreturn = lua_gettop(lua_state());
|
||||||
return protected_function_result(lua_state(), firstreturn, 0, 1, call_status::runtime);
|
return protected_function_result(lua_state(), firstreturn, 0, 1, call_status::runtime);
|
||||||
}
|
}
|
||||||
|
catch (const std::string& error) {
|
||||||
|
onexcept(error.c_str());
|
||||||
|
firstreturn = lua_gettop(lua_state());
|
||||||
|
return protected_function_result(lua_state(), firstreturn, 0, 1, call_status::runtime);
|
||||||
|
}
|
||||||
catch (const std::exception& error) {
|
catch (const std::exception& error) {
|
||||||
onexcept(error.what());
|
onexcept(error.what());
|
||||||
firstreturn = lua_gettop(lua_state());
|
firstreturn = lua_gettop(lua_state());
|
||||||
return protected_function_result(lua_state(), firstreturn, 0, 1, call_status::runtime);
|
return protected_function_result(lua_state(), firstreturn, 0, 1, call_status::runtime);
|
||||||
}
|
}
|
||||||
#if !defined(SOL_LUAJIT)
|
#if !defined(SOL_EXCEPTIONS_SAFE_PROPAGATION)
|
||||||
// LuaJIT cannot have the catchall when the safe propagation is on
|
// LuaJIT cannot have the catchall when the safe propagation is on
|
||||||
// but LuaJIT will swallow all C++ errors
|
// but LuaJIT will swallow all C++ errors
|
||||||
// if we don't at least catch std::exception ones
|
// if we don't at least catch std::exception ones
|
||||||
|
@ -13577,8 +13585,8 @@ namespace sol {
|
||||||
#endif // LuaJIT
|
#endif // LuaJIT
|
||||||
#else
|
#else
|
||||||
// do not handle exceptions: they can be propogated into C++ and keep all type information / rich information
|
// do not handle exceptions: they can be propogated into C++ and keep all type information / rich information
|
||||||
#endif // about as safe as possible
|
#endif // Safe Exception Propagation
|
||||||
#endif // No Exceptions
|
#endif // Exceptions vs. No Exceptions
|
||||||
return protected_function_result(lua_state(), firstreturn, returncount, returncount, code);
|
return protected_function_result(lua_state(), firstreturn, returncount, returncount, code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -150,16 +150,16 @@ namespace sol {
|
||||||
stack::push(lua_state(), error);
|
stack::push(lua_state(), error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
#if !defined(SOL_EXCEPTIONS_SAFE_PROPAGATION) || defined(SOL_LUAJIT)
|
#if defined(SOL_EXCEPTIONS_SAFE_PROPAGATION) && !defined(SOL_LUAJIT)
|
||||||
try {
|
try {
|
||||||
#endif
|
#endif // Safe Exception Propagation
|
||||||
#endif // No Exceptions
|
#endif // No Exceptions
|
||||||
firstreturn = (std::max)(1, static_cast<int>(stacksize - n - static_cast<int>(h.valid())));
|
firstreturn = (std::max)(1, static_cast<int>(stacksize - n - static_cast<int>(h.valid())));
|
||||||
code = luacall(n, LUA_MULTRET, h);
|
code = luacall(n, LUA_MULTRET, h);
|
||||||
poststacksize = lua_gettop(lua_state()) - static_cast<int>(h.valid());
|
poststacksize = lua_gettop(lua_state()) - static_cast<int>(h.valid());
|
||||||
returncount = poststacksize - (firstreturn - 1);
|
returncount = poststacksize - (firstreturn - 1);
|
||||||
#ifndef SOL_NO_EXCEPTIONS
|
#ifndef SOL_NO_EXCEPTIONS
|
||||||
#if !defined(SOL_EXCEPTIONS_SAFE_PROPAGATION) || defined(SOL_LUAJIT)
|
#if defined(SOL_EXCEPTIONS_SAFE_PROPAGATION) && !defined(SOL_LUAJIT)
|
||||||
}
|
}
|
||||||
// Handle C++ errors thrown from C++ functions bound inside of lua
|
// Handle C++ errors thrown from C++ functions bound inside of lua
|
||||||
catch (const char* error) {
|
catch (const char* error) {
|
||||||
|
@ -167,12 +167,17 @@ namespace sol {
|
||||||
firstreturn = lua_gettop(lua_state());
|
firstreturn = lua_gettop(lua_state());
|
||||||
return protected_function_result(lua_state(), firstreturn, 0, 1, call_status::runtime);
|
return protected_function_result(lua_state(), firstreturn, 0, 1, call_status::runtime);
|
||||||
}
|
}
|
||||||
|
catch (const std::string& error) {
|
||||||
|
onexcept(error.c_str());
|
||||||
|
firstreturn = lua_gettop(lua_state());
|
||||||
|
return protected_function_result(lua_state(), firstreturn, 0, 1, call_status::runtime);
|
||||||
|
}
|
||||||
catch (const std::exception& error) {
|
catch (const std::exception& error) {
|
||||||
onexcept(error.what());
|
onexcept(error.what());
|
||||||
firstreturn = lua_gettop(lua_state());
|
firstreturn = lua_gettop(lua_state());
|
||||||
return protected_function_result(lua_state(), firstreturn, 0, 1, call_status::runtime);
|
return protected_function_result(lua_state(), firstreturn, 0, 1, call_status::runtime);
|
||||||
}
|
}
|
||||||
#if !defined(SOL_LUAJIT)
|
#if !defined(SOL_EXCEPTIONS_SAFE_PROPAGATION)
|
||||||
// LuaJIT cannot have the catchall when the safe propagation is on
|
// LuaJIT cannot have the catchall when the safe propagation is on
|
||||||
// but LuaJIT will swallow all C++ errors
|
// but LuaJIT will swallow all C++ errors
|
||||||
// if we don't at least catch std::exception ones
|
// if we don't at least catch std::exception ones
|
||||||
|
@ -184,8 +189,8 @@ namespace sol {
|
||||||
#endif // LuaJIT
|
#endif // LuaJIT
|
||||||
#else
|
#else
|
||||||
// do not handle exceptions: they can be propogated into C++ and keep all type information / rich information
|
// do not handle exceptions: they can be propogated into C++ and keep all type information / rich information
|
||||||
#endif // about as safe as possible
|
#endif // Safe Exception Propagation
|
||||||
#endif // No Exceptions
|
#endif // Exceptions vs. No Exceptions
|
||||||
return protected_function_result(lua_state(), firstreturn, returncount, returncount, code);
|
return protected_function_result(lua_state(), firstreturn, returncount, returncount, code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -77,13 +77,16 @@ namespace sol {
|
||||||
try {
|
try {
|
||||||
return f(L);
|
return f(L);
|
||||||
}
|
}
|
||||||
catch (const char* s) {
|
catch (const char* cs) {
|
||||||
lua_pushstring(L, s);
|
lua_pushstring(L, cs);
|
||||||
|
}
|
||||||
|
catch (const std::string& s) {
|
||||||
|
lua_pushlstring(L, s.c_str(), s.size());
|
||||||
}
|
}
|
||||||
catch (const std::exception& e) {
|
catch (const std::exception& e) {
|
||||||
lua_pushstring(L, e.what());
|
lua_pushstring(L, e.what());
|
||||||
}
|
}
|
||||||
#if defined(SOL_EXCEPTIONS_SAFE_PROPAGATION) && defined(SOL_LUAJIT)
|
#if !defined(SOL_EXCEPTIONS_SAFE_PROPAGATION)
|
||||||
// LuaJIT cannot have the catchall when the safe propagation is on
|
// LuaJIT cannot have the catchall when the safe propagation is on
|
||||||
// but LuaJIT will swallow all C++ errors
|
// but LuaJIT will swallow all C++ errors
|
||||||
// if we don't at least catch std::exception ones
|
// if we don't at least catch std::exception ones
|
||||||
|
@ -92,7 +95,7 @@ namespace sol {
|
||||||
}
|
}
|
||||||
#endif // LuaJIT cannot have the catchall, but we must catch std::exceps for it
|
#endif // LuaJIT cannot have the catchall, but we must catch std::exceps for it
|
||||||
return lua_error(L);
|
return lua_error(L);
|
||||||
#endif
|
#endif // Safe exceptions
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef SOL_NOEXCEPT_FUNCTION_TYPE
|
#ifdef SOL_NOEXCEPT_FUNCTION_TYPE
|
||||||
|
@ -134,7 +137,7 @@ namespace sol {
|
||||||
catch (const std::exception& e) {
|
catch (const std::exception& e) {
|
||||||
lua_pushstring(L, e.what());
|
lua_pushstring(L, e.what());
|
||||||
}
|
}
|
||||||
#if defined(SOL_EXCEPTIONS_SAFE_PROPAGATION) && !defined(SOL_LUAJIT)
|
#if !defined(SOL_EXCEPTIONS_SAFE_PROPAGATION)
|
||||||
// LuaJIT cannot have the catchall when the safe propagation is on
|
// LuaJIT cannot have the catchall when the safe propagation is on
|
||||||
// but LuaJIT will swallow all C++ errors
|
// but LuaJIT will swallow all C++ errors
|
||||||
// if we don't at least catch std::exception ones
|
// if we don't at least catch std::exception ones
|
||||||
|
|
Loading…
Reference in New Issue
Block a user