Spaces:
Sleeping
Sleeping
// PyCFunctionObject structure | |
typedef struct { | |
PyObject_HEAD | |
PyMethodDef *m_ml; /* Description of the C function to call */ | |
PyObject *m_self; /* Passed as 'self' arg to the C func, can be NULL */ | |
PyObject *m_module; /* The __module__ attribute, can be anything */ | |
PyObject *m_weakreflist; /* List of weak references */ | |
vectorcallfunc vectorcall; | |
} PyCFunctionObject; | |
// PyCMethodObject structure | |
typedef struct { | |
PyCFunctionObject func; | |
PyTypeObject *mm_class; /* Class that defines this method */ | |
} PyCMethodObject; | |
PyAPI_DATA(PyTypeObject) PyCMethod_Type; | |
/* Static inline functions for direct access to these values. | |
Type checks are *not* done, so use with care. */ | |
static inline PyCFunction PyCFunction_GET_FUNCTION(PyObject *func) { | |
return _PyCFunctionObject_CAST(func)->m_ml->ml_meth; | |
} | |
static inline PyObject* PyCFunction_GET_SELF(PyObject *func_obj) { | |
PyCFunctionObject *func = _PyCFunctionObject_CAST(func_obj); | |
if (func->m_ml->ml_flags & METH_STATIC) { | |
return _Py_NULL; | |
} | |
return func->m_self; | |
} | |
static inline int PyCFunction_GET_FLAGS(PyObject *func) { | |
return _PyCFunctionObject_CAST(func)->m_ml->ml_flags; | |
} | |
static inline PyTypeObject* PyCFunction_GET_CLASS(PyObject *func_obj) { | |
PyCFunctionObject *func = _PyCFunctionObject_CAST(func_obj); | |
if (func->m_ml->ml_flags & METH_METHOD) { | |
return _PyCMethodObject_CAST(func)->mm_class; | |
} | |
return _Py_NULL; | |
} | |