Skip to content

Commit a17d1e4

Browse files
authored
use datatypeinfo (#464)
1 parent 39cc454 commit a17d1e4

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

bindings/SofaTypes/src/SofaPython3/SofaTypes/Binding_Vec.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,18 @@
2222
#include <functional>
2323
#include <pybind11/operators.h>
2424
#include <sstream>
25-
using sofa::type::Vec;
2625

27-
#define BINDING_VEC_MAKE_NAME(N, T) \
28-
std::string(std::string("Vec") + std::to_string(N) + typeid(T).name())
26+
#include <sofa/defaulttype/typeinfo/TypeInfo_Vec.h>
27+
28+
using sofa::type::Vec;
2929

30-
namespace pyVec {
30+
namespace pyVec
31+
{
3132
template <sofa::Size N, class T> std::string __str__(const Vec<N, T> &v, bool repr)
3233
{
3334
std::stringstream s ;
3435
s.imbue(std::locale("C"));
35-
s << ((repr) ? (BINDING_VEC_MAKE_NAME(N, T) + "(") : ("("));
36+
s << ((repr) ? (sofa::defaulttype::DataTypeInfo< Vec<N, T> >::name() + "(") : ("("));
3637
s << v[0];
3738
for (size_t i = 1; i < v.size(); ++i)
3839
s << ", " << v[i];
@@ -86,7 +87,7 @@ template <sofa::Size N, class T>
8687
py::class_<Vec<N,T>> addVec(py::module &m)
8788
{
8889
typedef Vec<N, T> VecClass;
89-
py::class_<Vec<N, T>> p(m, BINDING_VEC_MAKE_NAME(N, T).c_str());
90+
py::class_<Vec<N, T>> p(m, sofa::defaulttype::DataTypeInfo< Vec<N, T> >::name().c_str());
9091

9192
p.def(py::init<>()); // empty ctor
9293
p.def(py::init<const VecClass &>()); // copy ctor

0 commit comments

Comments
 (0)