blob: 885c43e4cfd28494029c33f93bb4699a9eea4ca3 [file] [log] [blame]
Guido van Rossum50e9fb92006-08-17 05:42:55 +00001/* Former class object interface -- now only (un)bound methods are here */
Guido van Rossum85a5fbb1990-10-14 12:07:46 +00002
Guido van Rossumb3f72581993-05-21 19:56:10 +00003/* Revealing some structures (not for general use) */
Guido van Rossum85a5fbb1990-10-14 12:07:46 +00004
Fred Drakeea9cb5a2000-07-09 00:20:36 +00005#ifndef Py_CLASSOBJECT_H
6#define Py_CLASSOBJECT_H
7#ifdef __cplusplus
8extern "C" {
9#endif
10
Guido van Rossum81daa321993-05-20 14:24:46 +000011typedef struct {
Fred Drakeea9cb5a2000-07-09 00:20:36 +000012 PyObject_HEAD
Fred Drakeea9cb5a2000-07-09 00:20:36 +000013 PyObject *im_func; /* The callable object implementing the method */
14 PyObject *im_self; /* The instance it is bound to, or NULL */
Guido van Rossum301d0f82001-12-07 21:54:33 +000015 PyObject *im_class; /* The class that asked for the method */
Fred Drake6a1c87d2001-03-23 04:17:58 +000016 PyObject *im_weakreflist; /* List of weak references */
Guido van Rossumd4ba73c1998-07-10 15:46:33 +000017} PyMethodObject;
18
Guido van Rossum50e9fb92006-08-17 05:42:55 +000019PyAPI_DATA(PyTypeObject) PyMethod_Type;
Guido van Rossum85a5fbb1990-10-14 12:07:46 +000020
Guido van Rossumcaa63801995-01-12 11:45:45 +000021#define PyMethod_Check(op) ((op)->ob_type == &PyMethod_Type)
Guido van Rossum85a5fbb1990-10-14 12:07:46 +000022
Mark Hammond91a681d2002-08-12 07:21:58 +000023PyAPI_FUNC(PyObject *) PyMethod_New(PyObject *, PyObject *, PyObject *);
Guido van Rossum85a5fbb1990-10-14 12:07:46 +000024
Mark Hammond91a681d2002-08-12 07:21:58 +000025PyAPI_FUNC(PyObject *) PyMethod_Function(PyObject *);
26PyAPI_FUNC(PyObject *) PyMethod_Self(PyObject *);
27PyAPI_FUNC(PyObject *) PyMethod_Class(PyObject *);
Guido van Rossumb479dc52001-09-05 22:52:50 +000028
Guido van Rossumd4ba73c1998-07-10 15:46:33 +000029/* 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 Rossuma3309961993-07-28 09:05:47 +000038#ifdef __cplusplus
39}
40#endif
41#endif /* !Py_CLASSOBJECT_H */