mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-22 13:15:12 +00:00
Make static member functions, added with def_static
, staticmethod
descriptor instances (#1732)
This commit is contained in:
parent
7a24bcf1f6
commit
d23c821b20
@ -1121,7 +1121,7 @@ public:
|
|||||||
"def_static(...) called with a non-static member function pointer");
|
"def_static(...) called with a non-static member function pointer");
|
||||||
cpp_function cf(std::forward<Func>(f), name(name_), scope(*this),
|
cpp_function cf(std::forward<Func>(f), name(name_), scope(*this),
|
||||||
sibling(getattr(*this, name_, none())), extra...);
|
sibling(getattr(*this, name_, none())), extra...);
|
||||||
attr(cf.name()) = cf;
|
attr(cf.name()) = staticmethod(cf);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -742,6 +742,8 @@ inline bool PyEllipsis_Check(PyObject *o) { return o == Py_Ellipsis; }
|
|||||||
|
|
||||||
inline bool PyUnicode_Check_Permissive(PyObject *o) { return PyUnicode_Check(o) || PYBIND11_BYTES_CHECK(o); }
|
inline bool PyUnicode_Check_Permissive(PyObject *o) { return PyUnicode_Check(o) || PYBIND11_BYTES_CHECK(o); }
|
||||||
|
|
||||||
|
inline bool PyStaticMethod_Check(PyObject *o) { return o->ob_type == &PyStaticMethod_Type; }
|
||||||
|
|
||||||
class kwargs_proxy : public handle {
|
class kwargs_proxy : public handle {
|
||||||
public:
|
public:
|
||||||
explicit kwargs_proxy(handle h) : handle(h) { }
|
explicit kwargs_proxy(handle h) : handle(h) { }
|
||||||
@ -1281,6 +1283,11 @@ public:
|
|||||||
bool is_cpp_function() const { return (bool) cpp_function(); }
|
bool is_cpp_function() const { return (bool) cpp_function(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class staticmethod : public object {
|
||||||
|
public:
|
||||||
|
PYBIND11_OBJECT_CVT(staticmethod, object, detail::PyStaticMethod_Check, PyStaticMethod_New)
|
||||||
|
};
|
||||||
|
|
||||||
class buffer : public object {
|
class buffer : public object {
|
||||||
public:
|
public:
|
||||||
PYBIND11_OBJECT_DEFAULT(buffer, object, PyObject_CheckBuffer)
|
PYBIND11_OBJECT_DEFAULT(buffer, object, PyObject_CheckBuffer)
|
||||||
|
Loading…
Reference in New Issue
Block a user