classobject.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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) ((op)->ob_type == &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. PyAPI_FUNC(int) PyMethod_ClearFreeList(void);
  28. typedef struct {
  29. PyObject_HEAD
  30. PyObject *func;
  31. } PyInstanceMethodObject;
  32. PyAPI_DATA(PyTypeObject) PyInstanceMethod_Type;
  33. #define PyInstanceMethod_Check(op) ((op)->ob_type == &PyInstanceMethod_Type)
  34. PyAPI_FUNC(PyObject *) PyInstanceMethod_New(PyObject *);
  35. PyAPI_FUNC(PyObject *) PyInstanceMethod_Function(PyObject *);
  36. /* Macros for direct access to these values. Type checks are *not*
  37. done, so use with care. */
  38. #define PyInstanceMethod_GET_FUNCTION(meth) \
  39. (((PyInstanceMethodObject *)meth) -> func)
  40. #ifdef __cplusplus
  41. }
  42. #endif
  43. #endif /* !Py_CLASSOBJECT_H */
  44. #endif /* Py_LIMITED_API */