/usr/include/luabind/exception_handler.hpp is in libluabind-dev 0.9.1+dfsg-8.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | // Copyright Daniel Wallin 2005. Use, modification and distribution is
// subject to the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#ifndef LUABIND_EXCEPTION_HANDLER_050601_HPP
# define LUABIND_EXCEPTION_HANDLER_050601_HPP
# include <luabind/lua_include.hpp>
# include <luabind/config.hpp>
# include <boost/optional.hpp>
# include <boost/type.hpp>
# if BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
# include <boost/mpl/if.hpp>
# include <boost/type_traits/is_pointer.hpp>
# endif
namespace luabind {
# ifndef LUABIND_NO_EXCEPTIONS
namespace detail
{
struct LUABIND_API exception_handler_base
{
exception_handler_base()
: next(0)
{}
virtual ~exception_handler_base() {}
virtual void handle(lua_State*) const = 0;
void try_next(lua_State*) const;
exception_handler_base* next;
};
namespace mpl = boost::mpl;
template<class E, class Handler>
struct exception_handler : exception_handler_base
{
# if BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
typedef typename mpl::if_<
boost::is_pointer<E>, E, E const&
>::type argument;
# else
typedef E const& argument;
# endif
exception_handler(Handler handler)
: handler(handler)
{}
void handle(lua_State* L) const
{
try
{
try_next(L);
}
catch (argument e)
{
handler(L, e);
}
}
Handler handler;
};
LUABIND_API void handle_exception_aux(lua_State* L);
LUABIND_API void register_exception_handler(exception_handler_base*);
} // namespace detail
# endif
template<class E, class Handler>
void register_exception_handler(Handler handler, boost::type<E>* = 0)
{
# ifndef LUABIND_NO_EXCEPTIONS
detail::register_exception_handler(
new detail::exception_handler<E, Handler>(handler)
);
# endif
}
template<class R, class F>
boost::optional<R> handle_exceptions(lua_State* L, F fn, boost::type<R>* = 0)
{
# ifndef LUABIND_NO_EXCEPTIONS
try
{
return fn();
}
catch (...)
{
detail::handle_exception_aux(L);
}
return boost::optional<R>();
# else
return fn();
# endif
}
} // namespace luabind
#endif // LUABIND_EXCEPTION_HANDLER_050601_HPP
|