mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-22 05:05:11 +00:00
Merge branch 'master' of https://github.com/wjakob/pybind11
This commit is contained in:
commit
5d4d83da11
@ -104,7 +104,7 @@ template <typename type> class type_caster {
|
||||
public:
|
||||
typedef instance<type> instance_type;
|
||||
|
||||
static descr descr() { return typeid(type); }
|
||||
static descr name() { return typeid(type); }
|
||||
|
||||
type_caster() {
|
||||
auto const& registered_types = get_internals().registered_types;
|
||||
@ -211,7 +211,7 @@ protected:
|
||||
protected: \
|
||||
type value; \
|
||||
public: \
|
||||
static descr descr() { return py_name; } \
|
||||
static descr name() { return py_name; } \
|
||||
static PyObject *cast(const type *src, return_value_policy policy, PyObject *parent) { \
|
||||
return cast(*src, policy, parent); \
|
||||
} \
|
||||
@ -328,7 +328,7 @@ public:
|
||||
return PyUnicode_DecodeLatin1(str, 1, nullptr);
|
||||
}
|
||||
|
||||
static descr descr() { return "str"; }
|
||||
static descr name() { return "str"; }
|
||||
|
||||
operator char*() { return value; }
|
||||
operator char() { return *value; }
|
||||
@ -361,11 +361,11 @@ public:
|
||||
return tuple;
|
||||
}
|
||||
|
||||
static descr descr() {
|
||||
static descr name() {
|
||||
class descr result("(");
|
||||
result += std::move(type_caster<typename decay<T1>::type>::descr());
|
||||
result += std::move(type_caster<typename decay<T1>::type>::name());
|
||||
result += ", ";
|
||||
result += std::move(type_caster<typename decay<T2>::type>::descr());
|
||||
result += std::move(type_caster<typename decay<T2>::type>::name());
|
||||
result += ")";
|
||||
return result;
|
||||
}
|
||||
@ -391,9 +391,9 @@ public:
|
||||
return cast(src, policy, parent, typename make_index_sequence<size>::type());
|
||||
}
|
||||
|
||||
static descr descr(const char **keywords = nullptr, const char **values = nullptr) {
|
||||
std::array<class descr, size> descrs {{
|
||||
type_caster<typename decay<Tuple>::type>::descr()...
|
||||
static descr name(const char **keywords = nullptr, const char **values = nullptr) {
|
||||
std::array<class descr, size> names {{
|
||||
type_caster<typename decay<Tuple>::type>::name()...
|
||||
}};
|
||||
class descr result("(");
|
||||
for (int i=0; i<size; ++i) {
|
||||
@ -401,7 +401,7 @@ public:
|
||||
result += keywords[i];
|
||||
result += " : ";
|
||||
}
|
||||
result += std::move(descrs[i]);
|
||||
result += std::move(names[i]);
|
||||
if (values && values[i]) {
|
||||
result += " = ";
|
||||
result += values[i];
|
||||
|
@ -40,8 +40,8 @@ public:
|
||||
|
||||
|
||||
PYBIND_TYPE_CASTER(type, detail::descr("function<") +
|
||||
type_caster<std::tuple<Args...>>::descr() + detail::descr(" -> ") +
|
||||
type_caster<typename decay<Return>::type>::descr() +
|
||||
type_caster<std::tuple<Args...>>::name() + detail::descr(" -> ") +
|
||||
type_caster<typename decay<Return>::type>::name() +
|
||||
detail::descr(">"));
|
||||
};
|
||||
|
||||
|
@ -190,9 +190,9 @@ public:
|
||||
process_extras(((capture *) entry->data)->extras, entry, kw.data(), def.data());
|
||||
|
||||
|
||||
detail::descr d = cast_in::descr(kw.data(), def.data());
|
||||
detail::descr d = cast_in::name(kw.data(), def.data());
|
||||
d += " -> ";
|
||||
d += std::move(cast_out::descr());
|
||||
d += std::move(cast_out::name());
|
||||
|
||||
initialize(entry, d, sizeof...(Arg));
|
||||
}
|
||||
@ -247,9 +247,9 @@ private:
|
||||
std::array<const char *, N> kw{}, def{};
|
||||
process_extras(((capture *) entry->data)->extras, entry, kw.data(), def.data());
|
||||
|
||||
detail::descr d = cast_in::descr(kw.data(), def.data());
|
||||
detail::descr d = cast_in::name(kw.data(), def.data());
|
||||
d += " -> ";
|
||||
d += std::move(cast_out::descr());
|
||||
d += std::move(cast_out::name());
|
||||
|
||||
initialize(entry, d, sizeof...(Arg));
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ public:
|
||||
}
|
||||
return list;
|
||||
}
|
||||
PYBIND_TYPE_CASTER(type, detail::descr("list<") + value_conv::descr() + detail::descr(">"));
|
||||
PYBIND_TYPE_CASTER(type, detail::descr("list<") + value_conv::name() + detail::descr(">"));
|
||||
};
|
||||
|
||||
template <typename Key, typename Value> struct type_caster<std::map<Key, Value>> {
|
||||
@ -97,7 +97,7 @@ public:
|
||||
return dict;
|
||||
}
|
||||
|
||||
PYBIND_TYPE_CASTER(type, detail::descr("dict<") + key_conv::descr() + detail::descr(", ") + value_conv::descr() + detail::descr(">"));
|
||||
PYBIND_TYPE_CASTER(type, detail::descr("dict<") + key_conv::name() + detail::descr(", ") + value_conv::name() + detail::descr(">"));
|
||||
};
|
||||
|
||||
inline std::ostream &operator<<(std::ostream &os, const object &obj) { os << (const char *) obj.str(); return os; }
|
||||
|
Loading…
Reference in New Issue
Block a user