[Fix] updated autocxxpy: no constant instance will be passed from pybind11

This commit is contained in:
nanoric 2019-03-19 05:44:08 -04:00
parent 584f28ceaa
commit a6867e43d7

View File

@ -15,7 +15,7 @@ namespace autocxxpy
template <class tag, size_t size> template <class tag, size_t size>
struct get_string struct get_string
{ {
auto &operator()(string_literal<size> &val) auto &operator()(string_literal<size> &val) const noexcept
{ {
return val; return val;
} }
@ -38,7 +38,7 @@ namespace autocxxpy
template <class tag, class class_type, class value_type> template <class tag, class class_type, class value_type>
inline constexpr auto default_getter_wrap(value_type class_type::*member) inline constexpr auto default_getter_wrap(value_type class_type::*member)
{ // match normal case { // match normal case
return [member](const class_type &instance)->const value_type & { return [member](class_type &instance)->const value_type & {
return instance.*member; return instance.*member;
}; };
} }
@ -62,8 +62,8 @@ namespace autocxxpy
template <class tag, class class_type, class element_t, size_t size> template <class tag, class class_type, class element_t, size_t size>
inline constexpr auto default_getter_wrap(literal_array<element_t, size> class_type::*member) inline constexpr auto default_getter_wrap(literal_array<element_t, size> class_type::*member)
{ // match get any [] { // match get any []
return [member](const class_type &instance) { return [member](class_type &instance) {
auto es = std::vector<element_t *>(size); auto es = std::vector<const element_t *>(size);
for (size_t i = 0; i < size ; i++) for (size_t i = 0; i < size ; i++)
{ {
es[i] = instance.*member + i; es[i] = instance.*member + i;
@ -92,7 +92,7 @@ namespace autocxxpy
template <class tag, class class_type, class element_t, size_t size> template <class tag, class class_type, class element_t, size_t size>
inline constexpr auto default_getter_wrap(literal_array<element_t *, size> class_type::*member) inline constexpr auto default_getter_wrap(literal_array<element_t *, size> class_type::*member)
{ // match get (any *)[] { // match get (any *)[]
return [member](const class_type &instance) { return [member](class_type &instance) {
std::vector<element_t *> arr; std::vector<element_t *> arr;
for (auto &v : instance.*member) for (auto &v : instance.*member)
{ {
@ -106,7 +106,7 @@ namespace autocxxpy
template <class tag, class class_type, size_t size> template <class tag, class class_type, size_t size>
inline constexpr auto default_getter_wrap(string_literal<size> class_type::*member) inline constexpr auto default_getter_wrap(string_literal<size> class_type::*member)
{ // match get char [] { // match get char []
return [member](const class_type &instance) { return [member](class_type &instance) {
return get_string<tag, size>{}(instance.*member); return get_string<tag, size>{}(instance.*member);
}; };
} }