blob: ed0016761fd0345b4bae6d457b92df9d65d0f02f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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
|