Chris@16
|
1 // Copyright David Abrahams 2002.
|
Chris@16
|
2 // Distributed under the Boost Software License, Version 1.0. (See
|
Chris@16
|
3 // accompanying file LICENSE_1_0.txt or copy at
|
Chris@16
|
4 // http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
5 #ifndef EXCEPTION_HANDLER_DWA2002810_HPP
|
Chris@16
|
6 # define EXCEPTION_HANDLER_DWA2002810_HPP
|
Chris@16
|
7
|
Chris@16
|
8 # include <boost/python/detail/config.hpp>
|
Chris@16
|
9 # include <boost/function/function0.hpp>
|
Chris@16
|
10 # include <boost/function/function2.hpp>
|
Chris@16
|
11
|
Chris@16
|
12 namespace boost { namespace python { namespace detail {
|
Chris@16
|
13
|
Chris@16
|
14 struct BOOST_PYTHON_DECL_FORWARD exception_handler;
|
Chris@16
|
15
|
Chris@16
|
16 typedef function2<bool, exception_handler const&, function0<void> const&> handler_function;
|
Chris@16
|
17
|
Chris@16
|
18 struct BOOST_PYTHON_DECL exception_handler
|
Chris@16
|
19 {
|
Chris@16
|
20 private: // types
|
Chris@16
|
21
|
Chris@16
|
22 public:
|
Chris@16
|
23 explicit exception_handler(handler_function const& impl);
|
Chris@16
|
24
|
Chris@16
|
25 inline bool handle(function0<void> const& f) const;
|
Chris@16
|
26
|
Chris@16
|
27 bool operator()(function0<void> const& f) const;
|
Chris@16
|
28
|
Chris@16
|
29 static exception_handler* chain;
|
Chris@16
|
30
|
Chris@16
|
31 private:
|
Chris@16
|
32 static exception_handler* tail;
|
Chris@16
|
33
|
Chris@16
|
34 handler_function m_impl;
|
Chris@16
|
35 exception_handler* m_next;
|
Chris@16
|
36 };
|
Chris@16
|
37
|
Chris@16
|
38
|
Chris@16
|
39 inline bool exception_handler::handle(function0<void> const& f) const
|
Chris@16
|
40 {
|
Chris@16
|
41 return this->m_impl(*this, f);
|
Chris@16
|
42 }
|
Chris@16
|
43
|
Chris@16
|
44 BOOST_PYTHON_DECL void register_exception_handler(handler_function const& f);
|
Chris@16
|
45
|
Chris@16
|
46 }}} // namespace boost::python::detail
|
Chris@16
|
47
|
Chris@16
|
48 #endif // EXCEPTION_HANDLER_DWA2002810_HPP
|