| 1981 | }; |
| 1982 | |
| 1983 | class weakref : public object { |
| 1984 | public: |
| 1985 | PYBIND11_OBJECT_CVT_DEFAULT(weakref, object, PyWeakref_Check, raw_weakref) |
| 1986 | explicit weakref(handle obj, handle callback = {}) |
| 1987 | : object(PyWeakref_NewRef(obj.ptr(), callback.ptr()), stolen_t{}) { |
| 1988 | if (!m_ptr) { |
| 1989 | if (PyErr_Occurred()) { |
| 1990 | throw error_already_set(); |
| 1991 | } |
| 1992 | pybind11_fail("Could not allocate weak reference!"); |
| 1993 | } |
| 1994 | } |
| 1995 | |
| 1996 | private: |
| 1997 | static PyObject *raw_weakref(PyObject *o) { return PyWeakref_NewRef(o, nullptr); } |
| 1998 | }; |
| 1999 | |
| 2000 | class slice : public object { |
| 2001 | public: |
no outgoing calls