1 | /* Descriptors */ |
2 | #ifndef Py_DESCROBJECT_H |
3 | #define Py_DESCROBJECT_H |
4 | #ifdef __cplusplus |
5 | extern "C" { |
6 | #endif |
7 | |
8 | typedef PyObject *(*getter)(PyObject *, void *); |
9 | typedef int (*setter)(PyObject *, PyObject *, void *); |
10 | |
11 | typedef 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 |
20 | typedef PyObject *(*wrapperfunc)(PyObject *self, PyObject *args, |
21 | void *wrapped); |
22 | |
23 | typedef PyObject *(*wrapperfunc_kwds)(PyObject *self, PyObject *args, |
24 | void *wrapped, PyObject *kwds); |
25 | |
26 | struct 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 | |
41 | typedef 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 | |
53 | typedef struct { |
54 | PyDescr_COMMON; |
55 | PyMethodDef *d_method; |
56 | vectorcallfunc vectorcall; |
57 | } PyMethodDescrObject; |
58 | |
59 | typedef struct { |
60 | PyDescr_COMMON; |
61 | struct PyMemberDef *d_member; |
62 | } PyMemberDescrObject; |
63 | |
64 | typedef struct { |
65 | PyDescr_COMMON; |
66 | PyGetSetDef *d_getset; |
67 | } PyGetSetDescrObject; |
68 | |
69 | typedef 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 | |
76 | PyAPI_DATA(PyTypeObject) PyClassMethodDescr_Type; |
77 | PyAPI_DATA(PyTypeObject) PyGetSetDescr_Type; |
78 | PyAPI_DATA(PyTypeObject) PyMemberDescr_Type; |
79 | PyAPI_DATA(PyTypeObject) PyMethodDescr_Type; |
80 | PyAPI_DATA(PyTypeObject) PyWrapperDescr_Type; |
81 | PyAPI_DATA(PyTypeObject) PyDictProxy_Type; |
82 | #ifndef Py_LIMITED_API |
83 | PyAPI_DATA(PyTypeObject) _PyMethodWrapper_Type; |
84 | #endif /* Py_LIMITED_API */ |
85 | |
86 | PyAPI_FUNC(PyObject *) PyDescr_NewMethod(PyTypeObject *, PyMethodDef *); |
87 | PyAPI_FUNC(PyObject *) PyDescr_NewClassMethod(PyTypeObject *, PyMethodDef *); |
88 | struct PyMemberDef; /* forward declaration for following prototype */ |
89 | PyAPI_FUNC(PyObject *) PyDescr_NewMember(PyTypeObject *, |
90 | struct PyMemberDef *); |
91 | PyAPI_FUNC(PyObject *) PyDescr_NewGetSet(PyTypeObject *, |
92 | struct PyGetSetDef *); |
93 | #ifndef Py_LIMITED_API |
94 | PyAPI_FUNC(PyObject *) PyDescr_NewWrapper(PyTypeObject *, |
95 | struct wrapperbase *, void *); |
96 | PyAPI_FUNC(int) PyDescr_IsData(PyObject *); |
97 | #endif |
98 | |
99 | PyAPI_FUNC(PyObject *) PyDictProxy_New(PyObject *); |
100 | PyAPI_FUNC(PyObject *) PyWrapper_New(PyObject *, PyObject *); |
101 | |
102 | |
103 | PyAPI_DATA(PyTypeObject) PyProperty_Type; |
104 | #ifdef __cplusplus |
105 | } |
106 | #endif |
107 | #endif /* !Py_DESCROBJECT_H */ |
108 | |
109 | |