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 char *name;
13 getter get;
14 setter set;
15 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 char *name;
28 int offset;
29 void *function;
30 wrapperfunc wrapper;
31 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} PyMethodDescrObject;
57
58typedef struct {
59 PyDescr_COMMON;
60 struct PyMemberDef *d_member;
61} PyMemberDescrObject;
62
63typedef struct {
64 PyDescr_COMMON;
65 PyGetSetDef *d_getset;
66} PyGetSetDescrObject;
67
68typedef struct {
69 PyDescr_COMMON;
70 struct wrapperbase *d_base;
71 void *d_wrapped; /* This can be any function pointer */
72} PyWrapperDescrObject;
73#endif /* Py_LIMITED_API */
74
75PyAPI_DATA(PyTypeObject) PyClassMethodDescr_Type;
76PyAPI_DATA(PyTypeObject) PyGetSetDescr_Type;
77PyAPI_DATA(PyTypeObject) PyMemberDescr_Type;
78PyAPI_DATA(PyTypeObject) PyMethodDescr_Type;
79PyAPI_DATA(PyTypeObject) PyWrapperDescr_Type;
80PyAPI_DATA(PyTypeObject) PyDictProxy_Type;
81PyAPI_DATA(PyTypeObject) _PyMethodWrapper_Type;
82
83PyAPI_FUNC(PyObject *) PyDescr_NewMethod(PyTypeObject *, PyMethodDef *);
84PyAPI_FUNC(PyObject *) PyDescr_NewClassMethod(PyTypeObject *, PyMethodDef *);
85struct PyMemberDef; /* forward declaration for following prototype */
86PyAPI_FUNC(PyObject *) PyDescr_NewMember(PyTypeObject *,
87 struct PyMemberDef *);
88PyAPI_FUNC(PyObject *) PyDescr_NewGetSet(PyTypeObject *,
89 struct PyGetSetDef *);
90#ifndef Py_LIMITED_API
91PyAPI_FUNC(PyObject *) PyDescr_NewWrapper(PyTypeObject *,
92 struct wrapperbase *, void *);
93#define PyDescr_IsData(d) (Py_TYPE(d)->tp_descr_set != NULL)
94#endif
95
96PyAPI_FUNC(PyObject *) PyDictProxy_New(PyObject *);
97PyAPI_FUNC(PyObject *) PyWrapper_New(PyObject *, PyObject *);
98
99
100PyAPI_DATA(PyTypeObject) PyProperty_Type;
101#ifdef __cplusplus
102}
103#endif
104#endif /* !Py_DESCROBJECT_H */
105
106