Guido van Rossum | 50e9fb9 | 2006-08-17 05:42:55 +0000 | [diff] [blame] | 1 | /* Former class object interface -- now only (un)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 | |
Fred Drake | ea9cb5a | 2000-07-09 00:20:36 +0000 | [diff] [blame] | 5 | #ifndef Py_CLASSOBJECT_H |
| 6 | #define Py_CLASSOBJECT_H |
| 7 | #ifdef __cplusplus |
| 8 | extern "C" { |
| 9 | #endif |
| 10 | |
Guido van Rossum | 81daa32 | 1993-05-20 14:24:46 +0000 | [diff] [blame] | 11 | typedef struct { |
Fred Drake | ea9cb5a | 2000-07-09 00:20:36 +0000 | [diff] [blame] | 12 | PyObject_HEAD |
Fred Drake | ea9cb5a | 2000-07-09 00:20:36 +0000 | [diff] [blame] | 13 | PyObject *im_func; /* The callable object implementing the method */ |
| 14 | PyObject *im_self; /* The instance it is bound to, or NULL */ |
Guido van Rossum | 301d0f8 | 2001-12-07 21:54:33 +0000 | [diff] [blame] | 15 | PyObject *im_class; /* The class that asked for the method */ |
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 | |
Mark Hammond | 91a681d | 2002-08-12 07:21:58 +0000 | [diff] [blame] | 23 | PyAPI_FUNC(PyObject *) PyMethod_New(PyObject *, 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 *); |
| 27 | PyAPI_FUNC(PyObject *) PyMethod_Class(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) \ |
| 34 | (((PyMethodObject *)meth) -> im_self) |
| 35 | #define PyMethod_GET_CLASS(meth) \ |
| 36 | (((PyMethodObject *)meth) -> im_class) |
| 37 | |
Guido van Rossum | a330996 | 1993-07-28 09:05:47 +0000 | [diff] [blame] | 38 | #ifdef __cplusplus |
| 39 | } |
| 40 | #endif |
| 41 | #endif /* !Py_CLASSOBJECT_H */ |