• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #define PyCMethod_CheckExact(op) Py_IS_TYPE(op, &PyCMethod_Type)
8 #define PyCMethod_Check(op) PyObject_TypeCheck(op, &PyCMethod_Type)
9 
10 /* Macros for direct access to these values. Type checks are *not*
11    done, so use with care. */
12 #define PyCFunction_GET_FUNCTION(func) \
13         (((PyCFunctionObject *)func) -> m_ml -> ml_meth)
14 #define PyCFunction_GET_SELF(func) \
15         (((PyCFunctionObject *)func) -> m_ml -> ml_flags & METH_STATIC ? \
16          NULL : ((PyCFunctionObject *)func) -> m_self)
17 #define PyCFunction_GET_FLAGS(func) \
18         (((PyCFunctionObject *)func) -> m_ml -> ml_flags)
19 #define PyCFunction_GET_CLASS(func) \
20     (((PyCFunctionObject *)func) -> m_ml -> ml_flags & METH_METHOD ? \
21          ((PyCMethodObject *)func) -> mm_class : NULL)
22 
23 typedef struct {
24     PyObject_HEAD
25     PyMethodDef *m_ml; /* Description of the C function to call */
26     PyObject    *m_self; /* Passed as 'self' arg to the C func, can be NULL */
27     PyObject    *m_module; /* The __module__ attribute, can be anything */
28     PyObject    *m_weakreflist; /* List of weak references */
29     vectorcallfunc vectorcall;
30 } PyCFunctionObject;
31 
32 typedef struct {
33     PyCFunctionObject func;
34     PyTypeObject *mm_class; /* Class that defines this method */
35 } PyCMethodObject;
36