1/* Descriptors */
2#ifndef Py_DESCROBJECT_H
3#define Py_DESCROBJECT_H
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8typedef PyObject *(*getter)(PyObject *, void *);
9typedef int (*setter)(PyObject *, PyObject *, void *);
10
11typedef struct PyGetSetDef {
12 const char *name;
13 getter get;
14 setter set;
15 const char *doc;
16 void *closure;
17} PyGetSetDef;
18
19#ifndef Py_LIMITED_API
20typedef PyObject *(*wrapperfunc)(PyObject *self, PyObject *args,
21 void *wrapped);
22
23typedef PyObject *(*wrapperfunc_kwds)(PyObject *self, PyObject *args,
24 void *wrapped, PyObject *kwds);
25
26struct wrapperbase {
27 const char *name;
28 int offset;
29 void *function;
30 wrapperfunc wrapper;
31 const char *doc;
32 int flags;
33 PyObject *name_strobj;
34};
35
36/* Flags for above struct */
37#define PyWrapperFlag_KEYWORDS 1 /* wrapper function takes keyword args */
38
39/* Various kinds of descriptor objects */
40
41typedef struct {
42 PyObject_HEAD
43 PyTypeObject *d_type;
44 PyObject *d_name;
45 PyObject *d_qualname;
46} PyDescrObject;
47
48#define PyDescr_COMMON PyDescrObject d_common
49
50#define PyDescr_TYPE(x) (((PyDescrObject *)(x))->d_type)
51#define PyDescr_NAME(x) (((PyDescrObject *)(x))->d_name)
52
53typedef struct {
54 PyDescr_COMMON;
55 PyMethodDef *d_method;
56 vectorcallfunc vectorcall;
57} PyMethodDescrObject;
58
59typedef struct {
60 PyDescr_COMMON;
61 struct PyMemberDef *d_member;
62} PyMemberDescrObject;
63
64typedef struct {
65 PyDescr_COMMON;
66 PyGetSetDef *d_getset;
67} PyGetSetDescrObject;
68
69typedef struct {
70 PyDescr_COMMON;
71 struct wrapperbase *d_base;
72 void *d_wrapped; /* This can be any function pointer */
73} PyWrapperDescrObject;
74#endif /* Py_LIMITED_API */
75
76PyAPI_DATA(PyTypeObject) PyClassMethodDescr_Type;
77PyAPI_DATA(PyTypeObject) PyGetSetDescr_Type;
78PyAPI_DATA(PyTypeObject) PyMemberDescr_Type;
79PyAPI_DATA(PyTypeObject) PyMethodDescr_Type;
80PyAPI_DATA(PyTypeObject) PyWrapperDescr_Type;
81PyAPI_DATA(PyTypeObject) PyDictProxy_Type;
82#ifndef Py_LIMITED_API
83PyAPI_DATA(PyTypeObject) _PyMethodWrapper_Type;
84#endif /* Py_LIMITED_API */
85
86PyAPI_FUNC(PyObject *) PyDescr_NewMethod(PyTypeObject *, PyMethodDef *);
87PyAPI_FUNC(PyObject *) PyDescr_NewClassMethod(PyTypeObject *, PyMethodDef *);
88struct PyMemberDef; /* forward declaration for following prototype */
89PyAPI_FUNC(PyObject *) PyDescr_NewMember(PyTypeObject *,
90 struct PyMemberDef *);
91PyAPI_FUNC(PyObject *) PyDescr_NewGetSet(PyTypeObject *,
92 struct PyGetSetDef *);
93#ifndef Py_LIMITED_API
94PyAPI_FUNC(PyObject *) PyDescr_NewWrapper(PyTypeObject *,
95 struct wrapperbase *, void *);
96PyAPI_FUNC(int) PyDescr_IsData(PyObject *);
97#endif
98
99PyAPI_FUNC(PyObject *) PyDictProxy_New(PyObject *);
100PyAPI_FUNC(PyObject *) PyWrapper_New(PyObject *, PyObject *);
101
102
103PyAPI_DATA(PyTypeObject) PyProperty_Type;
104#ifdef __cplusplus
105}
106#endif
107#endif /* !Py_DESCROBJECT_H */
108
109

source code of include/python3.10/descrobject.h