Skip to content
Snippets Groups Projects
Verified Commit a1e58775 authored by Justin Carpentier's avatar Justin Carpentier
Browse files

core: deploy alignment support

parent a8980f85
No related branches found
No related tags found
No related merge requests found
// //
// Copyright (c) 2014-2022 CNRS INRIA // Copyright (c) 2014-2023 CNRS INRIA
// //
#ifndef __eigenpy_eigen_from_python_hpp__ #ifndef __eigenpy_eigen_from_python_hpp__
#define __eigenpy_eigen_from_python_hpp__ #define __eigenpy_eigen_from_python_hpp__
#include <boost/python/converter/rvalue_from_python_data.hpp>
#include "eigenpy/eigen-allocator.hpp"
#include "eigenpy/fwd.hpp" #include "eigenpy/fwd.hpp"
#include "eigenpy/eigen-allocator.hpp"
#include "eigenpy/numpy-type.hpp" #include "eigenpy/numpy-type.hpp"
#include "eigenpy/scalar-conversion.hpp" #include "eigenpy/scalar-conversion.hpp"
...@@ -67,15 +65,9 @@ struct referent_storage_eigen_ref; ...@@ -67,15 +65,9 @@ struct referent_storage_eigen_ref;
template <typename MatType, int Options, typename Stride> template <typename MatType, int Options, typename Stride>
struct referent_storage_eigen_ref { struct referent_storage_eigen_ref {
typedef Eigen::Ref<MatType, Options, Stride> RefType; typedef Eigen::Ref<MatType, Options, Stride> RefType;
#if BOOST_VERSION / 100 % 1000 >= 77 typedef typename ::eigenpy::aligned_storage<
typedef typename ::boost::python::detail::aligned_storage< ::boost::python::detail::referent_size<RefType &>::value>::type
::boost::python::detail::referent_size<RefType &>::value,
::boost::alignment_of<RefType &>::value>::type AlignedStorage;
#else
typedef ::boost::python::detail::aligned_storage<
::boost::python::detail::referent_size<RefType &>::value>
AlignedStorage; AlignedStorage;
#endif
referent_storage_eigen_ref() referent_storage_eigen_ref()
: pyArray(NULL), : pyArray(NULL),
...@@ -121,12 +113,8 @@ struct referent_storage<Eigen::Ref<MatType, Options, Stride> &> { ...@@ -121,12 +113,8 @@ struct referent_storage<Eigen::Ref<MatType, Options, Stride> &> {
typedef ::eigenpy::details::referent_storage_eigen_ref<MatType, Options, typedef ::eigenpy::details::referent_storage_eigen_ref<MatType, Options,
Stride> Stride>
StorageType; StorageType;
#if BOOST_VERSION / 100 % 1000 >= 77 typedef typename ::eigenpy::aligned_storage<
typedef referent_size<StorageType &>::value>::type type;
typename aligned_storage<referent_size<StorageType &>::value>::type type;
#else
typedef aligned_storage<referent_size<StorageType &>::value> type;
#endif
}; };
template <typename MatType, int Options, typename Stride> template <typename MatType, int Options, typename Stride>
...@@ -134,13 +122,8 @@ struct referent_storage<const Eigen::Ref<const MatType, Options, Stride> &> { ...@@ -134,13 +122,8 @@ struct referent_storage<const Eigen::Ref<const MatType, Options, Stride> &> {
typedef ::eigenpy::details::referent_storage_eigen_ref<const MatType, Options, typedef ::eigenpy::details::referent_storage_eigen_ref<const MatType, Options,
Stride> Stride>
StorageType; StorageType;
#if BOOST_VERSION / 100 % 1000 >= 77 typedef typename ::eigenpy::aligned_storage<
typedef referent_size<StorageType &>::value>::type type;
typename aligned_storage<referent_size<StorageType &>::value,
alignment_of<StorageType &>::value>::type type;
#else
typedef aligned_storage<referent_size<StorageType &>::value> type;
#endif
}; };
#endif #endif
} // namespace detail } // namespace detail
...@@ -151,69 +134,39 @@ namespace boost { ...@@ -151,69 +134,39 @@ namespace boost {
namespace python { namespace python {
namespace converter { namespace converter {
template <typename MatrixReference>
struct rvalue_from_python_data_eigen
: rvalue_from_python_storage<MatrixReference> {
typedef MatrixReference T;
#if (!defined(__MWERKS__) || __MWERKS__ >= 0x3000) && \
(!defined(__EDG_VERSION__) || __EDG_VERSION__ >= 245) && \
(!defined(__DECCXX_VER) || __DECCXX_VER > 60590014) && \
!defined(BOOST_PYTHON_SYNOPSIS) /* Synopsis' OpenCXX has trouble parsing \
this */
// This must always be a POD struct with m_data its first member.
BOOST_STATIC_ASSERT(BOOST_PYTHON_OFFSETOF(rvalue_from_python_storage<T>,
stage1) == 0);
#endif
// The usual constructor
rvalue_from_python_data_eigen(rvalue_from_python_stage1_data const &_stage1) {
this->stage1 = _stage1;
}
// This constructor just sets m_convertible -- used by
// implicitly_convertible<> to perform the final step of the
// conversion, where the construct() function is already known.
rvalue_from_python_data_eigen(void *convertible) {
this->stage1.convertible = convertible;
}
// Destroys any object constructed in the storage.
~rvalue_from_python_data_eigen() {
typedef typename boost::remove_const<
typename boost::remove_reference<MatrixReference>::type>::type
MatrixType;
if (this->stage1.convertible == this->storage.bytes)
static_cast<MatrixType *>((void *)this->storage.bytes)->~MatrixType();
}
};
#define EIGENPY_RVALUE_FROM_PYTHON_DATA_INIT(type) \ #define EIGENPY_RVALUE_FROM_PYTHON_DATA_INIT(type) \
typedef rvalue_from_python_data_eigen<type> Base; \ typedef ::eigenpy::rvalue_from_python_data<type> Base; \
\ \
rvalue_from_python_data(rvalue_from_python_stage1_data const &_stage1) \ rvalue_from_python_data(rvalue_from_python_stage1_data const &_stage1) \
: Base(_stage1) {} \ : Base(_stage1) {} \
\ \
rvalue_from_python_data(void *convertible) : Base(convertible){}; rvalue_from_python_data(void *convertible) : Base(convertible){};
/// \brief Template specialization of rvalue_from_python_data template <typename Scalar, int Rows, int Cols, int Options, int MaxRows,
int MaxCols>
struct rvalue_from_python_data<
Eigen::Matrix<Scalar, Rows, Cols, Options, MaxRows, MaxCols> const &>
: ::eigenpy::rvalue_from_python_data<Eigen::Matrix<
Scalar, Rows, Cols, Options, MaxRows, MaxCols> const &> {
typedef Eigen::Matrix<Scalar, Rows, Cols, Options, MaxRows, MaxCols> T;
EIGENPY_RVALUE_FROM_PYTHON_DATA_INIT(T const &)
};
template <typename Derived> template <typename Derived>
struct rvalue_from_python_data<Eigen::MatrixBase<Derived> const &> struct rvalue_from_python_data<Eigen::MatrixBase<Derived> const &>
: rvalue_from_python_data_eigen<Derived const &> { : ::eigenpy::rvalue_from_python_data<Derived const &> {
EIGENPY_RVALUE_FROM_PYTHON_DATA_INIT(Derived const &) EIGENPY_RVALUE_FROM_PYTHON_DATA_INIT(Derived const &)
}; };
/// \brief Template specialization of rvalue_from_python_data
template <typename Derived> template <typename Derived>
struct rvalue_from_python_data<Eigen::EigenBase<Derived> const &> struct rvalue_from_python_data<Eigen::EigenBase<Derived> const &>
: rvalue_from_python_data_eigen<Derived const &> { : ::eigenpy::rvalue_from_python_data<Derived const &> {
EIGENPY_RVALUE_FROM_PYTHON_DATA_INIT(Derived const &) EIGENPY_RVALUE_FROM_PYTHON_DATA_INIT(Derived const &)
}; };
/// \brief Template specialization of rvalue_from_python_data
template <typename Derived> template <typename Derived>
struct rvalue_from_python_data<Eigen::PlainObjectBase<Derived> const &> struct rvalue_from_python_data<Eigen::PlainObjectBase<Derived> const &>
: rvalue_from_python_data_eigen<Derived const &> { : ::eigenpy::rvalue_from_python_data<Derived const &> {
EIGENPY_RVALUE_FROM_PYTHON_DATA_INIT(Derived const &) EIGENPY_RVALUE_FROM_PYTHON_DATA_INIT(Derived const &)
}; };
......
...@@ -7,8 +7,9 @@ ...@@ -7,8 +7,9 @@
#include <boost/type_traits.hpp> #include <boost/type_traits.hpp>
#include "eigenpy/eigen-allocator.hpp"
#include "eigenpy/fwd.hpp" #include "eigenpy/fwd.hpp"
#include "eigenpy/eigen-allocator.hpp"
#include "eigenpy/numpy-allocator.hpp" #include "eigenpy/numpy-allocator.hpp"
#include "eigenpy/numpy-type.hpp" #include "eigenpy/numpy-type.hpp"
......
...@@ -6,9 +6,9 @@ ...@@ -6,9 +6,9 @@
#ifndef __eigenpy_eigenpy_hpp__ #ifndef __eigenpy_eigenpy_hpp__
#define __eigenpy_eigenpy_hpp__ #define __eigenpy_eigenpy_hpp__
#include "eigenpy/fwd.hpp"
#include "eigenpy/deprecated.hpp" #include "eigenpy/deprecated.hpp"
#include "eigenpy/eigen-typedef.hpp" #include "eigenpy/eigen-typedef.hpp"
#include "eigenpy/fwd.hpp"
#define ENABLE_SPECIFIC_MATRIX_TYPE(TYPE) \ #define ENABLE_SPECIFIC_MATRIX_TYPE(TYPE) \
::eigenpy::enableEigenPySpecific<TYPE>(); ::eigenpy::enableEigenPySpecific<TYPE>();
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#undef BOOST_BIND_GLOBAL_PLACEHOLDERS #undef BOOST_BIND_GLOBAL_PLACEHOLDERS
#include <Eigen/Core> #include <Eigen/Core>
#include <Eigen/Geometry>
#if EIGEN_VERSION_AT_LEAST(3, 2, 90) #if EIGEN_VERSION_AT_LEAST(3, 2, 90)
#define EIGENPY_DEFAULT_ALIGNMENT_VALUE Eigen::Aligned16 #define EIGENPY_DEFAULT_ALIGNMENT_VALUE Eigen::Aligned16
......
/* /*
* Copyright 2014-2019, CNRS * Copyright 2014-2019, CNRS
* Copyright 2018-2021, INRIA * Copyright 2018-2023, INRIA
*/ */
#ifndef __eigenpy_geometry_conversion_hpp__ #ifndef __eigenpy_geometry_conversion_hpp__
#define __eigenpy_geometry_conversion_hpp__ #define __eigenpy_geometry_conversion_hpp__
#include <Eigen/Geometry>
#include "eigenpy/fwd.hpp" #include "eigenpy/fwd.hpp"
namespace eigenpy { namespace eigenpy {
......
/* /*
* Copyright 2014-2022 CNRS INRIA * Copyright 2014-2023 CNRS INRIA
*/ */
#ifndef __eigenpy_quaternion_hpp__ #ifndef __eigenpy_quaternion_hpp__
#define __eigenpy_quaternion_hpp__ #define __eigenpy_quaternion_hpp__
#include <Eigen/Core>
#include <Eigen/Geometry>
#include "eigenpy/eigenpy.hpp" #include "eigenpy/eigenpy.hpp"
#include "eigenpy/exception.hpp" #include "eigenpy/exception.hpp"
#include "eigenpy/eigen-from-python.hpp"
namespace boost { namespace boost {
namespace python { namespace python {
...@@ -18,7 +16,7 @@ namespace converter { ...@@ -18,7 +16,7 @@ namespace converter {
/// \brief Template specialization of rvalue_from_python_data /// \brief Template specialization of rvalue_from_python_data
template <typename Quaternion> template <typename Quaternion>
struct rvalue_from_python_data<Eigen::QuaternionBase<Quaternion> const&> struct rvalue_from_python_data<Eigen::QuaternionBase<Quaternion> const&>
: rvalue_from_python_data_eigen<Quaternion const&> { : ::eigenpy::rvalue_from_python_data<Quaternion const&> {
EIGENPY_RVALUE_FROM_PYTHON_DATA_INIT(Quaternion const&) EIGENPY_RVALUE_FROM_PYTHON_DATA_INIT(Quaternion const&)
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment