|
16 | 16 | #include "eigenpy/scipy-type.hpp" |
17 | 17 | #include "eigenpy/registration.hpp" |
18 | 18 |
|
19 | | -namespace boost { |
20 | | -namespace python { |
21 | | - |
22 | | -template <typename MatrixRef, class MakeHolder> |
23 | | -struct to_python_indirect_eigen { |
24 | | - template <class U> |
25 | | - inline PyObject* operator()(U const& mat) const { |
26 | | - return eigenpy::EigenToPy<MatrixRef>::convert(const_cast<U&>(mat)); |
27 | | - } |
28 | | - |
29 | | -#ifndef BOOST_PYTHON_NO_PY_SIGNATURES |
30 | | - inline PyTypeObject const* get_pytype() const { |
31 | | - return converter::registered_pytype<MatrixRef>::get_pytype(); |
32 | | - } |
33 | | -#endif |
34 | | -}; |
35 | | - |
36 | | -template <typename Scalar, int RowsAtCompileTime, int ColsAtCompileTime, |
37 | | - int Options, int MaxRowsAtCompileTime, int MaxColsAtCompileTime, |
38 | | - class MakeHolder> |
39 | | -struct to_python_indirect< |
40 | | - Eigen::Matrix<Scalar, RowsAtCompileTime, ColsAtCompileTime, Options, |
41 | | - MaxRowsAtCompileTime, MaxColsAtCompileTime>&, |
42 | | - MakeHolder> |
43 | | - : to_python_indirect_eigen< |
44 | | - Eigen::Matrix<Scalar, RowsAtCompileTime, ColsAtCompileTime, Options, |
45 | | - MaxRowsAtCompileTime, MaxColsAtCompileTime>&, |
46 | | - MakeHolder> {}; |
47 | | - |
48 | | -template <typename Scalar, int RowsAtCompileTime, int ColsAtCompileTime, |
49 | | - int Options, int MaxRowsAtCompileTime, int MaxColsAtCompileTime, |
50 | | - class MakeHolder> |
51 | | -struct to_python_indirect< |
52 | | - const Eigen::Matrix<Scalar, RowsAtCompileTime, ColsAtCompileTime, Options, |
53 | | - MaxRowsAtCompileTime, MaxColsAtCompileTime>&, |
54 | | - MakeHolder> |
55 | | - : to_python_indirect_eigen< |
56 | | - const Eigen::Matrix<Scalar, RowsAtCompileTime, ColsAtCompileTime, |
57 | | - Options, MaxRowsAtCompileTime, |
58 | | - MaxColsAtCompileTime>&, |
59 | | - MakeHolder> {}; |
60 | | - |
61 | | -} // namespace python |
62 | | -} // namespace boost |
63 | | - |
64 | 19 | namespace eigenpy { |
65 | 20 |
|
66 | 21 | EIGENPY_DOCUMENTATION_START_IGNORE |
@@ -202,23 +157,63 @@ struct eigen_to_py_impl_tensor { |
202 | 157 |
|
203 | 158 | EIGENPY_DOCUMENTATION_END_IGNORE |
204 | 159 |
|
205 | | -#ifdef EIGENPY_MSVC_COMPILER |
206 | | -template <typename EigenType> |
207 | | -struct EigenToPy<EigenType, |
208 | | - typename boost::remove_reference<EigenType>::type::Scalar> |
209 | | -#else |
210 | | -template <typename EigenType, typename _Scalar> |
211 | | -struct EigenToPy |
212 | | -#endif |
213 | | - : eigen_to_py_impl<EigenType> { |
214 | | -}; |
| 160 | +template <typename EigenType, |
| 161 | + typename Scalar = |
| 162 | + typename boost::remove_reference<EigenType>::type::Scalar> |
| 163 | +struct EigenToPy : eigen_to_py_impl<EigenType> {}; |
215 | 164 |
|
216 | 165 | template <typename MatType> |
217 | 166 | struct EigenToPyConverter { |
218 | 167 | static void registration() { |
219 | 168 | bp::to_python_converter<MatType, EigenToPy<MatType>, true>(); |
220 | 169 | } |
221 | 170 | }; |
| 171 | + |
222 | 172 | } // namespace eigenpy |
223 | 173 |
|
| 174 | +namespace boost { |
| 175 | +namespace python { |
| 176 | + |
| 177 | +template <typename MatrixRef, class MakeHolder> |
| 178 | +struct to_python_indirect_eigen { |
| 179 | + template <class U> |
| 180 | + inline PyObject* operator()(U const& mat) const { |
| 181 | + return eigenpy::EigenToPy<MatrixRef>::convert(const_cast<U&>(mat)); |
| 182 | + } |
| 183 | + |
| 184 | +#ifndef BOOST_PYTHON_NO_PY_SIGNATURES |
| 185 | + inline PyTypeObject const* get_pytype() const { |
| 186 | + return converter::registered_pytype<MatrixRef>::get_pytype(); |
| 187 | + } |
| 188 | +#endif |
| 189 | +}; |
| 190 | + |
| 191 | +template <typename Scalar, int RowsAtCompileTime, int ColsAtCompileTime, |
| 192 | + int Options, int MaxRowsAtCompileTime, int MaxColsAtCompileTime, |
| 193 | + class MakeHolder> |
| 194 | +struct to_python_indirect< |
| 195 | + Eigen::Matrix<Scalar, RowsAtCompileTime, ColsAtCompileTime, Options, |
| 196 | + MaxRowsAtCompileTime, MaxColsAtCompileTime>&, |
| 197 | + MakeHolder> |
| 198 | + : to_python_indirect_eigen< |
| 199 | + Eigen::Matrix<Scalar, RowsAtCompileTime, ColsAtCompileTime, Options, |
| 200 | + MaxRowsAtCompileTime, MaxColsAtCompileTime>&, |
| 201 | + MakeHolder> {}; |
| 202 | + |
| 203 | +template <typename Scalar, int RowsAtCompileTime, int ColsAtCompileTime, |
| 204 | + int Options, int MaxRowsAtCompileTime, int MaxColsAtCompileTime, |
| 205 | + class MakeHolder> |
| 206 | +struct to_python_indirect< |
| 207 | + const Eigen::Matrix<Scalar, RowsAtCompileTime, ColsAtCompileTime, Options, |
| 208 | + MaxRowsAtCompileTime, MaxColsAtCompileTime>&, |
| 209 | + MakeHolder> |
| 210 | + : to_python_indirect_eigen< |
| 211 | + const Eigen::Matrix<Scalar, RowsAtCompileTime, ColsAtCompileTime, |
| 212 | + Options, MaxRowsAtCompileTime, |
| 213 | + MaxColsAtCompileTime>&, |
| 214 | + MakeHolder> {}; |
| 215 | + |
| 216 | +} // namespace python |
| 217 | +} // namespace boost |
| 218 | + |
224 | 219 | #endif // __eigenpy_eigen_to_python_hpp__ |
0 commit comments