blob: 1952f673b7d865442a85487f70c36fbab58f7102 [file] [log] [blame]
Christian Heimesff737952007-11-27 10:40:20 +00001/* Former class object interface -- now only 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
Martin v. Löwis4d0d4712010-12-03 20:14:31 +00005#ifndef Py_LIMITED_API
Fred Drakeea9cb5a2000-07-09 00:20:36 +00006#ifndef Py_CLASSOBJECT_H
7#define Py_CLASSOBJECT_H
8#ifdef __cplusplus
9extern "C" {
10#endif
11
Guido van Rossum81daa321993-05-20 14:24:46 +000012typedef struct {
Fred Drakeea9cb5a2000-07-09 00:20:36 +000013 PyObject_HEAD
Fred Drakeea9cb5a2000-07-09 00:20:36 +000014 PyObject *im_func; /* The callable object implementing the method */
Christian Heimesff737952007-11-27 10:40:20 +000015 PyObject *im_self; /* The instance it is bound to */
Fred Drake6a1c87d2001-03-23 04:17:58 +000016 PyObject *im_weakreflist; /* List of weak references */
Jeroen Demeyeraacc77f2019-05-29 20:31:52 +020017 vectorcallfunc vectorcall;
Guido van Rossumd4ba73c1998-07-10 15:46:33 +000018} PyMethodObject;
19
Guido van Rossum50e9fb92006-08-17 05:42:55 +000020PyAPI_DATA(PyTypeObject) PyMethod_Type;
Guido van Rossum85a5fbb1990-10-14 12:07:46 +000021
Dong-hee Nad212c3c2020-02-14 16:48:12 +090022#define PyMethod_Check(op) Py_IS_TYPE(op, &PyMethod_Type)
Guido van Rossum85a5fbb1990-10-14 12:07:46 +000023
Christian Heimesff737952007-11-27 10:40:20 +000024PyAPI_FUNC(PyObject *) PyMethod_New(PyObject *, PyObject *);
Guido van Rossum85a5fbb1990-10-14 12:07:46 +000025
Mark Hammond91a681d2002-08-12 07:21:58 +000026PyAPI_FUNC(PyObject *) PyMethod_Function(PyObject *);
27PyAPI_FUNC(PyObject *) PyMethod_Self(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) \
Serhiy Storchaka598ceae2017-11-28 17:56:10 +020034 (((PyMethodObject *)meth) -> im_self)
Guido van Rossumd4ba73c1998-07-10 15:46:33 +000035
Christian Heimesa3534a62007-12-11 19:56:40 +000036typedef struct {
Serhiy Storchaka598ceae2017-11-28 17:56:10 +020037 PyObject_HEAD
38 PyObject *func;
Christian Heimesa3534a62007-12-11 19:56:40 +000039} PyInstanceMethodObject;
40
41PyAPI_DATA(PyTypeObject) PyInstanceMethod_Type;
42
Dong-hee Nad212c3c2020-02-14 16:48:12 +090043#define PyInstanceMethod_Check(op) Py_IS_TYPE(op, &PyInstanceMethod_Type)
Christian Heimesa3534a62007-12-11 19:56:40 +000044
45PyAPI_FUNC(PyObject *) PyInstanceMethod_New(PyObject *);
46PyAPI_FUNC(PyObject *) PyInstanceMethod_Function(PyObject *);
47
48/* Macros for direct access to these values. Type checks are *not*
49 done, so use with care. */
50#define PyInstanceMethod_GET_FUNCTION(meth) \
51 (((PyInstanceMethodObject *)meth) -> func)
52
Guido van Rossuma3309961993-07-28 09:05:47 +000053#ifdef __cplusplus
54}
55#endif
56#endif /* !Py_CLASSOBJECT_H */
Martin v. Löwis4d0d4712010-12-03 20:14:31 +000057#endif /* Py_LIMITED_API */