Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-22 10:26:15

0001 // Copyright Jim Bosch 2010-2012.
0002 // Copyright Stefan Seefeld 2016.
0003 // Distributed under the Boost Software License, Version 1.0.
0004 // (See accompanying file LICENSE_1_0.txt or copy at
0005 // http://www.boost.org/LICENSE_1_0.txt)
0006 
0007 #ifndef boost_python_numpy_numpy_object_mgr_traits_hpp_
0008 #define boost_python_numpy_numpy_object_mgr_traits_hpp_
0009 
0010 #include <boost/python/numpy/config.hpp>
0011 
0012 /**
0013  *  @brief Macro that specializes object_manager_traits by requiring a 
0014  *         source-file implementation of get_pytype().
0015  */
0016 
0017 #define NUMPY_OBJECT_MANAGER_TRAITS(manager)                            \
0018 template <>                             \
0019 struct BOOST_NUMPY_DECL object_manager_traits<manager>          \
0020 {                                   \
0021   BOOST_STATIC_CONSTANT(bool, is_specialized = true);           \
0022   static inline python::detail::new_reference adopt(PyObject* x)    \
0023   {                                 \
0024     return python::detail::new_reference(python::pytype_check((PyTypeObject*)get_pytype(), x)); \
0025   }                                 \
0026   static bool check(PyObject* x)                    \
0027   {                                 \
0028     return ::PyObject_IsInstance(x, (PyObject*)get_pytype());       \
0029   }                                 \
0030   static manager* checked_downcast(PyObject* x)             \
0031   {                                 \
0032     return python::downcast<manager>((checked_downcast_impl)(x, (PyTypeObject*)get_pytype())); \
0033   }                                 \
0034   static PyTypeObject const * get_pytype();             \
0035 }
0036 
0037 #endif
0038