/src/cpython-install/include/python3.15/cpython/classobject.h
Line | Count | Source (jump to first uncovered line) |
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 |
9 | | extern "C" { |
10 | | #endif |
11 | | |
12 | | typedef 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 | | |
20 | | PyAPI_DATA(PyTypeObject) PyMethod_Type; |
21 | | |
22 | | #define PyMethod_Check(op) Py_IS_TYPE((op), &PyMethod_Type) |
23 | | |
24 | | PyAPI_FUNC(PyObject *) PyMethod_New(PyObject *, PyObject *); |
25 | | |
26 | | PyAPI_FUNC(PyObject *) PyMethod_Function(PyObject *); |
27 | | PyAPI_FUNC(PyObject *) PyMethod_Self(PyObject *); |
28 | | |
29 | | #define _PyMethod_CAST(meth) \ |
30 | | (assert(PyMethod_Check(meth)), _Py_CAST(PyMethodObject*, meth)) |
31 | | |
32 | | /* Static inline functions for direct access to these values. |
33 | | Type checks are *not* done, so use with care. */ |
34 | 0 | static inline PyObject* PyMethod_GET_FUNCTION(PyObject *meth) { |
35 | 0 | return _PyMethod_CAST(meth)->im_func; |
36 | 0 | } |
37 | | #define PyMethod_GET_FUNCTION(meth) PyMethod_GET_FUNCTION(_PyObject_CAST(meth)) |
38 | | |
39 | 0 | static inline PyObject* PyMethod_GET_SELF(PyObject *meth) { |
40 | 0 | return _PyMethod_CAST(meth)->im_self; |
41 | 0 | } |
42 | | #define PyMethod_GET_SELF(meth) PyMethod_GET_SELF(_PyObject_CAST(meth)) |
43 | | |
44 | | typedef struct { |
45 | | PyObject_HEAD |
46 | | PyObject *func; |
47 | | } PyInstanceMethodObject; |
48 | | |
49 | | PyAPI_DATA(PyTypeObject) PyInstanceMethod_Type; |
50 | | |
51 | | #define PyInstanceMethod_Check(op) Py_IS_TYPE((op), &PyInstanceMethod_Type) |
52 | | |
53 | | PyAPI_FUNC(PyObject *) PyInstanceMethod_New(PyObject *); |
54 | | PyAPI_FUNC(PyObject *) PyInstanceMethod_Function(PyObject *); |
55 | | |
56 | | #define _PyInstanceMethod_CAST(meth) \ |
57 | | (assert(PyInstanceMethod_Check(meth)), \ |
58 | | _Py_CAST(PyInstanceMethodObject*, meth)) |
59 | | |
60 | | /* Static inline function for direct access to these values. |
61 | | Type checks are *not* done, so use with care. */ |
62 | 0 | static inline PyObject* PyInstanceMethod_GET_FUNCTION(PyObject *meth) { |
63 | 0 | return _PyInstanceMethod_CAST(meth)->func; |
64 | 0 | } |
65 | | #define PyInstanceMethod_GET_FUNCTION(meth) PyInstanceMethod_GET_FUNCTION(_PyObject_CAST(meth)) |
66 | | |
67 | | #ifdef __cplusplus |
68 | | } |
69 | | #endif |
70 | | #endif // !Py_CLASSOBJECT_H |
71 | | #endif // !Py_LIMITED_API |