descrobject.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #ifndef Py_CPYTHON_DESCROBJECT_H
  2. # error "this header file must not be included directly"
  3. #endif
  4. typedef PyObject *(*wrapperfunc)(PyObject *self, PyObject *args,
  5. void *wrapped);
  6. typedef PyObject *(*wrapperfunc_kwds)(PyObject *self, PyObject *args,
  7. void *wrapped, PyObject *kwds);
  8. struct wrapperbase {
  9. const char *name;
  10. int offset;
  11. void *function;
  12. wrapperfunc wrapper;
  13. const char *doc;
  14. int flags;
  15. PyObject *name_strobj;
  16. };
  17. /* Flags for above struct */
  18. #define PyWrapperFlag_KEYWORDS 1 /* wrapper function takes keyword args */
  19. /* Various kinds of descriptor objects */
  20. typedef struct {
  21. PyObject_HEAD
  22. PyTypeObject *d_type;
  23. PyObject *d_name;
  24. PyObject *d_qualname;
  25. } PyDescrObject;
  26. #define PyDescr_COMMON PyDescrObject d_common
  27. #define PyDescr_TYPE(x) (((PyDescrObject *)(x))->d_type)
  28. #define PyDescr_NAME(x) (((PyDescrObject *)(x))->d_name)
  29. typedef struct {
  30. PyDescr_COMMON;
  31. PyMethodDef *d_method;
  32. vectorcallfunc vectorcall;
  33. } PyMethodDescrObject;
  34. typedef struct {
  35. PyDescr_COMMON;
  36. PyMemberDef *d_member;
  37. } PyMemberDescrObject;
  38. typedef struct {
  39. PyDescr_COMMON;
  40. PyGetSetDef *d_getset;
  41. } PyGetSetDescrObject;
  42. typedef struct {
  43. PyDescr_COMMON;
  44. struct wrapperbase *d_base;
  45. void *d_wrapped; /* This can be any function pointer */
  46. } PyWrapperDescrObject;
  47. PyAPI_DATA(PyTypeObject) _PyMethodWrapper_Type;
  48. PyAPI_FUNC(PyObject *) PyDescr_NewWrapper(PyTypeObject *,
  49. struct wrapperbase *, void *);
  50. PyAPI_FUNC(int) PyDescr_IsData(PyObject *);