1/* Former class object interface -- now only bound methods are here */
2
3/* Revealing some structures (not for general use) */
4
5#ifndef Py_LIMITED_API
6#ifndef Py_CLASSOBJECT_H
7#define Py_CLASSOBJECT_H
8#ifdef __cplusplus
9extern "C" {
10#endif
11
12typedef struct {
13 PyObject_HEAD
14 PyObject *im_func; /* The callable object implementing the method */
15 PyObject *im_self; /* The instance it is bound to */
16 PyObject *im_weakreflist; /* List of weak references */
17 vectorcallfunc vectorcall;
18} PyMethodObject;
19
20PyAPI_DATA(PyTypeObject) PyMethod_Type;
21
22#define PyMethod_Check(op) Py_IS_TYPE(op, &PyMethod_Type)
23
24PyAPI_FUNC(PyObject *) PyMethod_New(PyObject *, PyObject *);
25
26PyAPI_FUNC(PyObject *) PyMethod_Function(PyObject *);
27PyAPI_FUNC(PyObject *) PyMethod_Self(PyObject *);
28
29/* Macros for direct access to these values. Type checks are *not*
30 done, so use with care. */
31#define PyMethod_GET_FUNCTION(meth) \
32 (((PyMethodObject *)meth) -> im_func)
33#define PyMethod_GET_SELF(meth) \
34 (((PyMethodObject *)meth) -> im_self)
35
36typedef struct {
37 PyObject_HEAD
38 PyObject *func;
39} PyInstanceMethodObject;
40
41PyAPI_DATA(PyTypeObject) PyInstanceMethod_Type;
42
43#define PyInstanceMethod_Check(op) Py_IS_TYPE(op, &PyInstanceMethod_Type)
44
45PyAPI_FUNC(PyObject *) PyInstanceMethod_New(PyObject *);
46PyAPI_FUNC(PyObject *) PyInstanceMethod_Function(PyObject *);
47
48/* Macros for direct access to these values. Type checks are *not*
49 done, so use with care. */
50#define PyInstanceMethod_GET_FUNCTION(meth) \
51 (((PyInstanceMethodObject *)meth) -> func)
52
53#ifdef __cplusplus
54}
55#endif
56#endif /* !Py_CLASSOBJECT_H */
57#endif /* Py_LIMITED_API */
58

source code of include/python3.10/classobject.h