Skip to content

Commit 2244664

Browse files
committed
add docstrings to abstract classes
1 parent 6ead5bd commit 2244664

1 file changed

Lines changed: 30 additions & 3 deletions

File tree

‎Modules/_ctypes/_ctypes.c‎

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2899,6 +2899,13 @@ static PyMethodDef PyCData_methods[] = {
28992899
{ NULL, NULL },
29002900
};
29012901

2902+
PyDoc_STRVAR(cdata_doc,
2903+
"This non-public class is the common base class of all ctypes data types. Among other things, all ctypes type\n"
2904+
"instances contain a memory block that hold C compatible data; the address of the memory block is returned\n"
2905+
"by the addressof() helper function. Another instance variable is exposed as _objects; this contains\n"
2906+
"other Python objects that need to be kept alive in case the memory block contains pointers."
2907+
);
2908+
29022909
PyTypeObject PyCData_Type = {
29032910
PyVarObject_HEAD_INIT(NULL, 0)
29042911
"_ctypes._CData",
@@ -2920,7 +2927,7 @@ PyTypeObject PyCData_Type = {
29202927
0, /* tp_setattro */
29212928
&PyCData_as_buffer, /* tp_as_buffer */
29222929
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
2923-
PyDoc_STR("XXX to be provided"), /* tp_doc */
2930+
cdata_doc, /* tp_doc */
29242931
(traverseproc)PyCData_traverse, /* tp_traverse */
29252932
(inquiry)PyCData_clear, /* tp_clear */
29262933
0, /* tp_richcompare */
@@ -5020,6 +5027,13 @@ Simple_repr(CDataObject *self)
50205027
return result;
50215028
}
50225029

5030+
5031+
PyDoc_STRVAR(simple_cdata_doc,
5032+
"This non-public class is the base class of all fundamental ctypes data types.\n"
5033+
"It contains the common attributes of the fundamentalctypes data types.\n"
5034+
"_SimpleCData is a subclass of _CData, so it inherits their methods and attributes."
5035+
);
5036+
50235037
static PyTypeObject Simple_Type = {
50245038
PyVarObject_HEAD_INIT(NULL, 0)
50255039
"_ctypes._SimpleCData",
@@ -5041,7 +5055,7 @@ static PyTypeObject Simple_Type = {
50415055
0, /* tp_setattro */
50425056
&PyCData_as_buffer, /* tp_as_buffer */
50435057
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
5044-
PyDoc_STR("XXX to be provided"), /* tp_doc */
5058+
simple_cdata_doc, /* tp_doc */
50455059
(traverseproc)PyCData_traverse, /* tp_traverse */
50465060
(inquiry)PyCData_clear, /* tp_clear */
50475061
0, /* tp_richcompare */
@@ -5402,6 +5416,19 @@ static PyNumberMethods Pointer_as_number = {
54025416
(inquiry)Pointer_bool, /* nb_bool */
54035417
};
54045418

5419+
5420+
PyDoc_STRVAR(cpointer_doc,
5421+
"Private, abstract base class for pointers.\n"
5422+
"\n"
5423+
"Concrete pointer types are created by calling POINTER() with the type that will be pointed to; this is done\n"
5424+
"automatically by pointer().\n"
5425+
"\n"
5426+
"If a pointer points to an array, its elements can be read and written using standard subscript and slice ac-\n"
5427+
"cesses. Pointer objects have no size, so len() will raise TypeError. Negative subscripts will read from the\n"
5428+
"memory before the pointer (as in C), and out-of-range subscripts will probably crash with an access violation\n"
5429+
"(if you’re lucky)."
5430+
);
5431+
54055432
PyTypeObject PyCPointer_Type = {
54065433
PyVarObject_HEAD_INIT(NULL, 0)
54075434
"_ctypes._Pointer",
@@ -5423,7 +5450,7 @@ PyTypeObject PyCPointer_Type = {
54235450
0, /* tp_setattro */
54245451
&PyCData_as_buffer, /* tp_as_buffer */
54255452
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
5426-
PyDoc_STR("XXX to be provided"), /* tp_doc */
5453+
cpointer_doc, /* tp_doc */
54275454
(traverseproc)PyCData_traverse, /* tp_traverse */
54285455
(inquiry)PyCData_clear, /* tp_clear */
54295456
0, /* tp_richcompare */

0 commit comments

Comments
 (0)