Skip to content

Commit 2920c55

Browse files
committed
Docs: fill in descriptor C API docs
1 parent ca95e97 commit 2920c55

File tree

1 file changed

+44
-10
lines changed

1 file changed

+44
-10
lines changed

Doc/c-api/descriptor.rst

Lines changed: 44 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,21 @@ Descriptor Objects
88
"Descriptors" are objects that describe some attribute of an object. They are
99
found in the dictionary of type objects.
1010

11-
.. XXX document these!
12-
1311
.. c:function:: PyObject* PyDescr_NewGetSet(PyTypeObject *type, struct PyGetSetDef *getset)
1412
13+
Create a new get-set descriptor for extension type *type* from the
14+
:c:type:`PyGetSetDef` structure *getset*.
15+
16+
On success, return a :term:`strong reference` to the descriptor. Return
17+
``NULL`` with an exception set on failure.
1518
16-
.. c:function:: PyObject* PyDescr_NewMember(PyTypeObject *type, struct PyMemberDef *meth)
19+
.. c:function:: PyObject* PyDescr_NewMember(PyTypeObject *type, struct PyMemberDef *member)
1720
21+
Create a new member descriptor for extension type *type* from the
22+
:c:type:`PyMemberDef` structure *member*.
23+
24+
On success, return a :term:`strong reference` to the descriptor. Return
25+
``NULL`` with an exception set on failure.
1826
1927
.. c:var:: PyTypeObject PyMemberDescr_Type
2028
@@ -30,22 +38,37 @@ found in the dictionary of type objects.
3038
The type object for get/set descriptor objects created from
3139
:c:type:`PyGetSetDef` structures. These descriptors implement attributes
3240
whose value is computed by C getter and setter functions, and are used
33-
for many built-in type attributes.
41+
for many built-in type attributes. They correspond to
42+
:class:`types.GetSetDescriptorType` objects in Python.
3443
3544
3645
.. c:function:: PyObject* PyDescr_NewMethod(PyTypeObject *type, struct PyMethodDef *meth)
3746
47+
Create a new method descriptor for extension type *type* from the
48+
:c:type:`PyMethodDef` structure *meth*.
49+
50+
On success, return a :term:`strong reference` to the descriptor. Return
51+
``NULL`` with an exception set on failure.
3852
3953
.. c:var:: PyTypeObject PyMethodDescr_Type
4054
4155
The type object for method descriptor objects created from
4256
:c:type:`PyMethodDef` structures. These descriptors expose C functions as
43-
methods on a type, and correspond to :class:`types.MemberDescriptorType`
57+
methods on a type, and correspond to :class:`types.MethodDescriptorType`
4458
objects in Python.
4559
4660
47-
.. c:function:: PyObject* PyDescr_NewWrapper(PyTypeObject *type, struct wrapperbase *wrapper, void *wrapped)
61+
.. c:function:: PyObject* PyDescr_NewWrapper(PyTypeObject *type, struct wrapperbase *base, void *wrapped)
4862
63+
Create a new wrapper descriptor for extension type *type* from the
64+
``struct wrapperbase`` structure *base* and the wrapped C function pointer
65+
*wrapped*.
66+
67+
Wrapper descriptors are used internally to expose special methods
68+
implemented by slot wrappers.
69+
70+
On success, return a :term:`strong reference` to the descriptor. Return
71+
``NULL`` with an exception set on failure.
4972
5073
.. c:var:: PyTypeObject PyWrapperDescr_Type
5174
@@ -58,6 +81,11 @@ found in the dictionary of type objects.
5881
5982
.. c:function:: PyObject* PyDescr_NewClassMethod(PyTypeObject *type, PyMethodDef *method)
6083
84+
Create a new class method descriptor for extension type *type* from the
85+
:c:type:`PyMethodDef` structure *method*.
86+
87+
On success, return a :term:`strong reference` to the descriptor. Return
88+
``NULL`` with an exception set on failure.
6189
6290
.. c:function:: int PyDescr_IsData(PyObject *descr)
6391
@@ -66,8 +94,14 @@ found in the dictionary of type objects.
6694
no error checking.
6795
6896
69-
.. c:function:: PyObject* PyWrapper_New(PyObject *, PyObject *)
97+
.. c:function:: PyObject* PyWrapper_New(PyObject *d, PyObject *self)
98+
99+
Create a new bound wrapper object from the wrapper descriptor *d* and the
100+
object *self*. The returned object appears in Python as a
101+
:class:`types.MethodWrapperType` instance.
70102
103+
On success, return a :term:`strong reference` to the wrapper object. Return
104+
``NULL`` with an exception set on failure.
71105
72106
.. c:macro:: PyDescr_COMMON
73107
@@ -104,9 +138,9 @@ Built-in descriptors
104138
.. c:var:: PyTypeObject PyClassMethodDescr_Type
105139
106140
The type object for C-level class method descriptor objects.
107-
This is the type of the descriptors created for :func:`classmethod` defined in
108-
C extension types, and is the same object as :class:`classmethod`
109-
in Python.
141+
This is the type of the descriptors created for :func:`classmethod` defined
142+
in C extension types, and corresponds to
143+
:class:`types.ClassMethodDescriptorType` objects in Python.
110144
111145
112146
.. c:function:: PyObject *PyClassMethod_New(PyObject *callable)

0 commit comments

Comments
 (0)