mirror of
https://github.com/EQEmu/Server.git
synced 2026-06-11 07:38:36 +00:00
Swapped luabind for non-boost fork
https://github.com/decimad/luabind-deboostified
This commit is contained in:
@@ -4,84 +4,93 @@
|
||||
|
||||
#define LUABIND_BUILDING
|
||||
|
||||
#include <luabind/config.hpp>
|
||||
#include <luabind/exception_handler.hpp>
|
||||
#include <luabind/error.hpp>
|
||||
#include <stdexcept>
|
||||
#include <luabind/lua_include.hpp>
|
||||
|
||||
#include <luabind/config.hpp> // for LUABIND_API
|
||||
|
||||
#ifndef LUABIND_NO_EXCEPTIONS
|
||||
#include <luabind/error.hpp> // for error
|
||||
#include <luabind/exception_handler.hpp> // for exception_handler_base
|
||||
|
||||
namespace luabind { namespace detail {
|
||||
#include <exception> // for exception
|
||||
#include <stdexcept> // for logic_error, runtime_error
|
||||
|
||||
namespace
|
||||
{
|
||||
exception_handler_base* handler_chain = 0;
|
||||
namespace luabind {
|
||||
namespace detail {
|
||||
|
||||
void push_exception_string(lua_State* L, char const* exception, char const* what)
|
||||
{
|
||||
lua_pushstring(L, exception);
|
||||
lua_pushstring(L, ": '");
|
||||
lua_pushstring(L, what);
|
||||
lua_pushstring(L, "'");
|
||||
lua_concat(L, 4);
|
||||
}
|
||||
}
|
||||
namespace {
|
||||
|
||||
void exception_handler_base::try_next(lua_State* L) const
|
||||
{
|
||||
if (next)
|
||||
next->handle(L);
|
||||
else
|
||||
throw;
|
||||
}
|
||||
exception_handler_base* handler_chain = 0;
|
||||
|
||||
LUABIND_API void handle_exception_aux(lua_State* L)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (handler_chain)
|
||||
handler_chain->handle(L);
|
||||
else
|
||||
throw;
|
||||
}
|
||||
catch (error const&)
|
||||
{}
|
||||
catch (std::logic_error const& e)
|
||||
{
|
||||
push_exception_string(L, "std::logic_error", e.what());
|
||||
}
|
||||
catch (std::runtime_error const& e)
|
||||
{
|
||||
push_exception_string(L, "std::runtime_error", e.what());
|
||||
}
|
||||
catch (std::exception const& e)
|
||||
{
|
||||
push_exception_string(L, "std::exception", e.what());
|
||||
}
|
||||
catch (char const* str)
|
||||
{
|
||||
push_exception_string(L, "c-string", str);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
lua_pushstring(L, "Unknown C++ exception");
|
||||
}
|
||||
}
|
||||
void push_exception_string(lua_State* L, char const* exception, char const* what)
|
||||
{
|
||||
lua_pushstring(L, exception);
|
||||
lua_pushstring(L, ": '");
|
||||
lua_pushstring(L, what);
|
||||
lua_pushstring(L, "'");
|
||||
lua_concat(L, 4);
|
||||
}
|
||||
}
|
||||
|
||||
LUABIND_API void register_exception_handler(exception_handler_base* handler)
|
||||
{
|
||||
if (!handler_chain) handler_chain = handler;
|
||||
else
|
||||
{
|
||||
exception_handler_base* p = handler_chain;
|
||||
void exception_handler_base::try_next(lua_State* L) const
|
||||
{
|
||||
if(next)
|
||||
next->handle(L);
|
||||
else
|
||||
throw;
|
||||
}
|
||||
|
||||
for (; p->next; p = p->next);
|
||||
LUABIND_API void handle_exception_aux(lua_State* L)
|
||||
{
|
||||
try
|
||||
{
|
||||
if(handler_chain)
|
||||
handler_chain->handle(L);
|
||||
else
|
||||
throw;
|
||||
}
|
||||
catch(error const&)
|
||||
{
|
||||
// is always thrown in the context where an error message was already pushed to the lua stack.
|
||||
}
|
||||
catch(std::logic_error const& e)
|
||||
{
|
||||
push_exception_string(L, "std::logic_error", e.what());
|
||||
}
|
||||
catch(std::runtime_error const& e)
|
||||
{
|
||||
push_exception_string(L, "std::runtime_error", e.what());
|
||||
}
|
||||
catch(std::exception const& e)
|
||||
{
|
||||
push_exception_string(L, "std::exception", e.what());
|
||||
}
|
||||
catch(char const* str)
|
||||
{
|
||||
push_exception_string(L, "c-string", str);
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
lua_pushstring(L, "Unknown C++ exception");
|
||||
}
|
||||
}
|
||||
|
||||
handler->next = 0;
|
||||
p->next = handler;
|
||||
}
|
||||
}
|
||||
LUABIND_API void register_exception_handler(exception_handler_base* handler)
|
||||
{
|
||||
if(!handler_chain) handler_chain = handler;
|
||||
else
|
||||
{
|
||||
exception_handler_base* p = handler_chain;
|
||||
|
||||
}} // namespace luabind::detail
|
||||
for(; p->next; p = p->next);
|
||||
|
||||
handler->next = 0;
|
||||
p->next = handler;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
} // namespace luabind
|
||||
|
||||
#endif // LUABIND_NO_EXCEPTIONS
|
||||
|
||||
|
||||
Reference in New Issue
Block a user