File indexing completed on 2025-01-18 09:50:38
0001
0002
0003
0004
0005 #ifndef TRANSLATE_EXCEPTION_TDS20091020_HPP
0006 # define TRANSLATE_EXCEPTION_TDS20091020_HPP
0007
0008 # include <boost/python/detail/exception_handler.hpp>
0009 # include <boost/python/detail/type_traits.hpp>
0010
0011 # include <boost/call_traits.hpp>
0012
0013 # include <boost/function/function0.hpp>
0014
0015 namespace boost { namespace python { namespace detail {
0016
0017
0018
0019
0020
0021 template <class ExceptionType, class Translate>
0022 struct translate_exception
0023 {
0024
0025 # if defined(__linux__) && defined(__GNUC__) \
0026 && BOOST_WORKAROUND(__GNUC__, == 3) \
0027 && BOOST_WORKAROUND(__GNUC_MINOR__, == 3) \
0028 && (BOOST_WORKAROUND(__GNUC_PATCHLEVEL__, == 1) \
0029 || BOOST_WORKAROUND(__GNUC_PATCHLEVEL__, == 3))
0030 typedef typename remove_reference<
0031 typename add_const<ExceptionType>::type
0032 >::type exception_non_ref;
0033 # else
0034 typedef typename add_lvalue_reference<
0035 typename add_const<ExceptionType>::type
0036 >::type exception_cref;
0037 # endif
0038
0039 inline bool operator()(
0040 exception_handler const& handler
0041 , function0<void> const& f
0042 , typename call_traits<Translate>::param_type translate) const
0043 {
0044 try
0045 {
0046 return handler(f);
0047 }
0048
0049 # if defined(__linux__) && defined(__GNUC__) \
0050 && BOOST_WORKAROUND(__GNUC__, == 3) \
0051 && BOOST_WORKAROUND(__GNUC_MINOR__, == 3) \
0052 && (BOOST_WORKAROUND(__GNUC_PATCHLEVEL__, == 1) \
0053 || BOOST_WORKAROUND(__GNUC_PATCHLEVEL__, == 3))
0054 catch(exception_non_ref& e)
0055 # else
0056 catch(exception_cref e)
0057 # endif
0058 {
0059 translate(e);
0060 return true;
0061 }
0062 }
0063 };
0064
0065 }}}
0066
0067 #endif