1 // Copyright Jim Bosch 2010-2012.
2 // Copyright Stefan Seefeld 2016.
3 // Distributed under the Boost Software License, Version 1.0.
4 // (See accompanying file LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt)
7 #ifndef boost_python_numpy_numpy_object_mgr_traits_hpp_
8 #define boost_python_numpy_numpy_object_mgr_traits_hpp_
11 * @brief Macro that specializes object_manager_traits by requiring a
12 * source-file implementation of get_pytype().
15 #define NUMPY_OBJECT_MANAGER_TRAITS(manager) \
17 struct object_manager_traits<manager> \
19 BOOST_STATIC_CONSTANT(bool, is_specialized = true); \
20 static inline python::detail::new_reference adopt(PyObject* x) \
22 return python::detail::new_reference(python::pytype_check((PyTypeObject*)get_pytype(), x)); \
24 static bool check(PyObject* x) \
26 return ::PyObject_IsInstance(x, (PyObject*)get_pytype()); \
28 static manager* checked_downcast(PyObject* x) \
30 return python::downcast<manager>((checked_downcast_impl)(x, (PyTypeObject*)get_pytype())); \
32 static PyTypeObject const * get_pytype(); \