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