source: NonGTP/Boost/boost/python/errors.hpp @ 857

Revision 857, 1.4 KB checked in by igarcia, 19 years ago (diff)
RevLine 
[857]1//  (C) Copyright David Abrahams 2000.
2// Distributed under the Boost Software License, Version 1.0. (See
3// accompanying file LICENSE_1_0.txt or copy at
4// http://www.boost.org/LICENSE_1_0.txt)
5//
6//  The author gratefully acknowleges the support of Dragon Systems, Inc., in
7//  producing this work.
8
9#ifndef ERRORS_DWA052500_H_
10# define ERRORS_DWA052500_H_
11
12# include <boost/python/detail/prefix.hpp>
13# include <boost/function/function0.hpp>
14
15namespace boost { namespace python {
16
17struct BOOST_PYTHON_DECL_EXCEPTION error_already_set
18{
19  virtual ~error_already_set();
20};
21
22// Handles exceptions caught just before returning to Python code.
23// Returns true iff an exception was caught.
24BOOST_PYTHON_DECL bool handle_exception_impl(function0<void>);
25
26template <class T>
27bool handle_exception(T f)
28{
29    return handle_exception_impl(function0<void>(boost::ref(f)));
30}
31
32namespace detail { inline void rethrow() { throw; } }
33
34inline void handle_exception()
35{
36    handle_exception(detail::rethrow);
37}
38
39BOOST_PYTHON_DECL void throw_error_already_set();
40
41template <class T>
42inline T* expect_non_null(T* x)
43{
44    if (x == 0)
45        throw_error_already_set();
46    return x;
47}
48
49// Return source if it is an instance of pytype; throw an appropriate
50// exception otherwise.
51BOOST_PYTHON_DECL PyObject* pytype_check(PyTypeObject* pytype, PyObject* source);
52
53}} // namespace boost::python
54
55#endif // ERRORS_DWA052500_H_
Note: See TracBrowser for help on using the repository browser.