Commit f7d0611f authored by Patrik Huber's avatar Patrik Huber

Fixed compile error in docstring glm bindings

clang and gcc complained about this, while VS2015 accepted it. It turns out this is the much better way to do it!
parent 568294c6
...@@ -38,7 +38,7 @@ template<typename T, glm::precision P> ...@@ -38,7 +38,7 @@ template<typename T, glm::precision P>
struct type_caster<glm::tvec2<T, P>> struct type_caster<glm::tvec2<T, P>>
{ {
using vector_type = glm::tvec2<T, P>; using vector_type = glm::tvec2<T, P>;
typedef typename T Scalar; using Scalar = T;
static constexpr std::size_t num_elements = 2; static constexpr std::size_t num_elements = 2;
bool load(handle src, bool) bool load(handle src, bool)
...@@ -75,18 +75,14 @@ struct type_caster<glm::tvec2<T, P>> ...@@ -75,18 +75,14 @@ struct type_caster<glm::tvec2<T, P>>
// Specifies the doc-string for the type in Python: // Specifies the doc-string for the type in Python:
PYBIND11_TYPE_CASTER(vector_type, _("numpy.ndarray[") + npy_format_descriptor<Scalar>::name() + PYBIND11_TYPE_CASTER(vector_type, _("numpy.ndarray[") + npy_format_descriptor<Scalar>::name() +
_("[") + elements() + _("]]")); _("[") + _<num_elements>() + _("]]"));
protected:
template <typename T = vector_type>
static PYBIND11_DESCR elements() { return _(std::to_string(num_elements).c_str()); }
}; };
template<typename T, glm::precision P> template<typename T, glm::precision P>
struct type_caster<glm::tvec3<T, P>> struct type_caster<glm::tvec3<T, P>>
{ {
using vector_type = glm::tvec3<T, P>; using vector_type = glm::tvec3<T, P>;
typedef typename T Scalar; using Scalar = T;
static constexpr std::size_t num_elements = 3; static constexpr std::size_t num_elements = 3;
bool load(handle src, bool) bool load(handle src, bool)
...@@ -123,18 +119,14 @@ struct type_caster<glm::tvec3<T, P>> ...@@ -123,18 +119,14 @@ struct type_caster<glm::tvec3<T, P>>
// Specifies the doc-string for the type in Python: // Specifies the doc-string for the type in Python:
PYBIND11_TYPE_CASTER(vector_type, _("numpy.ndarray[") + npy_format_descriptor<Scalar>::name() + PYBIND11_TYPE_CASTER(vector_type, _("numpy.ndarray[") + npy_format_descriptor<Scalar>::name() +
_("[") + elements() + _("]]")); _("[") + _<num_elements>() + _("]]"));
protected:
template <typename T = vector_type>
static PYBIND11_DESCR elements() { return _(std::to_string(num_elements).c_str()); }
}; };
template<typename T, glm::precision P> template<typename T, glm::precision P>
struct type_caster<glm::tvec4<T, P>> struct type_caster<glm::tvec4<T, P>>
{ {
using vector_type = glm::tvec4<T, P>; using vector_type = glm::tvec4<T, P>;
typedef typename T Scalar; using Scalar = T;
static constexpr std::size_t num_elements = 4; static constexpr std::size_t num_elements = 4;
bool load(handle src, bool) bool load(handle src, bool)
...@@ -171,18 +163,14 @@ struct type_caster<glm::tvec4<T, P>> ...@@ -171,18 +163,14 @@ struct type_caster<glm::tvec4<T, P>>
// Specifies the doc-string for the type in Python: // Specifies the doc-string for the type in Python:
PYBIND11_TYPE_CASTER(vector_type, _("numpy.ndarray[") + npy_format_descriptor<Scalar>::name() + PYBIND11_TYPE_CASTER(vector_type, _("numpy.ndarray[") + npy_format_descriptor<Scalar>::name() +
_("[") + elements() + _("]]")); _("[") + _<num_elements>() + _("]]"));
protected:
template <typename T = vector_type>
static PYBIND11_DESCR elements() { return _(std::to_string(num_elements).c_str()); }
}; };
template<typename T, glm::precision P> template<typename T, glm::precision P>
struct type_caster<glm::tmat3x3<T, P>> struct type_caster<glm::tmat3x3<T, P>>
{ {
using matrix_type = glm::tmat3x3<T, P>; using matrix_type = glm::tmat3x3<T, P>;
typedef typename T Scalar; using Scalar = T;
static constexpr std::size_t num_rows = 3; static constexpr std::size_t num_rows = 3;
static constexpr std::size_t num_cols = 3; static constexpr std::size_t num_cols = 3;
...@@ -223,20 +211,14 @@ struct type_caster<glm::tmat3x3<T, P>> ...@@ -223,20 +211,14 @@ struct type_caster<glm::tmat3x3<T, P>>
// Specifies the doc-string for the type in Python: // Specifies the doc-string for the type in Python:
PYBIND11_TYPE_CASTER(matrix_type, _("numpy.ndarray[") + npy_format_descriptor<Scalar>::name() + PYBIND11_TYPE_CASTER(matrix_type, _("numpy.ndarray[") + npy_format_descriptor<Scalar>::name() +
_("[") + rows() + _(", ") + cols() + _("]]")); _("[") + _<num_rows>() + _(", ") + _<num_cols>() + _("]]"));
protected:
template <typename T = matrix_type>
static PYBIND11_DESCR rows() { return _(std::to_string(num_rows).c_str()); }
template <typename T = matrix_type>
static PYBIND11_DESCR cols() { return _(std::to_string(num_cols).c_str()); }
}; };
template<typename T, glm::precision P> template<typename T, glm::precision P>
struct type_caster<glm::tmat4x3<T, P>> struct type_caster<glm::tmat4x3<T, P>>
{ {
using matrix_type = glm::tmat4x3<T, P>; using matrix_type = glm::tmat4x3<T, P>;
typedef typename T Scalar; using Scalar = T;
static constexpr std::size_t num_rows = 3; static constexpr std::size_t num_rows = 3;
static constexpr std::size_t num_cols = 4; static constexpr std::size_t num_cols = 4;
...@@ -277,20 +259,14 @@ struct type_caster<glm::tmat4x3<T, P>> ...@@ -277,20 +259,14 @@ struct type_caster<glm::tmat4x3<T, P>>
// Specifies the doc-string for the type in Python: // Specifies the doc-string for the type in Python:
PYBIND11_TYPE_CASTER(matrix_type, _("numpy.ndarray[") + npy_format_descriptor<Scalar>::name() + PYBIND11_TYPE_CASTER(matrix_type, _("numpy.ndarray[") + npy_format_descriptor<Scalar>::name() +
_("[") + rows() + _(", ") + cols() + _("]]")); _("[") + _<num_rows>() + _(", ") + _<num_cols>() + _("]]"));
protected:
template <typename T = matrix_type>
static PYBIND11_DESCR rows() { return _(std::to_string(num_rows).c_str()); }
template <typename T = matrix_type>
static PYBIND11_DESCR cols() { return _(std::to_string(num_cols).c_str()); }
}; };
template<typename T, glm::precision P> template<typename T, glm::precision P>
struct type_caster<glm::tmat4x4<T, P>> struct type_caster<glm::tmat4x4<T, P>>
{ {
using matrix_type = glm::tmat4x4<T, P>; using matrix_type = glm::tmat4x4<T, P>;
typedef typename T Scalar; using Scalar = T;
static constexpr std::size_t num_rows = 4; static constexpr std::size_t num_rows = 4;
static constexpr std::size_t num_cols = 4; static constexpr std::size_t num_cols = 4;
...@@ -331,13 +307,7 @@ struct type_caster<glm::tmat4x4<T, P>> ...@@ -331,13 +307,7 @@ struct type_caster<glm::tmat4x4<T, P>>
// Specifies the doc-string for the type in Python: // Specifies the doc-string for the type in Python:
PYBIND11_TYPE_CASTER(matrix_type, _("numpy.ndarray[") + npy_format_descriptor<Scalar>::name() + PYBIND11_TYPE_CASTER(matrix_type, _("numpy.ndarray[") + npy_format_descriptor<Scalar>::name() +
_("[") + rows() + _(", ") + cols() + _("]]")); _("[") + _<num_rows>() + _(", ") + _<num_cols>() + _("]]"));
protected:
template <typename T = matrix_type>
static PYBIND11_DESCR rows() { return _(std::to_string(num_rows).c_str()); }
template <typename T = matrix_type>
static PYBIND11_DESCR cols() { return _(std::to_string(num_cols).c_str()); }
}; };
NAMESPACE_END(detail) NAMESPACE_END(detail)
......
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