mirror of
https://github.com/ThePhD/sol2.git
synced 2024-03-22 13:10:44 +08:00
formatting
This commit is contained in:
parent
0113fb86b4
commit
4ed197f065
|
@ -170,7 +170,7 @@ private:
|
||||||
returncount = poststacksize - firstreturn;
|
returncount = poststacksize - firstreturn;
|
||||||
}
|
}
|
||||||
// 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) {
|
||||||
h.stackindex = 0;
|
h.stackindex = 0;
|
||||||
stack::push(lua_state(), error);
|
stack::push(lua_state(), error);
|
||||||
firstreturn = lua_gettop(lua_state());
|
firstreturn = lua_gettop(lua_state());
|
||||||
|
|
|
@ -48,19 +48,19 @@ inline int static_trampoline (lua_State* L) {
|
||||||
|
|
||||||
template <typename Fx>
|
template <typename Fx>
|
||||||
inline int trampoline(lua_State* L, Fx&& f) {
|
inline int trampoline(lua_State* L, Fx&& f) {
|
||||||
try {
|
try {
|
||||||
return f(L);
|
return f(L);
|
||||||
}
|
}
|
||||||
catch (const char *s) { // Catch and convert exceptions.
|
catch (const char *s) { // Catch and convert exceptions.
|
||||||
lua_pushstring(L, s);
|
lua_pushstring(L, s);
|
||||||
}
|
}
|
||||||
catch (const std::exception& e) {
|
catch (const std::exception& e) {
|
||||||
lua_pushstring(L, e.what());
|
lua_pushstring(L, e.what());
|
||||||
}
|
}
|
||||||
catch (...) {
|
catch (...) {
|
||||||
lua_pushstring(L, "caught (...) exception");
|
lua_pushstring(L, "caught (...) exception");
|
||||||
}
|
}
|
||||||
return lua_error(L);
|
return lua_error(L);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int c_trampoline(lua_State* L, lua_CFunction f) {
|
inline int c_trampoline(lua_State* L, lua_CFunction f) {
|
||||||
|
|
16
tests.cpp
16
tests.cpp
|
@ -1201,16 +1201,16 @@ TEST_CASE( "functions/function_result-protected_function_result", "Function resu
|
||||||
luadoom.error_handler = cpphandler;
|
luadoom.error_handler = cpphandler;
|
||||||
|
|
||||||
{
|
{
|
||||||
sol::protected_function_result result = doom();
|
sol::protected_function_result result = doom();
|
||||||
REQUIRE(!result.valid());
|
REQUIRE(!result.valid());
|
||||||
std::string errorstring = result;
|
std::string errorstring = result;
|
||||||
REQUIRE(errorstring == handlederrormessage);
|
REQUIRE(errorstring == handlederrormessage);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
sol::protected_function_result result = luadoom();
|
sol::protected_function_result result = luadoom();
|
||||||
REQUIRE(!result.valid());
|
REQUIRE(!result.valid());
|
||||||
std::string errorstring = result;
|
std::string errorstring = result;
|
||||||
REQUIRE(errorstring == handlederrormessage);
|
REQUIRE(errorstring == handlederrormessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user