os/ossrv/ossrv_pub/boost_apis/boost/python/errors.hpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
//  (C) Copyright David Abrahams 2000.
sl@0
     2
// Distributed under the Boost Software License, Version 1.0. (See
sl@0
     3
// accompanying file LICENSE_1_0.txt or copy at
sl@0
     4
// http://www.boost.org/LICENSE_1_0.txt)
sl@0
     5
//
sl@0
     6
//  The author gratefully acknowleges the support of Dragon Systems, Inc., in
sl@0
     7
//  producing this work.
sl@0
     8
sl@0
     9
#ifndef ERRORS_DWA052500_H_
sl@0
    10
# define ERRORS_DWA052500_H_
sl@0
    11
sl@0
    12
# include <boost/python/detail/prefix.hpp>
sl@0
    13
# include <boost/function/function0.hpp>
sl@0
    14
sl@0
    15
namespace boost { namespace python {
sl@0
    16
sl@0
    17
struct BOOST_PYTHON_DECL_EXCEPTION error_already_set
sl@0
    18
{
sl@0
    19
  virtual ~error_already_set();
sl@0
    20
};
sl@0
    21
sl@0
    22
// Handles exceptions caught just before returning to Python code.
sl@0
    23
// Returns true iff an exception was caught.
sl@0
    24
BOOST_PYTHON_DECL bool handle_exception_impl(function0<void>);
sl@0
    25
sl@0
    26
template <class T>
sl@0
    27
bool handle_exception(T f)
sl@0
    28
{
sl@0
    29
    return handle_exception_impl(function0<void>(boost::ref(f)));
sl@0
    30
}
sl@0
    31
sl@0
    32
namespace detail { inline void rethrow() { throw; } }
sl@0
    33
sl@0
    34
inline void handle_exception()
sl@0
    35
{
sl@0
    36
    handle_exception(detail::rethrow);
sl@0
    37
}
sl@0
    38
sl@0
    39
BOOST_PYTHON_DECL void throw_error_already_set();
sl@0
    40
sl@0
    41
template <class T>
sl@0
    42
inline T* expect_non_null(T* x)
sl@0
    43
{
sl@0
    44
    if (x == 0)
sl@0
    45
        throw_error_already_set();
sl@0
    46
    return x;
sl@0
    47
}
sl@0
    48
sl@0
    49
// Return source if it is an instance of pytype; throw an appropriate
sl@0
    50
// exception otherwise.
sl@0
    51
BOOST_PYTHON_DECL PyObject* pytype_check(PyTypeObject* pytype, PyObject* source);
sl@0
    52
sl@0
    53
}} // namespace boost::python
sl@0
    54
sl@0
    55
#endif // ERRORS_DWA052500_H_