classobject.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /* Former class object interface -- now only bound methods are here */
  2. /* Revealing some structures (not for general use) */
  3. #ifndef Py_LIMITED_API
  4. #ifndef Py_CLASSOBJECT_H
  5. #define Py_CLASSOBJECT_H
  6. #ifdef __cplusplus
  7. extern "C" {
  8. #endif
  9. typedef struct {
  10. PyObject_HEAD
  11. PyObject *im_func; /* The callable object implementing the method */
  12. PyObject *im_self; /* The instance it is bound to */
  13. PyObject *im_weakreflist; /* List of weak references */
  14. vectorcallfunc vectorcall;
  15. } PyMethodObject;
  16. PyAPI_DATA(PyTypeObject) PyMethod_Type;
  17. #define PyMethod_Check(op) Py_IS_TYPE(op, &PyMethod_Type)
  18. PyAPI_FUNC(PyObject *) PyMethod_New(PyObject *, PyObject *);
  19. PyAPI_FUNC(PyObject *) PyMethod_Function(PyObject *);
  20. PyAPI_FUNC(PyObject *) PyMethod_Self(PyObject *);
  21. /* Macros for direct access to these values. Type checks are *not*
  22. done, so use with care. */
  23. #define PyMethod_GET_FUNCTION(meth) \
  24. (((PyMethodObject *)meth) -> im_func)
  25. #define PyMethod_GET_SELF(meth) \
  26. (((PyMethodObject *)meth) -> im_self)
  27. typedef struct {
  28. PyObject_HEAD
  29. PyObject *func;
  30. } PyInstanceMethodObject;
  31. PyAPI_DATA(PyTypeObject) PyInstanceMethod_Type;
  32. #define PyInstanceMethod_Check(op) Py_IS_TYPE(op, &PyInstanceMethod_Type)
  33. PyAPI_FUNC(PyObject *) PyInstanceMethod_New(PyObject *);
  34. PyAPI_FUNC(PyObject *) PyInstanceMethod_Function(PyObject *);
  35. /* Macros for direct access to these values. Type checks are *not*
  36. done, so use with care. */
  37. #define PyInstanceMethod_GET_FUNCTION(meth) \
  38. (((PyInstanceMethodObject *)meth) -> func)
  39. #ifdef __cplusplus
  40. }
  41. #endif
  42. #endif /* !Py_CLASSOBJECT_H */
  43. #endif /* Py_LIMITED_API */