5 #ifndef __eigenpy_alignment_hpp__ 6 #define __eigenpy_alignment_hpp__ 8 #include <boost/python/detail/referent_storage.hpp> 9 #include <boost/python/converter/arg_from_python.hpp> 10 #include <boost/python/converter/rvalue_from_python_data.hpp> 11 #include <boost/type_traits/aligned_storage.hpp> 16 template <std::
size_t size, std::
size_t alignment = EIGENPY_DEFAULT_ALIGN_BYTES>
19 typename ::boost::aligned_storage<size, alignment>::type
data;
26 PyObject_VAR_HEAD PyObject *
dict;
35 void *original = std::malloc(size + alignment);
36 if (original == 0)
return 0;
37 if (
is_aligned(original, alignment))
return original;
39 reinterpret_cast<void *
>((
reinterpret_cast<std::size_t
>(original) &
40 ~(std::size_t(alignment - 1))) +
42 *(
reinterpret_cast<void **
>(aligned) - 1) = original;
52 template <
typename Scalar,
int Rows,
int Cols,
int Options,
int MaxRows,
54 struct referent_storage<
55 Eigen::Matrix<Scalar, Rows, Cols, Options, MaxRows, MaxCols> &> {
56 typedef Eigen::Matrix<Scalar, Rows, Cols, Options, MaxRows, MaxCols>
T;
61 template <
typename Scalar,
int Rows,
int Cols,
int Options,
int MaxRows,
63 struct referent_storage<
64 const
Eigen::Matrix<Scalar, Rows, Cols, Options, MaxRows, MaxCols> &> {
65 typedef Eigen::Matrix<Scalar, Rows, Cols, Options, MaxRows, MaxCols>
T;
70 #ifdef EIGENPY_WITH_TENSOR_SUPPORT 71 template <
typename Scalar,
int Rank,
int Options,
typename IndexType>
72 struct referent_storage<
Eigen::Tensor<Scalar, Rank, Options, IndexType> &> {
73 typedef Eigen::Tensor<Scalar, Rank, Options, IndexType>
T;
78 template <
typename Scalar,
int Rank,
int Options,
typename IndexType>
79 struct referent_storage<
80 const Eigen::Tensor<Scalar, Rank, Options, IndexType> &> {
81 typedef Eigen::Tensor<Scalar, Rank, Options, IndexType>
T;
87 template <
typename Scalar,
int Options>
88 struct referent_storage<Eigen::Quaternion<Scalar, Options> &> {
89 typedef Eigen::Quaternion<Scalar, Options>
T;
94 template <
typename Scalar,
int Options>
95 struct referent_storage<const Eigen::Quaternion<Scalar, Options> &> {
96 typedef Eigen::Quaternion<Scalar, Options>
T;
110 template <
typename Derived>
111 struct instance<value_holder<Derived> >
123 typedef typename boost::remove_const<
124 typename boost::remove_reference<T>::type>::type T_;
125 static_cast<T_ *
>((
void *)bytes)->~T_();
131 : ::boost::python::converter::rvalue_from_python_storage<T> {
132 #if (!defined(__MWERKS__) || __MWERKS__ >= 0x3000) && \ 133 (!defined(__EDG_VERSION__) || __EDG_VERSION__ >= 245) && \ 134 (!defined(__DECCXX_VER) || __DECCXX_VER > 60590014) && \ 135 !defined(BOOST_PYTHON_SYNOPSIS) 139 BOOST_PYTHON_OFFSETOF(
140 ::boost::python::converter::rvalue_from_python_storage<T>, stage1) ==
146 ::boost::python::converter::rvalue_from_python_stage1_data
const 148 this->stage1 = _stage1;
155 this->stage1.convertible = convertible;
160 if (this->stage1.convertible == this->storage.bytes) {
161 void *storage =
reinterpret_cast<void *
>(this->storage.bytes);
169 #endif // __eigenpy_alignment_hpp__ Eigen::Matrix< Scalar, Rows, Cols, Options, MaxRows, MaxCols > T
PyObject_VAR_HEAD PyObject * dict
rvalue_from_python_data(void *convertible)
~rvalue_from_python_data()
Eigen::Matrix< Scalar, Rows, Cols, Options, MaxRows, MaxCols > T
eigenpy::aligned_storage< referent_size< T & >::value >::type type
Eigen::Quaternion< Scalar, Options > T
#define EIGENPY_DEFAULT_ALIGN_BYTES
eigenpy::aligned_storage< referent_size< T & >::value >::type type
typename ::boost::aligned_storage< size, alignment >::type data
static void run(void *bytes)
rvalue_from_python_data(::boost::python::converter::rvalue_from_python_stage1_data const &_stage1)
bool is_aligned(const void *ptr, std::size_t alignment)
Eigen::Quaternion< Scalar, Options > T
void * aligned_malloc(std::size_t size, std::size_t alignment=EIGENPY_DEFAULT_ALIGN_BYTES)
boost::python::instance_holder * objects
aligned_storage< sizeof(Data)>::type storage
eigenpy::aligned_storage< referent_size< T & >::value >::type type
eigenpy::aligned_storage< referent_size< T & >::value >::type type