blob: 7ecbfe3b5e2fe87d9482bd56f72b69fce37d6c26 [file] [log] [blame]
Petr Viktorine1becf42020-05-07 15:39:59 +02001#ifndef Py_CPYTHON_METHODOBJECT_H
2# error "this header file must not be included directly"
3#endif
4
5PyAPI_DATA(PyTypeObject) PyCMethod_Type;
6
scoder4c9ea092020-05-12 16:12:41 +02007#define PyCMethod_CheckExact(op) Py_IS_TYPE(op, &PyCMethod_Type)
8#define PyCMethod_Check(op) PyObject_TypeCheck(op, &PyCMethod_Type)
9
Petr Viktorine1becf42020-05-07 15:39:59 +020010/* 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
23typedef 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
32typedef struct {
33 PyCFunctionObject func;
34 PyTypeObject *mm_class; /* Class that defines this method */
35} PyCMethodObject;