Chris@16: // Copyright David Abrahams 2002. Chris@16: // Distributed under the Boost Software License, Version 1.0. (See Chris@16: // accompanying file LICENSE_1_0.txt or copy at Chris@16: // http://www.boost.org/LICENSE_1_0.txt) Chris@16: #ifndef TRANSLATE_EXCEPTION_TDS20091020_HPP Chris@16: # define TRANSLATE_EXCEPTION_TDS20091020_HPP Chris@16: Chris@16: # include Chris@16: Chris@16: # include Chris@16: # include Chris@16: # include Chris@16: # include Chris@16: Chris@16: # include Chris@16: Chris@16: namespace boost { namespace python { namespace detail { Chris@16: Chris@16: // A ternary function object used to translate C++ exceptions of type Chris@16: // ExceptionType into Python exceptions by invoking an object of type Chris@16: // Translate. Typically the translate function will be curried with Chris@16: // boost::bind(). Chris@16: template Chris@16: struct translate_exception Chris@16: { Chris@16: // workaround for broken gcc that ships with SuSE 9.0 and SuSE 9.1 Chris@16: # if defined(__linux__) && defined(__GNUC__) \ Chris@16: && BOOST_WORKAROUND(__GNUC__, == 3) \ Chris@16: && BOOST_WORKAROUND(__GNUC_MINOR__, == 3) \ Chris@16: && (BOOST_WORKAROUND(__GNUC_PATCHLEVEL__, == 1) \ Chris@16: || BOOST_WORKAROUND(__GNUC_PATCHLEVEL__, == 3)) Chris@16: typedef typename remove_reference< Chris@16: typename add_const::type Chris@16: >::type exception_non_ref; Chris@16: # else Chris@16: typedef typename add_reference< Chris@16: typename add_const::type Chris@16: >::type exception_cref; Chris@16: # endif Chris@16: Chris@16: inline bool operator()( Chris@16: exception_handler const& handler Chris@16: , function0 const& f Chris@16: , typename call_traits::param_type translate) const Chris@16: { Chris@16: try Chris@16: { Chris@16: return handler(f); Chris@16: } Chris@16: // workaround for broken gcc that ships with SuSE 9.0 and SuSE 9.1 Chris@16: # if defined(__linux__) && defined(__GNUC__) \ Chris@16: && BOOST_WORKAROUND(__GNUC__, == 3) \ Chris@16: && BOOST_WORKAROUND(__GNUC_MINOR__, == 3) \ Chris@16: && (BOOST_WORKAROUND(__GNUC_PATCHLEVEL__, == 1) \ Chris@16: || BOOST_WORKAROUND(__GNUC_PATCHLEVEL__, == 3)) Chris@16: catch(exception_non_ref& e) Chris@16: # else Chris@16: catch(exception_cref e) Chris@16: # endif Chris@16: { Chris@16: translate(e); Chris@16: return true; Chris@16: } Chris@16: } Chris@16: }; Chris@16: Chris@16: }}} // namespace boost::python::detail Chris@16: Chris@16: #endif // TRANSLATE_EXCEPTION_DWA2002810_HPP