@@ -77,38 +77,34 @@ found in the dictionary of type objects.
7777 methods on a type, and correspond to :class: `types.MethodDescriptorType `
7878 objects in Python.
7979
80+ .. c :var :: PyTypeObject PyWrapperDescr_Type
8081
81- .. c :struct :: wrapperbase
82+ The type object for wrapper descriptor objects created by
83+ :c:func: `PyDescr_NewWrapper ` and :c:func: `PyWrapper_New `.
8284
83- Describes a slot wrapper used by :c:func: `PyDescr_NewWrapper `.
85+ Wrapper descriptors are used internally to expose special methods
86+ such as ``__repr__ `` or ``__add__ ``, which are implemented by type slots.
87+ The type is exposed in Python as :class: `types.WrapperDescriptorType `.
8488
85- Each ``wrapperbase `` record stores the Python-visible name and metadata for a
86- special method implemented by a type slot, together with the wrapper
87- function used to adapt that slot to Python's calling convention.
8889
89- .. c :function :: PyObject* PyDescr_NewWrapper (PyTypeObject *type, struct wrapperbase *base, void *wrapped)
90+ .. `wrapperbase` & `PyWrapperFlag_KEYWORDS` show up in search and index,
91+ and link here, but are only referenced in prose:
9092
91- Create a new wrapper descriptor for extension type *type * from the
92- :c:struct: `wrapperbase ` structure *base * and the wrapped slot function
93- pointer
94- *wrapped *.
93+ .. c :struct :: wrapperbase
94+ :no-typesetting:
9595
96- Wrapper descriptors expose special methods implemented by type slots. This
97- is the same kind of descriptor that CPython creates for slot-based special
98- methods such as ``__repr__ `` or ``__add__ ``, and it appears in Python as a
99- :class: `types.WrapperDescriptorType ` object.
96+ .. c :macro :: PyWrapperFlag_KEYWORDS
97+ :no-typesetting:
10098
101- On success, return a :term: `strong reference ` to the descriptor. Return
102- ``NULL `` with an exception set on failure.
99+ .. c :function :: PyObject* PyDescr_NewWrapper (PyTypeObject *type, struct wrapperbase *base, void *wrapped)
103100
104- .. c :var :: PyTypeObject PyWrapperDescr_Type
101+ Create a new wrapper descriptor of type : c:var:` PyWrapperDescr_Type `.
105102
106- The type object for wrapper descriptor objects created by
107- :c:func: `PyDescr_NewWrapper ` and :c:func: `PyWrapper_New `. Wrapper
108- descriptors are used internally to expose special methods implemented
109- via wrapper structures, and appear in Python as
110- :class: `types.WrapperDescriptorType ` objects.
103+ This function is meant for internal use only; it and
104+ related API (``struct wrapperbase `` and the ``PyWrapperFlag_KEYWORDS ``
105+ flag) are exposed publicly for backwards compatibility reasons.
111106
107+ See :c:func:`PyCMethod_New` for wrapping a C function.
112108
113109.. c:function:: PyObject* PyDescr_NewClassMethod(PyTypeObject *type, PyMethodDef *method)
114110
@@ -143,6 +139,30 @@ found in the dictionary of type objects.
143139 On success, return a :term: `strong reference ` to the wrapper object. Return
144140 ``NULL `` with an exception set on failure.
145141
142+ .. c :macro :: PyDescr_TYPE(descr)
143+
144+ Return a :term: `borrowed reference ` to the type that the descriptor
145+ *descr * belongs to. This is accessible as :attr: `~object.__objclass__ `
146+ in Python.
147+
148+ *descr * must be a descriptor object created by one of the
149+ ``PyDescr_New* `` functions (an instance of
150+ :c:var: `PyMethodDescr_Type `, :c:var: `PyClassMethodDescr_Type `,
151+ :c:var: `PyMemberDescr_Type `, :c:var: `PyGetSetDescr_Type `, or
152+ :c:var: `PyWrapperDescr_Type `). If the passed descriptor is not
153+ an instance of one of these types, the behavior is undefined.
154+
155+
156+ .. c:macro:: PyDescr_NAME(descr)
157+
158+ Return the name of the descriptor *descr* as a :term:`borrowed reference`
159+ to a :class:`str` object. This is available as :attr:`~definition.__name__`
160+ in Python.
161+
162+ *descr* must be a descriptor object created by one of the ``PyDescr_New*``
163+ functions. If not, the behavior is undefined.
164+
165+
146166Built-in descriptors
147167^^^^^^^^^^^^^^^^^^^^
148168
0 commit comments