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