Skip to content

Commit a1e5877

Browse files
committed
core: deploy alignment support
1 parent a8980f8 commit a1e5877

File tree

6 files changed

+30
-79
lines changed

6 files changed

+30
-79
lines changed

include/eigenpy/eigen-from-python.hpp

Lines changed: 22 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
//
2-
// Copyright (c) 2014-2022 CNRS INRIA
2+
// Copyright (c) 2014-2023 CNRS INRIA
33
//
44

55
#ifndef __eigenpy_eigen_from_python_hpp__
66
#define __eigenpy_eigen_from_python_hpp__
77

8-
#include <boost/python/converter/rvalue_from_python_data.hpp>
9-
10-
#include "eigenpy/eigen-allocator.hpp"
118
#include "eigenpy/fwd.hpp"
9+
#include "eigenpy/eigen-allocator.hpp"
1210
#include "eigenpy/numpy-type.hpp"
1311
#include "eigenpy/scalar-conversion.hpp"
1412

@@ -67,15 +65,9 @@ struct referent_storage_eigen_ref;
6765
template <typename MatType, int Options, typename Stride>
6866
struct referent_storage_eigen_ref {
6967
typedef Eigen::Ref<MatType, Options, Stride> RefType;
70-
#if BOOST_VERSION / 100 % 1000 >= 77
71-
typedef typename ::boost::python::detail::aligned_storage<
72-
::boost::python::detail::referent_size<RefType &>::value,
73-
::boost::alignment_of<RefType &>::value>::type AlignedStorage;
74-
#else
75-
typedef ::boost::python::detail::aligned_storage<
76-
::boost::python::detail::referent_size<RefType &>::value>
68+
typedef typename ::eigenpy::aligned_storage<
69+
::boost::python::detail::referent_size<RefType &>::value>::type
7770
AlignedStorage;
78-
#endif
7971

8072
referent_storage_eigen_ref()
8173
: pyArray(NULL),
@@ -121,26 +113,17 @@ struct referent_storage<Eigen::Ref<MatType, Options, Stride> &> {
121113
typedef ::eigenpy::details::referent_storage_eigen_ref<MatType, Options,
122114
Stride>
123115
StorageType;
124-
#if BOOST_VERSION / 100 % 1000 >= 77
125-
typedef
126-
typename aligned_storage<referent_size<StorageType &>::value>::type type;
127-
#else
128-
typedef aligned_storage<referent_size<StorageType &>::value> type;
129-
#endif
116+
typedef typename ::eigenpy::aligned_storage<
117+
referent_size<StorageType &>::value>::type type;
130118
};
131119

132120
template <typename MatType, int Options, typename Stride>
133121
struct referent_storage<const Eigen::Ref<const MatType, Options, Stride> &> {
134122
typedef ::eigenpy::details::referent_storage_eigen_ref<const MatType, Options,
135123
Stride>
136124
StorageType;
137-
#if BOOST_VERSION / 100 % 1000 >= 77
138-
typedef
139-
typename aligned_storage<referent_size<StorageType &>::value,
140-
alignment_of<StorageType &>::value>::type type;
141-
#else
142-
typedef aligned_storage<referent_size<StorageType &>::value> type;
143-
#endif
125+
typedef typename ::eigenpy::aligned_storage<
126+
referent_size<StorageType &>::value>::type type;
144127
};
145128
#endif
146129
} // namespace detail
@@ -151,69 +134,39 @@ namespace boost {
151134
namespace python {
152135
namespace converter {
153136

154-
template <typename MatrixReference>
155-
struct rvalue_from_python_data_eigen
156-
: rvalue_from_python_storage<MatrixReference> {
157-
typedef MatrixReference T;
158-
159-
#if (!defined(__MWERKS__) || __MWERKS__ >= 0x3000) && \
160-
(!defined(__EDG_VERSION__) || __EDG_VERSION__ >= 245) && \
161-
(!defined(__DECCXX_VER) || __DECCXX_VER > 60590014) && \
162-
!defined(BOOST_PYTHON_SYNOPSIS) /* Synopsis' OpenCXX has trouble parsing \
163-
this */
164-
// This must always be a POD struct with m_data its first member.
165-
BOOST_STATIC_ASSERT(BOOST_PYTHON_OFFSETOF(rvalue_from_python_storage<T>,
166-
stage1) == 0);
167-
#endif
168-
169-
// The usual constructor
170-
rvalue_from_python_data_eigen(rvalue_from_python_stage1_data const &_stage1) {
171-
this->stage1 = _stage1;
172-
}
173-
174-
// This constructor just sets m_convertible -- used by
175-
// implicitly_convertible<> to perform the final step of the
176-
// conversion, where the construct() function is already known.
177-
rvalue_from_python_data_eigen(void *convertible) {
178-
this->stage1.convertible = convertible;
179-
}
180-
181-
// Destroys any object constructed in the storage.
182-
~rvalue_from_python_data_eigen() {
183-
typedef typename boost::remove_const<
184-
typename boost::remove_reference<MatrixReference>::type>::type
185-
MatrixType;
186-
if (this->stage1.convertible == this->storage.bytes)
187-
static_cast<MatrixType *>((void *)this->storage.bytes)->~MatrixType();
188-
}
189-
};
190-
191137
#define EIGENPY_RVALUE_FROM_PYTHON_DATA_INIT(type) \
192-
typedef rvalue_from_python_data_eigen<type> Base; \
138+
typedef ::eigenpy::rvalue_from_python_data<type> Base; \
193139
\
194140
rvalue_from_python_data(rvalue_from_python_stage1_data const &_stage1) \
195141
: Base(_stage1) {} \
196142
\
197143
rvalue_from_python_data(void *convertible) : Base(convertible){};
198144

199-
/// \brief Template specialization of rvalue_from_python_data
145+
template <typename Scalar, int Rows, int Cols, int Options, int MaxRows,
146+
int MaxCols>
147+
struct rvalue_from_python_data<
148+
Eigen::Matrix<Scalar, Rows, Cols, Options, MaxRows, MaxCols> const &>
149+
: ::eigenpy::rvalue_from_python_data<Eigen::Matrix<
150+
Scalar, Rows, Cols, Options, MaxRows, MaxCols> const &> {
151+
typedef Eigen::Matrix<Scalar, Rows, Cols, Options, MaxRows, MaxCols> T;
152+
EIGENPY_RVALUE_FROM_PYTHON_DATA_INIT(T const &)
153+
};
154+
200155
template <typename Derived>
201156
struct rvalue_from_python_data<Eigen::MatrixBase<Derived> const &>
202-
: rvalue_from_python_data_eigen<Derived const &> {
157+
: ::eigenpy::rvalue_from_python_data<Derived const &> {
203158
EIGENPY_RVALUE_FROM_PYTHON_DATA_INIT(Derived const &)
204159
};
205160

206-
/// \brief Template specialization of rvalue_from_python_data
207161
template <typename Derived>
208162
struct rvalue_from_python_data<Eigen::EigenBase<Derived> const &>
209-
: rvalue_from_python_data_eigen<Derived const &> {
163+
: ::eigenpy::rvalue_from_python_data<Derived const &> {
210164
EIGENPY_RVALUE_FROM_PYTHON_DATA_INIT(Derived const &)
211165
};
212166

213-
/// \brief Template specialization of rvalue_from_python_data
214167
template <typename Derived>
215168
struct rvalue_from_python_data<Eigen::PlainObjectBase<Derived> const &>
216-
: rvalue_from_python_data_eigen<Derived const &> {
169+
: ::eigenpy::rvalue_from_python_data<Derived const &> {
217170
EIGENPY_RVALUE_FROM_PYTHON_DATA_INIT(Derived const &)
218171
};
219172

include/eigenpy/eigen-to-python.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77

88
#include <boost/type_traits.hpp>
99

10-
#include "eigenpy/eigen-allocator.hpp"
1110
#include "eigenpy/fwd.hpp"
11+
12+
#include "eigenpy/eigen-allocator.hpp"
1213
#include "eigenpy/numpy-allocator.hpp"
1314
#include "eigenpy/numpy-type.hpp"
1415

include/eigenpy/eigenpy.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
#ifndef __eigenpy_eigenpy_hpp__
77
#define __eigenpy_eigenpy_hpp__
88

9+
#include "eigenpy/fwd.hpp"
910
#include "eigenpy/deprecated.hpp"
1011
#include "eigenpy/eigen-typedef.hpp"
11-
#include "eigenpy/fwd.hpp"
1212

1313
#define ENABLE_SPECIFIC_MATRIX_TYPE(TYPE) \
1414
::eigenpy::enableEigenPySpecific<TYPE>();

include/eigenpy/fwd.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#undef BOOST_BIND_GLOBAL_PLACEHOLDERS
2222

2323
#include <Eigen/Core>
24+
#include <Eigen/Geometry>
2425

2526
#if EIGEN_VERSION_AT_LEAST(3, 2, 90)
2627
#define EIGENPY_DEFAULT_ALIGNMENT_VALUE Eigen::Aligned16

include/eigenpy/geometry-conversion.hpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
/*
22
* Copyright 2014-2019, CNRS
3-
* Copyright 2018-2021, INRIA
3+
* Copyright 2018-2023, INRIA
44
*/
55

66
#ifndef __eigenpy_geometry_conversion_hpp__
77
#define __eigenpy_geometry_conversion_hpp__
88

9-
#include <Eigen/Geometry>
10-
119
#include "eigenpy/fwd.hpp"
1210

1311
namespace eigenpy {

include/eigenpy/quaternion.hpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
/*
2-
* Copyright 2014-2022 CNRS INRIA
2+
* Copyright 2014-2023 CNRS INRIA
33
*/
44

55
#ifndef __eigenpy_quaternion_hpp__
66
#define __eigenpy_quaternion_hpp__
77

8-
#include <Eigen/Core>
9-
#include <Eigen/Geometry>
10-
118
#include "eigenpy/eigenpy.hpp"
129
#include "eigenpy/exception.hpp"
10+
#include "eigenpy/eigen-from-python.hpp"
1311

1412
namespace boost {
1513
namespace python {
@@ -18,7 +16,7 @@ namespace converter {
1816
/// \brief Template specialization of rvalue_from_python_data
1917
template <typename Quaternion>
2018
struct rvalue_from_python_data<Eigen::QuaternionBase<Quaternion> const&>
21-
: rvalue_from_python_data_eigen<Quaternion const&> {
19+
: ::eigenpy::rvalue_from_python_data<Quaternion const&> {
2220
EIGENPY_RVALUE_FROM_PYTHON_DATA_INIT(Quaternion const&)
2321
};
2422

0 commit comments

Comments
 (0)