5 #ifndef __eigenpy_register_hpp__ 6 #define __eigenpy_register_hpp__ 24 static PyArray_Descr * getPyArrayDescr(PyTypeObject * py_type_ptr);
26 template<
typename Scalar>
29 return isRegistered(Register::getPyType<Scalar>());
32 static bool isRegistered(PyTypeObject * py_type_ptr);
34 static int getTypeCode(PyTypeObject * py_type_ptr);
36 template<
typename Scalar>
39 if(!isNumpyNativeType<Scalar>())
41 const PyTypeObject * const_py_type_ptr = bp::converter::registered_pytype<Scalar>::get_pytype();
42 if(const_py_type_ptr == NULL)
45 ss <<
"The type " <<
typeid(Scalar).
name() <<
" does not have a registered converter inside Boot.Python." << std::endl;
46 throw std::invalid_argument(ss.str());
48 PyTypeObject * py_type_ptr =
const_cast<PyTypeObject *
>(const_py_type_ptr);
54 return new_descr->typeobj;
58 template<
typename Scalar>
61 if(isNumpyNativeType<Scalar>())
65 const std::type_info & info =
typeid(Scalar);
66 if(instance().type_to_py_type_bindings.find(&info) != instance().type_to_py_type_bindings.end())
68 PyTypeObject * py_type = instance().type_to_py_type_bindings[&info];
69 int code = instance().py_array_code_bindings[py_type];
79 const std::type_info * type_info_ptr,
81 PyArray_GetItemFunc * getitem,
82 PyArray_SetItemFunc * setitem,
83 PyArray_NonzeroFunc * nonzero,
84 PyArray_CopySwapFunc * copyswap,
85 PyArray_CopySwapNFunc * copyswapn,
86 PyArray_DotFunc * dotfunc);
96 bool operator()(
const PyTypeObject *
a,
const PyTypeObject * b)
const 98 return std::string(a->tp_name) < std::string(b->tp_name);
104 bool operator()(
const std::type_info *
a,
const std::type_info * b)
const 106 return std::string(a->name()) < std::string(b->name());
110 typedef std::map<const std::type_info *,PyTypeObject *,Compare_TypeInfo>
MapInfo;
113 typedef std::map<PyTypeObject *,PyArray_Descr *,Compare_PyTypeObject>
MapDescr;
116 typedef std::map<PyTypeObject *,int,Compare_PyTypeObject>
MapCode;
123 #endif // __eigenpy_register_hpp__ #define call_PyArray_DescrFromType(typenum)
MapCode py_array_code_bindings
std::map< PyTypeObject *, PyArray_Descr *, Compare_PyTypeObject > MapDescr
std::map< const std::type_info *, PyTypeObject *, Compare_TypeInfo > MapInfo
bool operator()(const std::type_info *a, const std::type_info *b) const
Structure collecting all the types registers in Numpy via EigenPy.
MapDescr py_array_descr_bindings
static PyTypeObject * getPyType()
std::map< PyTypeObject *, int, Compare_PyTypeObject > MapCode
static bool isRegistered()
bool operator()(const PyTypeObject *a, const PyTypeObject *b) const
MapInfo type_to_py_type_bindings
int registerNewType(PyTypeObject *py_type_ptr=NULL)