methodobject.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435
  1. #ifndef Py_CPYTHON_METHODOBJECT_H
  2. # error "this header file must not be included directly"
  3. #endif
  4. PyAPI_DATA(PyTypeObject) PyCMethod_Type;
  5. #define PyCMethod_CheckExact(op) Py_IS_TYPE(op, &PyCMethod_Type)
  6. #define PyCMethod_Check(op) PyObject_TypeCheck(op, &PyCMethod_Type)
  7. /* Macros for direct access to these values. Type checks are *not*
  8. done, so use with care. */
  9. #define PyCFunction_GET_FUNCTION(func) \
  10. (((PyCFunctionObject *)func) -> m_ml -> ml_meth)
  11. #define PyCFunction_GET_SELF(func) \
  12. (((PyCFunctionObject *)func) -> m_ml -> ml_flags & METH_STATIC ? \
  13. NULL : ((PyCFunctionObject *)func) -> m_self)
  14. #define PyCFunction_GET_FLAGS(func) \
  15. (((PyCFunctionObject *)func) -> m_ml -> ml_flags)
  16. #define PyCFunction_GET_CLASS(func) \
  17. (((PyCFunctionObject *)func) -> m_ml -> ml_flags & METH_METHOD ? \
  18. ((PyCMethodObject *)func) -> mm_class : NULL)
  19. typedef struct {
  20. PyObject_HEAD
  21. PyMethodDef *m_ml; /* Description of the C function to call */
  22. PyObject *m_self; /* Passed as 'self' arg to the C func, can be NULL */
  23. PyObject *m_module; /* The __module__ attribute, can be anything */
  24. PyObject *m_weakreflist; /* List of weak references */
  25. vectorcallfunc vectorcall;
  26. } PyCFunctionObject;
  27. typedef struct {
  28. PyCFunctionObject func;
  29. PyTypeObject *mm_class; /* Class that defines this method */
  30. } PyCMethodObject;