12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- #ifndef TRANSLATE_EXCEPTION_TDS20091020_HPP
- # define TRANSLATE_EXCEPTION_TDS20091020_HPP
- # include <boost/python/detail/exception_handler.hpp>
- # include <boost/python/detail/type_traits.hpp>
- # include <boost/call_traits.hpp>
- # include <boost/function/function0.hpp>
- namespace boost { namespace python { namespace detail {
- template <class ExceptionType, class Translate>
- struct translate_exception
- {
- # if defined(__linux__) && defined(__GNUC__) \
- && BOOST_WORKAROUND(__GNUC__, == 3) \
- && BOOST_WORKAROUND(__GNUC_MINOR__, == 3) \
- && (BOOST_WORKAROUND(__GNUC_PATCHLEVEL__, == 1) \
- || BOOST_WORKAROUND(__GNUC_PATCHLEVEL__, == 3))
- typedef typename remove_reference<
- typename add_const<ExceptionType>::type
- >::type exception_non_ref;
- # else
- typedef typename add_lvalue_reference<
- typename add_const<ExceptionType>::type
- >::type exception_cref;
- # endif
-
- inline bool operator()(
- exception_handler const& handler
- , function0<void> const& f
- , typename call_traits<Translate>::param_type translate) const
- {
- try
- {
- return handler(f);
- }
- # if defined(__linux__) && defined(__GNUC__) \
- && BOOST_WORKAROUND(__GNUC__, == 3) \
- && BOOST_WORKAROUND(__GNUC_MINOR__, == 3) \
- && (BOOST_WORKAROUND(__GNUC_PATCHLEVEL__, == 1) \
- || BOOST_WORKAROUND(__GNUC_PATCHLEVEL__, == 3))
- catch(exception_non_ref& e)
- # else
- catch(exception_cref e)
- # endif
- {
- translate(e);
- return true;
- }
- }
- };
- }}}
- #endif
|