os/ossrv/ossrv_pub/boost_apis/boost/python/errors.hpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/ossrv_pub/boost_apis/boost/python/errors.hpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,55 @@
     1.4 +//  (C) Copyright David Abrahams 2000.
     1.5 +// Distributed under the Boost Software License, Version 1.0. (See
     1.6 +// accompanying file LICENSE_1_0.txt or copy at
     1.7 +// http://www.boost.org/LICENSE_1_0.txt)
     1.8 +//
     1.9 +//  The author gratefully acknowleges the support of Dragon Systems, Inc., in
    1.10 +//  producing this work.
    1.11 +
    1.12 +#ifndef ERRORS_DWA052500_H_
    1.13 +# define ERRORS_DWA052500_H_
    1.14 +
    1.15 +# include <boost/python/detail/prefix.hpp>
    1.16 +# include <boost/function/function0.hpp>
    1.17 +
    1.18 +namespace boost { namespace python {
    1.19 +
    1.20 +struct BOOST_PYTHON_DECL_EXCEPTION error_already_set
    1.21 +{
    1.22 +  virtual ~error_already_set();
    1.23 +};
    1.24 +
    1.25 +// Handles exceptions caught just before returning to Python code.
    1.26 +// Returns true iff an exception was caught.
    1.27 +BOOST_PYTHON_DECL bool handle_exception_impl(function0<void>);
    1.28 +
    1.29 +template <class T>
    1.30 +bool handle_exception(T f)
    1.31 +{
    1.32 +    return handle_exception_impl(function0<void>(boost::ref(f)));
    1.33 +}
    1.34 +
    1.35 +namespace detail { inline void rethrow() { throw; } }
    1.36 +
    1.37 +inline void handle_exception()
    1.38 +{
    1.39 +    handle_exception(detail::rethrow);
    1.40 +}
    1.41 +
    1.42 +BOOST_PYTHON_DECL void throw_error_already_set();
    1.43 +
    1.44 +template <class T>
    1.45 +inline T* expect_non_null(T* x)
    1.46 +{
    1.47 +    if (x == 0)
    1.48 +        throw_error_already_set();
    1.49 +    return x;
    1.50 +}
    1.51 +
    1.52 +// Return source if it is an instance of pytype; throw an appropriate
    1.53 +// exception otherwise.
    1.54 +BOOST_PYTHON_DECL PyObject* pytype_check(PyTypeObject* pytype, PyObject* source);
    1.55 +
    1.56 +}} // namespace boost::python
    1.57 +
    1.58 +#endif // ERRORS_DWA052500_H_