Skip to content

Commit da34179

Browse files
committed
core: Remove a CL dedicated hack to allow EigenToPy and EigenFromPy specialization on Windows
core: Use same namespace scope
1 parent 4c69144 commit da34179

File tree

3 files changed

+60
-71
lines changed

3 files changed

+60
-71
lines changed

include/eigenpy/eigen-from-python.hpp

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -290,16 +290,10 @@ struct eigen_from_py_impl<MatType, Eigen::MatrixBase<MatType> > {
290290
static void registration();
291291
};
292292

293-
#ifdef EIGENPY_MSVC_COMPILER
294-
template <typename EigenType>
295-
struct EigenFromPy<EigenType,
296-
typename boost::remove_reference<EigenType>::type::Scalar>
297-
#else
298-
template <typename EigenType, typename _Scalar>
299-
struct EigenFromPy
300-
#endif
301-
: eigen_from_py_impl<EigenType> {
302-
};
293+
template <typename EigenType,
294+
typename Scalar =
295+
typename boost::remove_reference<EigenType>::type::Scalar>
296+
struct EigenFromPy : eigen_from_py_impl<EigenType> {};
303297

304298
template <typename MatType>
305299
void *eigen_from_py_impl<MatType, Eigen::MatrixBase<MatType> >::convertible(

include/eigenpy/eigen-to-python.hpp

Lines changed: 50 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -16,51 +16,6 @@
1616
#include "eigenpy/scipy-type.hpp"
1717
#include "eigenpy/registration.hpp"
1818

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-
6419
namespace eigenpy {
6520

6621
EIGENPY_DOCUMENTATION_START_IGNORE
@@ -202,23 +157,63 @@ struct eigen_to_py_impl_tensor {
202157

203158
EIGENPY_DOCUMENTATION_END_IGNORE
204159

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> {};
215164

216165
template <typename MatType>
217166
struct EigenToPyConverter {
218167
static void registration() {
219168
bp::to_python_converter<MatType, EigenToPy<MatType>, true>();
220169
}
221170
};
171+
222172
} // namespace eigenpy
223173

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+
224219
#endif // __eigenpy_eigen_to_python_hpp__

include/eigenpy/fwd.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,13 @@ namespace bp = boost::python;
125125
#endif
126126

127127
namespace eigenpy {
128-
template <typename MatType,
129-
typename Scalar =
130-
typename boost::remove_reference<MatType>::type::Scalar>
128+
129+
// Default Scalar value can't be defined in the declaration
130+
// because of a CL bug.
131+
// See https://github.com/stack-of-tasks/eigenpy/pull/462
132+
template <typename MatType, typename Scalar>
131133
struct EigenToPy;
132-
template <typename MatType,
133-
typename Scalar =
134-
typename boost::remove_reference<MatType>::type::Scalar>
134+
template <typename MatType, typename Scalar>
135135
struct EigenFromPy;
136136

137137
template <typename T>

0 commit comments

Comments
 (0)