Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:50:40

0001 //  (C) Copyright David Abrahams 2000.
0002 // Distributed under the Boost Software License, Version 1.0. (See
0003 // accompanying file LICENSE_1_0.txt or copy at
0004 // http://www.boost.org/LICENSE_1_0.txt)
0005 //
0006 //  The author gratefully acknowleges the support of Dragon Systems, Inc., in
0007 //  producing this work.
0008 
0009 #ifndef ERRORS_DWA052500_H_
0010 # define ERRORS_DWA052500_H_
0011 
0012 # include <boost/python/detail/prefix.hpp>
0013 # include <boost/function/function0.hpp>
0014 
0015 namespace boost { namespace python {
0016 
0017 struct BOOST_PYTHON_DECL error_already_set
0018 {
0019   virtual ~error_already_set();
0020 };
0021 
0022 // Handles exceptions caught just before returning to Python code.
0023 // Returns true iff an exception was caught.
0024 BOOST_PYTHON_DECL bool handle_exception_impl(function0<void>);
0025 
0026 template <class T>
0027 bool handle_exception(T f)
0028 {
0029     return handle_exception_impl(function0<void>(boost::ref(f)));
0030 }
0031 
0032 namespace detail { inline void rethrow() { throw; } }
0033 
0034 inline void handle_exception()
0035 {
0036     handle_exception(detail::rethrow);
0037 }
0038 
0039 BOOST_PYTHON_DECL void throw_error_already_set();
0040 
0041 template <class T>
0042 inline T* expect_non_null(T* x)
0043 {
0044     if (x == 0)
0045         throw_error_already_set();
0046     return x;
0047 }
0048 
0049 // Return source if it is an instance of pytype; throw an appropriate
0050 // exception otherwise.
0051 BOOST_PYTHON_DECL PyObject* pytype_check(PyTypeObject* pytype, PyObject* source);
0052 
0053 }} // namespace boost::python
0054 
0055 #endif // ERRORS_DWA052500_H_