diff options
| author | Christoph Berg <myon@debian.org> | 2018-12-19 22:58:32 +0100 |
|---|---|---|
| committer | Christoph Berg <myon@debian.org> | 2018-12-19 22:58:32 +0100 |
| commit | e0737c56c1e384e05064a0c6e1ac46979371041b (patch) | |
| tree | a0123d694a2d36c43dabdf0a3907392fce11d457 /boost/libs/mpi/src/python/utility.hpp | |
| parent | b4aebf2d137b892f53503b13785ecae900062ff7 (diff) | |
New upstream version 2.0.0+repackupstream/2.0.0+repack
Diffstat (limited to 'boost/libs/mpi/src/python/utility.hpp')
| -rw-r--r-- | boost/libs/mpi/src/python/utility.hpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/boost/libs/mpi/src/python/utility.hpp b/boost/libs/mpi/src/python/utility.hpp new file mode 100644 index 00000000..ed001676 --- /dev/null +++ b/boost/libs/mpi/src/python/utility.hpp @@ -0,0 +1,43 @@ +// (C) Copyright 2006 Douglas Gregor <doug.gregor -at- gmail.com> + +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// Authors: Douglas Gregor +#ifndef BOOST_MPI_PYTHON_UTILITY_HPP +#define BOOST_MPI_PYTHON_UTILITY_HPP + +/** @file utility.hpp + * + * This file is a utility header for the Boost.MPI Python bindings. + */ +#include <boost/python.hpp> + +namespace boost { namespace mpi { namespace python { + +template<typename E> +class translate_exception +{ + explicit translate_exception(boost::python::object type) : type(type) { } + +public: + static void declare(boost::python::object type) + { + using boost::python::register_exception_translator; + register_exception_translator<E>(translate_exception(type)); + } + + void operator()(const E& e) const + { + using boost::python::object; + PyErr_SetObject(type.ptr(), object(e).ptr()); + } + +private: + boost::python::object type; +}; + +} } } // end namespace boost::mpi::python + +#endif // BOOST_MPI_PYTHON_UTILITY_HPP |
