Skip to content

Commit 1636178

Browse files
committed
core: remove macro and use inline functions
1 parent f83f64f commit 1636178

File tree

1 file changed

+54
-13
lines changed

1 file changed

+54
-13
lines changed

include/eigenpy/numpy.hpp

Lines changed: 54 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,10 @@ namespace eigenpy
6262

6363
}
6464

65-
#if defined _WIN32 || defined __CYGWIN__
65+
6666
namespace eigenpy
6767
{
68+
#if defined _WIN32 || defined __CYGWIN__
6869
EIGENPY_DLLAPI bool call_PyArray_Check(PyObject *);
6970

7071
EIGENPY_DLLAPI PyObject* call_PyArray_SimpleNew(int nd, npy_intp * shape, int np_type);
@@ -86,19 +87,59 @@ namespace eigenpy
8687
EIGENPY_DLLAPI PyArray_Descr * call_PyArray_MinScalarType(PyArrayObject *arr);
8788

8889
EIGENPY_DLLAPI int call_PyArray_RegisterCastFunc(PyArray_Descr* descr, int totype, PyArray_VectorUnaryFunc* castfunc);
89-
}
9090
#else
91-
#define call_PyArray_Check(py_obj) PyArray_Check(py_obj)
92-
#define call_PyArray_SimpleNew PyArray_SimpleNew
93-
#define call_PyArray_New(py_type_ptr,nd,shape,np_type,data_ptr,options) \
94-
PyArray_New(py_type_ptr,nd,shape,np_type,NULL,data_ptr,0,options,NULL)
95-
#define getPyArrayType() &PyArray_Type
96-
#define call_PyArray_DescrFromType(typenum) PyArray_DescrFromType(typenum)
97-
#define call_PyArray_MinScalarType(py_arr) PyArray_MinScalarType(py_arr)
98-
#define call_PyArray_InitArrFuncs(funcs) PyArray_InitArrFuncs(funcs)
99-
#define call_PyArray_RegisterDataType(dtype) PyArray_RegisterDataType(dtype)
100-
#define call_PyArray_RegisterCanCast(descr,totype,scalar) PyArray_RegisterCanCast(descr,totype,scalar)
101-
#define call_PyArray_RegisterCastFunc(descr,totype,castfunc) PyArray_RegisterCastFunc(descr,totype,castfunc)
91+
inline bool call_PyArray_Check(PyObject * py_obj)
92+
{
93+
return PyArray_Check(py_obj);
94+
}
95+
96+
inline PyObject* call_PyArray_SimpleNew(int nd, npy_intp * shape, int np_type)
97+
{
98+
return PyArray_SimpleNew(nd,shape,np_type);
99+
}
100+
101+
inline PyObject* call_PyArray_New(PyTypeObject * py_type_ptr, int nd, npy_intp * shape, int np_type, void * data_ptr, int options)
102+
{
103+
return PyArray_New(py_type_ptr,nd,shape,np_type,NULL,data_ptr,0,options,NULL);
104+
}
105+
106+
inline int call_PyArray_ObjectType(PyObject * obj, int val)
107+
{
108+
return PyArray_ObjectType(obj,val);
109+
}
110+
111+
inline PyTypeObject * getPyArrayType() { return &PyArray_Type; }
112+
113+
inline PyArray_Descr * call_PyArray_DescrFromType(int typenum)
114+
{
115+
return PyArray_DescrFromType(typenum);
116+
}
117+
118+
inline void call_PyArray_InitArrFuncs(PyArray_ArrFuncs * funcs)
119+
{
120+
PyArray_InitArrFuncs(funcs);
121+
}
122+
123+
inline int call_PyArray_RegisterDataType(PyArray_Descr * dtype)
124+
{
125+
return PyArray_RegisterDataType(dtype);
126+
}
127+
128+
inline PyArray_Descr * call_PyArray_MinScalarType(PyArrayObject * arr)
129+
{
130+
return PyArray_MinScalarType(arr);
131+
}
132+
133+
inline int call_PyArray_RegisterCanCast(PyArray_Descr *descr, int totype, NPY_SCALARKIND scalar)
134+
{
135+
return PyArray_RegisterCanCast(descr,totype,scalar);
136+
}
137+
138+
inline int call_PyArray_RegisterCastFunc(PyArray_Descr* descr, int totype, PyArray_VectorUnaryFunc* castfunc)
139+
{
140+
return PyArray_RegisterCastFunc(descr,totype,castfunc);
141+
}
102142
#endif
143+
}
103144

104145
#endif // ifndef __eigenpy_numpy_hpp__

0 commit comments

Comments
 (0)