Guido van Rossum | 32d34c8 | 2001-09-20 21:45:26 +0000 | [diff] [blame] | 1 | /* Descriptors */ |
Martin v. Löwis | 522cf1f | 2002-03-30 08:57:12 +0000 | [diff] [blame] | 2 | #ifndef Py_DESCROBJECT_H |
| 3 | #define Py_DESCROBJECT_H |
| 4 | #ifdef __cplusplus |
| 5 | extern "C" { |
| 6 | #endif |
Tim Peters | 6d6c1a3 | 2001-08-02 04:15:00 +0000 | [diff] [blame] | 7 | |
| 8 | typedef PyObject *(*getter)(PyObject *, void *); |
| 9 | typedef int (*setter)(PyObject *, PyObject *, void *); |
| 10 | |
Guido van Rossum | 32d34c8 | 2001-09-20 21:45:26 +0000 | [diff] [blame] | 11 | typedef struct PyGetSetDef { |
Tim Peters | 6d6c1a3 | 2001-08-02 04:15:00 +0000 | [diff] [blame] | 12 | char *name; |
| 13 | getter get; |
| 14 | setter set; |
Guido van Rossum | 32d34c8 | 2001-09-20 21:45:26 +0000 | [diff] [blame] | 15 | char *doc; |
Tim Peters | 6d6c1a3 | 2001-08-02 04:15:00 +0000 | [diff] [blame] | 16 | void *closure; |
Guido van Rossum | 32d34c8 | 2001-09-20 21:45:26 +0000 | [diff] [blame] | 17 | } PyGetSetDef; |
Tim Peters | 6d6c1a3 | 2001-08-02 04:15:00 +0000 | [diff] [blame] | 18 | |
| 19 | typedef PyObject *(*wrapperfunc)(PyObject *self, PyObject *args, |
| 20 | void *wrapped); |
| 21 | |
Guido van Rossum | c8e5645 | 2001-10-22 00:43:43 +0000 | [diff] [blame] | 22 | typedef PyObject *(*wrapperfunc_kwds)(PyObject *self, PyObject *args, |
| 23 | void *wrapped, PyObject *kwds); |
| 24 | |
Tim Peters | 6d6c1a3 | 2001-08-02 04:15:00 +0000 | [diff] [blame] | 25 | struct wrapperbase { |
| 26 | char *name; |
Guido van Rossum | 6d20407 | 2001-10-21 00:44:31 +0000 | [diff] [blame] | 27 | int offset; |
| 28 | void *function; |
Tim Peters | 6d6c1a3 | 2001-08-02 04:15:00 +0000 | [diff] [blame] | 29 | wrapperfunc wrapper; |
| 30 | char *doc; |
Guido van Rossum | c8e5645 | 2001-10-22 00:43:43 +0000 | [diff] [blame] | 31 | int flags; |
Guido van Rossum | 6d20407 | 2001-10-21 00:44:31 +0000 | [diff] [blame] | 32 | PyObject *name_strobj; |
Tim Peters | 6d6c1a3 | 2001-08-02 04:15:00 +0000 | [diff] [blame] | 33 | }; |
| 34 | |
Guido van Rossum | c8e5645 | 2001-10-22 00:43:43 +0000 | [diff] [blame] | 35 | /* Flags for above struct */ |
| 36 | #define PyWrapperFlag_KEYWORDS 1 /* wrapper function takes keyword args */ |
| 37 | |
Guido van Rossum | f4593e0 | 2001-10-03 12:09:30 +0000 | [diff] [blame] | 38 | /* Various kinds of descriptor objects */ |
| 39 | |
| 40 | #define PyDescr_COMMON \ |
| 41 | PyObject_HEAD \ |
| 42 | PyTypeObject *d_type; \ |
| 43 | PyObject *d_name |
| 44 | |
| 45 | typedef struct { |
| 46 | PyDescr_COMMON; |
| 47 | } PyDescrObject; |
| 48 | |
| 49 | typedef struct { |
| 50 | PyDescr_COMMON; |
| 51 | PyMethodDef *d_method; |
| 52 | } PyMethodDescrObject; |
| 53 | |
| 54 | typedef struct { |
| 55 | PyDescr_COMMON; |
| 56 | struct PyMemberDef *d_member; |
| 57 | } PyMemberDescrObject; |
| 58 | |
| 59 | typedef struct { |
| 60 | PyDescr_COMMON; |
| 61 | PyGetSetDef *d_getset; |
| 62 | } PyGetSetDescrObject; |
| 63 | |
| 64 | typedef struct { |
| 65 | PyDescr_COMMON; |
| 66 | struct wrapperbase *d_base; |
| 67 | void *d_wrapped; /* This can be any function pointer */ |
| 68 | } PyWrapperDescrObject; |
| 69 | |
Mark Hammond | 91a681d | 2002-08-12 07:21:58 +0000 | [diff] [blame] | 70 | PyAPI_DATA(PyTypeObject) PyWrapperDescr_Type; |
Guido van Rossum | f4593e0 | 2001-10-03 12:09:30 +0000 | [diff] [blame] | 71 | |
Mark Hammond | 91a681d | 2002-08-12 07:21:58 +0000 | [diff] [blame] | 72 | PyAPI_FUNC(PyObject *) PyDescr_NewMethod(PyTypeObject *, PyMethodDef *); |
Tim Peters | bca1cbc | 2002-12-09 22:56:13 +0000 | [diff] [blame] | 73 | PyAPI_FUNC(PyObject *) PyDescr_NewClassMethod(PyTypeObject *, PyMethodDef *); |
Mark Hammond | 91a681d | 2002-08-12 07:21:58 +0000 | [diff] [blame] | 74 | PyAPI_FUNC(PyObject *) PyDescr_NewMember(PyTypeObject *, |
Guido van Rossum | 6f79937 | 2001-09-20 20:46:19 +0000 | [diff] [blame] | 75 | struct PyMemberDef *); |
Mark Hammond | 91a681d | 2002-08-12 07:21:58 +0000 | [diff] [blame] | 76 | PyAPI_FUNC(PyObject *) PyDescr_NewGetSet(PyTypeObject *, |
Guido van Rossum | 32d34c8 | 2001-09-20 21:45:26 +0000 | [diff] [blame] | 77 | struct PyGetSetDef *); |
Mark Hammond | 91a681d | 2002-08-12 07:21:58 +0000 | [diff] [blame] | 78 | PyAPI_FUNC(PyObject *) PyDescr_NewWrapper(PyTypeObject *, |
Tim Peters | 6d6c1a3 | 2001-08-02 04:15:00 +0000 | [diff] [blame] | 79 | struct wrapperbase *, void *); |
Martin v. Löwis | 9f2e346 | 2007-07-21 17:22:18 +0000 | [diff] [blame] | 80 | #define PyDescr_IsData(d) (Py_Type(d)->tp_descr_set != NULL) |
Tim Peters | 6d6c1a3 | 2001-08-02 04:15:00 +0000 | [diff] [blame] | 81 | |
Mark Hammond | 91a681d | 2002-08-12 07:21:58 +0000 | [diff] [blame] | 82 | PyAPI_FUNC(PyObject *) PyDictProxy_New(PyObject *); |
| 83 | PyAPI_FUNC(PyObject *) PyWrapper_New(PyObject *, PyObject *); |
Guido van Rossum | 29a62dd | 2001-08-23 21:40:38 +0000 | [diff] [blame] | 84 | |
| 85 | |
Mark Hammond | 91a681d | 2002-08-12 07:21:58 +0000 | [diff] [blame] | 86 | PyAPI_DATA(PyTypeObject) PyProperty_Type; |
Martin v. Löwis | 522cf1f | 2002-03-30 08:57:12 +0000 | [diff] [blame] | 87 | #ifdef __cplusplus |
| 88 | } |
| 89 | #endif |
| 90 | #endif /* !Py_DESCROBJECT_H */ |
| 91 | |