Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added compatibility with SWIG 2.0 #476

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/core/include/iDynTree/Core/EigenHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ inline Eigen::Map<const Eigen::VectorXd> toEigen(const VectorDynSize & vec)
return Eigen::Map<const Eigen::VectorXd>(vec.data(),vec.size());
}

#if !defined(SWIG_VERSION) || SWIG_VERSION >= 0x030000
inline Eigen::Map<const Eigen::VectorXd> toEigen(Span<const double> vec)
{
return Eigen::Map<const Eigen::VectorXd>(vec.data(),vec.size());
Expand All @@ -72,6 +73,7 @@ inline Eigen::Map<Eigen::VectorXd> toEigen(iDynTree::Span<double> vec)
{
return Eigen::Map<Eigen::VectorXd>(vec.data(),vec.size());
}
#endif

inline Eigen::Map<const Eigen::Matrix<double,Eigen::Dynamic,Eigen::Dynamic,Eigen::RowMajor> > toEigen(const MatrixDynSize & mat)
{
Expand Down
10 changes: 7 additions & 3 deletions src/core/include/iDynTree/Core/VectorDynSize.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@
#ifndef IDYNTREE_DYNAMIC_SIZE_VECTOR_H
#define IDYNTREE_DYNAMIC_SIZE_VECTOR_H


#if !defined(SWIG_VERSION) || SWIG_VERSION >= 0x030000
#include <iDynTree/Core/Span.h>
#endif

#include <string>
#include <iDynTree/Core/Span.h>

namespace iDynTree
{
Expand Down Expand Up @@ -97,6 +98,7 @@ namespace iDynTree
*/
VectorDynSize & operator=(const VectorDynSize& vec);

#if !defined(SWIG_VERSION) || SWIG_VERSION >= 0x030000
/**
* Copy assignment operator.
*
Expand All @@ -107,7 +109,7 @@ namespace iDynTree
* \warning performs dynamic memory allocation operations
*/
VectorDynSize & operator=(const Span<const double>& vec);

#endif
/**
* @name Vector interface methods.
* Methods exposing a vector-like interface to PositionRaw.
Expand Down Expand Up @@ -187,6 +189,7 @@ namespace iDynTree
*/
void fillBuffer(double * buf) const;

#if !defined(SWIG_VERSION) || SWIG_VERSION >= 0x030000
/** Typedefs to enable make_span.
*/
///@{
Expand All @@ -198,6 +201,7 @@ namespace iDynTree

typedef typename std::allocator_traits<std::allocator<double>>::const_pointer const_pointer;
///@}
#endif

/** @name Output helpers.
* Output helpers.
Expand Down
8 changes: 8 additions & 0 deletions src/core/include/iDynTree/Core/VectorFixSize.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
#define IDYNTREE_VECTOR_FIX_SIZE_H

#include <iDynTree/Core/Utils.h>
#if !defined(SWIG_VERSION) || SWIG_VERSION >= 0x030000
#include <iDynTree/Core/Span.h>
#endif
#include <string>
#include <sstream>
#include <cassert>
Expand Down Expand Up @@ -69,13 +71,15 @@ namespace iDynTree

///@}

#if !defined(SWIG_VERSION) || SWIG_VERSION >= 0x030000
/**
* Copy assignment operator for spans.
*
* Checks that dimensions are matching through an assert.
*
*/
VectorFixSize & operator=(const Span<const double>& vec);
#endif

/**
* Raw data accessor
Expand Down Expand Up @@ -120,6 +124,7 @@ namespace iDynTree
std::string reservedToString() const;
///@}

#if !defined(SWIG_VERSION) || SWIG_VERSION >= 0x030000
/** Typedefs to enable make_span.
*/
///@{
Expand All @@ -131,6 +136,7 @@ namespace iDynTree

typedef typename std::allocator_traits<std::allocator<double>>::const_pointer const_pointer;
///@}
#endif

};

Expand Down Expand Up @@ -185,12 +191,14 @@ namespace iDynTree
return VecSize;
}

#if !defined(SWIG_VERSION) || SWIG_VERSION >= 0x030000
template<unsigned int VecSize>
VectorFixSize<VecSize> & VectorFixSize<VecSize>::operator=(const Span<const double>& vec) {
assert(VecSize == vec.size());
std::memcpy(this->m_data, vec.data(), VecSize*sizeof(double));
return *this;
}
#endif

template<unsigned int VecSize>
double VectorFixSize<VecSize>::operator()(const unsigned int index) const
Expand Down
7 changes: 2 additions & 5 deletions src/core/src/VectorDynSize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ VectorDynSize& VectorDynSize::operator=(const VectorDynSize& vec)
return *this;
}

#if !defined(SWIG_VERSION) || SWIG_VERSION >= 0x030000
VectorDynSize &VectorDynSize::operator=(const Span<const double> &vec)
{
// if the size don't match, reallocate the data
Expand All @@ -114,7 +115,7 @@ VectorDynSize &VectorDynSize::operator=(const Span<const double> &vec)

return *this;
}

#endif

void VectorDynSize::zero()
{
Expand Down Expand Up @@ -267,8 +268,4 @@ std::string VectorDynSize::reservedToString() const
return this->toString();
}





}
4 changes: 3 additions & 1 deletion src/model_io/urdf/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ find_package(LibXml2 REQUIRED)

set(IDYNTREE_MODELIO_URDF_HEADERS include/iDynTree/ModelIO/URDFDofsImport.h
include/iDynTree/ModelIO/ModelLoader.h
include/deprecated/iDynTree/ModelIO/URDFModelImport.h)
include/deprecated/iDynTree/ModelIO/URDFModelImport.h
include/deprecated/iDynTree/ModelIO/URDFGenericSensorsImport.h
include/deprecated/iDynTree/ModelIO/URDFSolidShapesImport.h)

set(IDYNTREE_MODELIO_URDF_PRIVATE_HEADERS include/private/URDFDocument.h
include/private/InertialElement.h
Expand Down