Petr Viktorin | e1becf4 | 2020-05-07 15:39:59 +0200 | [diff] [blame^] | 1 | #ifndef Py_CPYTHON_METHODOBJECT_H |
| 2 | # error "this header file must not be included directly" |
| 3 | #endif |
| 4 | |
| 5 | PyAPI_DATA(PyTypeObject) PyCMethod_Type; |
| 6 | |
| 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 | |
| 20 | typedef struct { |
| 21 | PyObject_HEAD |
| 22 | PyMethodDef *m_ml; /* Description of the C function to call */ |
| 23 | PyObject *m_self; /* Passed as 'self' arg to the C func, can be NULL */ |
| 24 | PyObject *m_module; /* The __module__ attribute, can be anything */ |
| 25 | PyObject *m_weakreflist; /* List of weak references */ |
| 26 | vectorcallfunc vectorcall; |
| 27 | } PyCFunctionObject; |
| 28 | |
| 29 | typedef struct { |
| 30 | PyCFunctionObject func; |
| 31 | PyTypeObject *mm_class; /* Class that defines this method */ |
| 32 | } PyCMethodObject; |