Christian Heimes | ff73795 | 2007-11-27 10:40:20 +0000 | [diff] [blame] | 1 | /* Former class object interface -- now only bound methods are here */ |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 2 | |
Guido van Rossum | b3f7258 | 1993-05-21 19:56:10 +0000 | [diff] [blame] | 3 | /* Revealing some structures (not for general use) */ |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 4 | |
Martin v. Löwis | 4d0d471 | 2010-12-03 20:14:31 +0000 | [diff] [blame] | 5 | #ifndef Py_LIMITED_API |
Fred Drake | ea9cb5a | 2000-07-09 00:20:36 +0000 | [diff] [blame] | 6 | #ifndef Py_CLASSOBJECT_H |
| 7 | #define Py_CLASSOBJECT_H |
| 8 | #ifdef __cplusplus |
| 9 | extern "C" { |
| 10 | #endif |
| 11 | |
Guido van Rossum | 81daa32 | 1993-05-20 14:24:46 +0000 | [diff] [blame] | 12 | typedef struct { |
Fred Drake | ea9cb5a | 2000-07-09 00:20:36 +0000 | [diff] [blame] | 13 | PyObject_HEAD |
Fred Drake | ea9cb5a | 2000-07-09 00:20:36 +0000 | [diff] [blame] | 14 | PyObject *im_func; /* The callable object implementing the method */ |
Christian Heimes | ff73795 | 2007-11-27 10:40:20 +0000 | [diff] [blame] | 15 | PyObject *im_self; /* The instance it is bound to */ |
Fred Drake | 6a1c87d | 2001-03-23 04:17:58 +0000 | [diff] [blame] | 16 | PyObject *im_weakreflist; /* List of weak references */ |
Jeroen Demeyer | aacc77f | 2019-05-29 20:31:52 +0200 | [diff] [blame^] | 17 | vectorcallfunc vectorcall; |
Guido van Rossum | d4ba73c | 1998-07-10 15:46:33 +0000 | [diff] [blame] | 18 | } PyMethodObject; |
| 19 | |
Guido van Rossum | 50e9fb9 | 2006-08-17 05:42:55 +0000 | [diff] [blame] | 20 | PyAPI_DATA(PyTypeObject) PyMethod_Type; |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 21 | |
Guido van Rossum | caa6380 | 1995-01-12 11:45:45 +0000 | [diff] [blame] | 22 | #define PyMethod_Check(op) ((op)->ob_type == &PyMethod_Type) |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 23 | |
Christian Heimes | ff73795 | 2007-11-27 10:40:20 +0000 | [diff] [blame] | 24 | PyAPI_FUNC(PyObject *) PyMethod_New(PyObject *, PyObject *); |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 25 | |
Mark Hammond | 91a681d | 2002-08-12 07:21:58 +0000 | [diff] [blame] | 26 | PyAPI_FUNC(PyObject *) PyMethod_Function(PyObject *); |
| 27 | PyAPI_FUNC(PyObject *) PyMethod_Self(PyObject *); |
Guido van Rossum | b479dc5 | 2001-09-05 22:52:50 +0000 | [diff] [blame] | 28 | |
Guido van Rossum | d4ba73c | 1998-07-10 15:46:33 +0000 | [diff] [blame] | 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) \ |
Serhiy Storchaka | 598ceae | 2017-11-28 17:56:10 +0200 | [diff] [blame] | 34 | (((PyMethodObject *)meth) -> im_self) |
Guido van Rossum | d4ba73c | 1998-07-10 15:46:33 +0000 | [diff] [blame] | 35 | |
Christian Heimes | a156e09 | 2008-02-16 07:38:31 +0000 | [diff] [blame] | 36 | PyAPI_FUNC(int) PyMethod_ClearFreeList(void); |
Christian Heimes | a3534a6 | 2007-12-11 19:56:40 +0000 | [diff] [blame] | 37 | |
| 38 | typedef struct { |
Serhiy Storchaka | 598ceae | 2017-11-28 17:56:10 +0200 | [diff] [blame] | 39 | PyObject_HEAD |
| 40 | PyObject *func; |
Christian Heimes | a3534a6 | 2007-12-11 19:56:40 +0000 | [diff] [blame] | 41 | } PyInstanceMethodObject; |
| 42 | |
| 43 | PyAPI_DATA(PyTypeObject) PyInstanceMethod_Type; |
| 44 | |
| 45 | #define PyInstanceMethod_Check(op) ((op)->ob_type == &PyInstanceMethod_Type) |
| 46 | |
| 47 | PyAPI_FUNC(PyObject *) PyInstanceMethod_New(PyObject *); |
| 48 | PyAPI_FUNC(PyObject *) PyInstanceMethod_Function(PyObject *); |
| 49 | |
| 50 | /* Macros for direct access to these values. Type checks are *not* |
| 51 | done, so use with care. */ |
| 52 | #define PyInstanceMethod_GET_FUNCTION(meth) \ |
| 53 | (((PyInstanceMethodObject *)meth) -> func) |
| 54 | |
Guido van Rossum | a330996 | 1993-07-28 09:05:47 +0000 | [diff] [blame] | 55 | #ifdef __cplusplus |
| 56 | } |
| 57 | #endif |
| 58 | #endif /* !Py_CLASSOBJECT_H */ |
Martin v. Löwis | 4d0d471 | 2010-12-03 20:14:31 +0000 | [diff] [blame] | 59 | #endif /* Py_LIMITED_API */ |