descrobject.h 2.9 KB

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