Verified Commit cdcfab5d authored by Justin Carpentier's avatar Justin Carpentier
Browse files

core: fix definition order

parent e402f5d1
......@@ -7,6 +7,7 @@
#include "eigenpy/fwd.hpp"
#include "eigenpy/scalar-conversion.hpp"
#include "eigenpy/register.hpp"
#include <stdexcept>
#include <typeinfo>
......@@ -16,27 +17,6 @@ namespace eigenpy
{
namespace bp = boost::python;
// By default, the Scalar is considered as a Python object
template <typename Scalar> struct NumpyEquivalentType { enum { type_code = NPY_USERDEF };};
template <> struct NumpyEquivalentType<float> { enum { type_code = NPY_FLOAT };};
template <> struct NumpyEquivalentType< std::complex<float> > { enum { type_code = NPY_CFLOAT };};
template <> struct NumpyEquivalentType<double> { enum { type_code = NPY_DOUBLE };};
template <> struct NumpyEquivalentType< std::complex<double> > { enum { type_code = NPY_CDOUBLE };};
template <> struct NumpyEquivalentType<long double> { enum { type_code = NPY_LONGDOUBLE };};
template <> struct NumpyEquivalentType< std::complex<long double> > { enum { type_code = NPY_CLONGDOUBLE };};
template <> struct NumpyEquivalentType<bool> { enum { type_code = NPY_BOOL };};
template <> struct NumpyEquivalentType<int> { enum { type_code = NPY_INT };};
template <> struct NumpyEquivalentType<long> { enum { type_code = NPY_LONG };};
template<typename Scalar>
bool isNumpyNativeType()
{
if((int)NumpyEquivalentType<Scalar>::type_code == NPY_USERDEF)
return false;
return true;
}
template<typename Scalar>
bool np_type_is_convertible_into_scalar(const int np_type)
{
......
......@@ -31,6 +31,28 @@ namespace eigenpy
{
void EIGENPY_DLLAPI import_numpy();
int EIGENPY_DLLAPI PyArray_TypeNum(PyTypeObject * type);
// By default, the Scalar is considered as a Python object
template <typename Scalar> struct NumpyEquivalentType { enum { type_code = NPY_USERDEF };};
template <> struct NumpyEquivalentType<float> { enum { type_code = NPY_FLOAT };};
template <> struct NumpyEquivalentType< std::complex<float> > { enum { type_code = NPY_CFLOAT };};
template <> struct NumpyEquivalentType<double> { enum { type_code = NPY_DOUBLE };};
template <> struct NumpyEquivalentType< std::complex<double> > { enum { type_code = NPY_CDOUBLE };};
template <> struct NumpyEquivalentType<long double> { enum { type_code = NPY_LONGDOUBLE };};
template <> struct NumpyEquivalentType< std::complex<long double> > { enum { type_code = NPY_CLONGDOUBLE };};
template <> struct NumpyEquivalentType<bool> { enum { type_code = NPY_BOOL };};
template <> struct NumpyEquivalentType<int> { enum { type_code = NPY_INT };};
template <> struct NumpyEquivalentType<long> { enum { type_code = NPY_LONG };};
template<typename Scalar>
bool isNumpyNativeType()
{
if((int)NumpyEquivalentType<Scalar>::type_code == NPY_USERDEF)
return false;
return true;
}
}
#if defined _WIN32 || defined __CYGWIN__
......
......@@ -6,7 +6,7 @@
#define __eigenpy_register_hpp__
#include "eigenpy/fwd.hpp"
#include "eigenpy/numpy-type.hpp"
#include "eigenpy/numpy.hpp"
#include "eigenpy/exception.hpp"
#include <algorithm>
......@@ -36,6 +36,7 @@ namespace eigenpy
template<typename Scalar>
static PyTypeObject * getPyType()
{
namespace bp = boost::python;
if(!isNumpyNativeType<Scalar>())
{
const PyTypeObject * const_py_type_ptr = bp::converter::registered_pytype<Scalar>::get_pytype();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment