File indexing completed on 2025-01-18 10:06:41
0001 #ifndef Py_CPYTHON_METHODOBJECT_H
0002 # error "this header file must not be included directly"
0003 #endif
0004
0005
0006
0007 typedef struct {
0008 PyObject_HEAD
0009 PyMethodDef *m_ml;
0010 PyObject *m_self;
0011 PyObject *m_module;
0012 PyObject *m_weakreflist;
0013 vectorcallfunc vectorcall;
0014 } PyCFunctionObject;
0015
0016 #define _PyCFunctionObject_CAST(func) \
0017 (assert(PyCFunction_Check(func)), \
0018 _Py_CAST(PyCFunctionObject*, (func)))
0019
0020
0021
0022
0023 typedef struct {
0024 PyCFunctionObject func;
0025 PyTypeObject *mm_class;
0026 } PyCMethodObject;
0027
0028 #define _PyCMethodObject_CAST(func) \
0029 (assert(PyCMethod_Check(func)), \
0030 _Py_CAST(PyCMethodObject*, (func)))
0031
0032 PyAPI_DATA(PyTypeObject) PyCMethod_Type;
0033
0034 #define PyCMethod_CheckExact(op) Py_IS_TYPE((op), &PyCMethod_Type)
0035 #define PyCMethod_Check(op) PyObject_TypeCheck((op), &PyCMethod_Type)
0036
0037
0038
0039
0040 static inline PyCFunction PyCFunction_GET_FUNCTION(PyObject *func) {
0041 return _PyCFunctionObject_CAST(func)->m_ml->ml_meth;
0042 }
0043 #define PyCFunction_GET_FUNCTION(func) PyCFunction_GET_FUNCTION(_PyObject_CAST(func))
0044
0045 static inline PyObject* PyCFunction_GET_SELF(PyObject *func_obj) {
0046 PyCFunctionObject *func = _PyCFunctionObject_CAST(func_obj);
0047 if (func->m_ml->ml_flags & METH_STATIC) {
0048 return _Py_NULL;
0049 }
0050 return func->m_self;
0051 }
0052 #define PyCFunction_GET_SELF(func) PyCFunction_GET_SELF(_PyObject_CAST(func))
0053
0054 static inline int PyCFunction_GET_FLAGS(PyObject *func) {
0055 return _PyCFunctionObject_CAST(func)->m_ml->ml_flags;
0056 }
0057 #define PyCFunction_GET_FLAGS(func) PyCFunction_GET_FLAGS(_PyObject_CAST(func))
0058
0059 static inline PyTypeObject* PyCFunction_GET_CLASS(PyObject *func_obj) {
0060 PyCFunctionObject *func = _PyCFunctionObject_CAST(func_obj);
0061 if (func->m_ml->ml_flags & METH_METHOD) {
0062 return _PyCMethodObject_CAST(func)->mm_class;
0063 }
0064 return _Py_NULL;
0065 }
0066 #define PyCFunction_GET_CLASS(func) PyCFunction_GET_CLASS(_PyObject_CAST(func))