mirror of
https://github.com/pybind/pybind11.git
synced 2024-12-04 10:57:11 +00:00
try name wrapper?
This commit is contained in:
parent
07ccee567f
commit
c6ba82cbba
@ -124,13 +124,21 @@ class TypeVar : public object {
|
|||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
class NameWrapper : public object {
|
||||||
|
PYBIND11_OBJECT_DEFAULT(TypeVarObject, object, PyObject_Type)
|
||||||
|
using object::object;
|
||||||
|
NameWrapper(const char *name){
|
||||||
|
attr("__name__") = name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
class TypeVarObject : public object {
|
class TypeVarObject : public object {
|
||||||
PYBIND11_OBJECT_DEFAULT(TypeVarObject, object, PyObject_Type)
|
PYBIND11_OBJECT_DEFAULT(TypeVarObject, object, PyObject_Type)
|
||||||
using object::object;
|
using object::object;
|
||||||
TypeVarObject(const char *name) {
|
TypeVarObject(const char *name) {
|
||||||
attr("__name__") = name;
|
attr("__name__") = name;
|
||||||
attr("__bound__") = make_caster<T>;
|
attr("__bound__") = NameWrapper(make_caster<T>::name);
|
||||||
attr("__constraints__") = pybind11::make_tuple();
|
attr("__constraints__") = pybind11::make_tuple();
|
||||||
}
|
}
|
||||||
// TypeVarObject(const char *name, py::typing::Tuple<pybind11::type, pybind11::ellipse> tuple){
|
// TypeVarObject(const char *name, py::typing::Tuple<pybind11::type, pybind11::ellipse> tuple){
|
||||||
|
@ -925,16 +925,14 @@ TEST_SUBMODULE(pytypes, m) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct TypeVarObject {};
|
struct TypeVarObject {};
|
||||||
py::class_<TypeVarObject>(m, "TypeVarObject").type_params()
|
py::class_<TypeVarObject>(m, "TypeVarObject").type_params() = py::make_tuple(py::typing::TypeVarObject<int>("T"));
|
||||||
= py::make_tuple(py::typing::TypeVarObject<int>("T"));
|
|
||||||
|
|
||||||
struct ParamSpec {};
|
struct ParamSpec {};
|
||||||
py::class_<ParamSpec>(m, "ParamSpec").type_params()
|
py::class_<ParamSpec>(m, "ParamSpec").type_params() = py::make_tuple(py::typing::ParamSpec("P"));
|
||||||
= py::make_tuple(py::typing::ParamSpec("P"));
|
|
||||||
|
|
||||||
struct TypeVarTuple {};
|
struct TypeVarTuple {};
|
||||||
py::class_<TypeVarTuple>(m, "TypeVarTuple").type_params()
|
py::class_<TypeVarTuple>(m, "TypeVarTuple").type_params() = py::make_tuple(py::typing::TypeVarTuple("T"));
|
||||||
= py::make_tuple(py::typing::TypeVarTuple("T"));
|
|
||||||
|
|
||||||
struct NoTypeParams {};
|
struct NoTypeParams {};
|
||||||
struct TypeParams {};
|
struct TypeParams {};
|
||||||
|
Loading…
Reference in New Issue
Block a user