From cdcfab5dc4bcd28f611d575f0797c5a4aab9a439 Mon Sep 17 00:00:00 2001
From: Justin Carpentier <justin.carpentier@inria.fr>
Date: Tue, 15 Jun 2021 18:58:52 +0200
Subject: [PATCH] core: fix definition order

---
 include/eigenpy/numpy-type.hpp | 22 +---------------------
 include/eigenpy/numpy.hpp      | 22 ++++++++++++++++++++++
 include/eigenpy/register.hpp   |  3 ++-
 3 files changed, 25 insertions(+), 22 deletions(-)

diff --git a/include/eigenpy/numpy-type.hpp b/include/eigenpy/numpy-type.hpp
index c9bccd7..ecc2404 100644
--- a/include/eigenpy/numpy-type.hpp
+++ b/include/eigenpy/numpy-type.hpp
@@ -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)
   {
diff --git a/include/eigenpy/numpy.hpp b/include/eigenpy/numpy.hpp
index 1631a79..bd68b7c 100644
--- a/include/eigenpy/numpy.hpp
+++ b/include/eigenpy/numpy.hpp
@@ -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__
diff --git a/include/eigenpy/register.hpp b/include/eigenpy/register.hpp
index 58bb770..2164449 100644
--- a/include/eigenpy/register.hpp
+++ b/include/eigenpy/register.hpp
@@ -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();
-- 
GitLab