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 */ |
Guido van Rossum | d4ba73c | 1998-07-10 15:46:33 +0000 | [diff] [blame] | 17 | } PyMethodObject; |
| 18 | |
Guido van Rossum | 50e9fb9 | 2006-08-17 05:42:55 +0000 | [diff] [blame] | 19 | PyAPI_DATA(PyTypeObject) PyMethod_Type; |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 20 | |
Guido van Rossum | caa6380 | 1995-01-12 11:45:45 +0000 | [diff] [blame] | 21 | #define PyMethod_Check(op) ((op)->ob_type == &PyMethod_Type) |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 22 | |
Christian Heimes | ff73795 | 2007-11-27 10:40:20 +0000 | [diff] [blame] | 23 | PyAPI_FUNC(PyObject *) PyMethod_New(PyObject *, PyObject *); |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 24 | |
Mark Hammond | 91a681d | 2002-08-12 07:21:58 +0000 | [diff] [blame] | 25 | PyAPI_FUNC(PyObject *) PyMethod_Function(PyObject *); |
| 26 | PyAPI_FUNC(PyObject *) PyMethod_Self(PyObject *); |
Guido van Rossum | b479dc5 | 2001-09-05 22:52:50 +0000 | [diff] [blame] | 27 | |
Guido van Rossum | d4ba73c | 1998-07-10 15:46:33 +0000 | [diff] [blame] | 28 | /* Macros for direct access to these values. Type checks are *not* |
| 29 | done, so use with care. */ |
| 30 | #define PyMethod_GET_FUNCTION(meth) \ |
| 31 | (((PyMethodObject *)meth) -> im_func) |
| 32 | #define PyMethod_GET_SELF(meth) \ |
| 33 | (((PyMethodObject *)meth) -> im_self) |
Guido van Rossum | d4ba73c | 1998-07-10 15:46:33 +0000 | [diff] [blame] | 34 | |
Christian Heimes | a156e09 | 2008-02-16 07:38:31 +0000 | [diff] [blame] | 35 | PyAPI_FUNC(int) PyMethod_ClearFreeList(void); |
Christian Heimes | a3534a6 | 2007-12-11 19:56:40 +0000 | [diff] [blame] | 36 | |
| 37 | typedef struct { |
| 38 | PyObject_HEAD |
| 39 | PyObject *func; |
| 40 | } PyInstanceMethodObject; |
| 41 | |
| 42 | PyAPI_DATA(PyTypeObject) PyInstanceMethod_Type; |
| 43 | |
| 44 | #define PyInstanceMethod_Check(op) ((op)->ob_type == &PyInstanceMethod_Type) |
| 45 | |
| 46 | PyAPI_FUNC(PyObject *) PyInstanceMethod_New(PyObject *); |
| 47 | PyAPI_FUNC(PyObject *) PyInstanceMethod_Function(PyObject *); |
| 48 | |
| 49 | /* Macros for direct access to these values. Type checks are *not* |
| 50 | done, so use with care. */ |
| 51 | #define PyInstanceMethod_GET_FUNCTION(meth) \ |
| 52 | (((PyInstanceMethodObject *)meth) -> func) |
| 53 | |
Guido van Rossum | a330996 | 1993-07-28 09:05:47 +0000 | [diff] [blame] | 54 | #ifdef __cplusplus |
| 55 | } |
| 56 | #endif |
| 57 | #endif /* !Py_CLASSOBJECT_H */ |
Martin v. Löwis | 4d0d471 | 2010-12-03 20:14:31 +0000 | [diff] [blame] | 58 | #endif /* Py_LIMITED_API */ |