mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
Add optional docstrings to member descriptors. For backwards
compatibility, this required all places where an array of "struct memberlist" structures was declared that is referenced from a type's tp_members slot to change the type of the structure to PyMemberDef; "struct memberlist" is now only used by old code that still calls PyMember_Get/Set. The code in PyObject_GenericGetAttr/SetAttr now calls the new APIs PyMember_GetOne/SetOne, which take a PyMemberDef argument. As examples, I added actual docstrings to the attributes of a few types: file, complex, instance method, super, and xxsubtype.spamlist. Also converted the symtable to new style getattr.
This commit is contained in:
parent
e0af35eb69
commit
6f7993765a
17 changed files with 313 additions and 251 deletions
|
@ -21,7 +21,7 @@ struct wrapperbase {
|
|||
|
||||
extern DL_IMPORT(PyObject *) PyDescr_NewMethod(PyTypeObject *, PyMethodDef *);
|
||||
extern DL_IMPORT(PyObject *) PyDescr_NewMember(PyTypeObject *,
|
||||
struct memberlist *);
|
||||
struct PyMemberDef *);
|
||||
extern DL_IMPORT(PyObject *) PyDescr_NewGetSet(PyTypeObject *,
|
||||
struct getsetlist *);
|
||||
extern DL_IMPORT(PyObject *) PyDescr_NewWrapper(PyTypeObject *,
|
||||
|
|
|
@ -274,7 +274,7 @@ typedef struct _typeobject {
|
|||
|
||||
/* Attribute descriptor and subclassing stuff */
|
||||
struct PyMethodDef *tp_methods;
|
||||
struct memberlist *tp_members;
|
||||
struct PyMemberDef *tp_members;
|
||||
struct getsetlist *tp_getset;
|
||||
struct _typeobject *tp_base;
|
||||
PyObject *tp_dict;
|
||||
|
|
|
@ -28,12 +28,22 @@ extern "C" {
|
|||
pointer is NULL. */
|
||||
|
||||
struct memberlist {
|
||||
/* Obsolete version, for binary backwards compatibility */
|
||||
char *name;
|
||||
int type;
|
||||
int offset;
|
||||
int flags;
|
||||
};
|
||||
|
||||
typedef struct PyMemberDef {
|
||||
/* Current version, use this */
|
||||
char *name;
|
||||
int type;
|
||||
int offset;
|
||||
int flags;
|
||||
char *doc;
|
||||
} PyMemberDef;
|
||||
|
||||
/* Types */
|
||||
#define T_SHORT 0
|
||||
#define T_INT 1
|
||||
|
@ -66,9 +76,15 @@ struct memberlist {
|
|||
#define RESTRICTED (READ_RESTRICTED | WRITE_RESTRICTED)
|
||||
|
||||
|
||||
/* Obsolete API, for binary backwards compatibility */
|
||||
DL_IMPORT(PyObject *) PyMember_Get(char *, struct memberlist *, char *);
|
||||
DL_IMPORT(int) PyMember_Set(char *, struct memberlist *, char *, PyObject *);
|
||||
|
||||
/* Current API, use this */
|
||||
DL_IMPORT(PyObject *) PyMember_GetOne(char *, struct PyMemberDef *);
|
||||
DL_IMPORT(int) PyMember_SetOne(char *, struct PyMemberDef *, PyObject *);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue