Guido van Rossum | 98bf58f | 2001-10-18 20:34:25 +0000 | [diff] [blame] | 1 | |
Benjamin Peterson | da3b5bf | 2010-08-09 15:53:58 +0000 | [diff] [blame] | 2 | /* Named tuple object interface */ |
Guido van Rossum | 98bf58f | 2001-10-18 20:34:25 +0000 | [diff] [blame] | 3 | |
| 4 | #ifndef Py_STRUCTSEQ_H |
| 5 | #define Py_STRUCTSEQ_H |
| 6 | #ifdef __cplusplus |
| 7 | extern "C" { |
| 8 | #endif |
Fred Drake | 330f72c | 2002-10-17 19:48:27 +0000 | [diff] [blame] | 9 | |
Guido van Rossum | 98bf58f | 2001-10-18 20:34:25 +0000 | [diff] [blame] | 10 | typedef struct PyStructSequence_Field { |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 11 | char *name; |
| 12 | char *doc; |
Guido van Rossum | 98bf58f | 2001-10-18 20:34:25 +0000 | [diff] [blame] | 13 | } PyStructSequence_Field; |
| 14 | |
| 15 | typedef struct PyStructSequence_Desc { |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 16 | char *name; |
| 17 | char *doc; |
| 18 | struct PyStructSequence_Field *fields; |
| 19 | int n_in_sequence; |
Guido van Rossum | 98bf58f | 2001-10-18 20:34:25 +0000 | [diff] [blame] | 20 | } PyStructSequence_Desc; |
| 21 | |
Martin v. Löwis | f607bda | 2002-10-16 18:27:39 +0000 | [diff] [blame] | 22 | extern char* PyStructSequence_UnnamedField; |
| 23 | |
Martin v. Löwis | 4d0d471 | 2010-12-03 20:14:31 +0000 | [diff] [blame] | 24 | #ifndef Py_LIMITED_API |
Fred Drake | 330f72c | 2002-10-17 19:48:27 +0000 | [diff] [blame] | 25 | PyAPI_FUNC(void) PyStructSequence_InitType(PyTypeObject *type, |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 26 | PyStructSequence_Desc *desc); |
Martin v. Löwis | 4d0d471 | 2010-12-03 20:14:31 +0000 | [diff] [blame] | 27 | #endif |
| 28 | PyAPI_FUNC(PyTypeObject*) PyStructSequence_NewType(PyStructSequence_Desc *desc); |
Fred Drake | 330f72c | 2002-10-17 19:48:27 +0000 | [diff] [blame] | 29 | |
Mark Hammond | 91a681d | 2002-08-12 07:21:58 +0000 | [diff] [blame] | 30 | PyAPI_FUNC(PyObject *) PyStructSequence_New(PyTypeObject* type); |
Guido van Rossum | 98bf58f | 2001-10-18 20:34:25 +0000 | [diff] [blame] | 31 | |
Martin v. Löwis | 4d0d471 | 2010-12-03 20:14:31 +0000 | [diff] [blame] | 32 | #ifndef Py_LIMITED_API |
Benjamin Peterson | ccabcd4 | 2010-07-07 20:54:01 +0000 | [diff] [blame] | 33 | typedef PyTupleObject PyStructSequence; |
Guido van Rossum | 98bf58f | 2001-10-18 20:34:25 +0000 | [diff] [blame] | 34 | |
| 35 | /* Macro, *only* to be used to fill in brand new objects */ |
Benjamin Peterson | ccabcd4 | 2010-07-07 20:54:01 +0000 | [diff] [blame] | 36 | #define PyStructSequence_SET_ITEM(op, i, v) PyTuple_SET_ITEM(op, i, v) |
Guido van Rossum | 98bf58f | 2001-10-18 20:34:25 +0000 | [diff] [blame] | 37 | |
Benjamin Peterson | ccabcd4 | 2010-07-07 20:54:01 +0000 | [diff] [blame] | 38 | #define PyStructSequence_GET_ITEM(op, i) PyTuple_GET_ITEM(op, i) |
Martin v. Löwis | 4d0d471 | 2010-12-03 20:14:31 +0000 | [diff] [blame] | 39 | #endif |
Skip Montanaro | 41cfce9 | 2007-08-24 21:11:00 +0000 | [diff] [blame] | 40 | |
Martin v. Löwis | 4d0d471 | 2010-12-03 20:14:31 +0000 | [diff] [blame] | 41 | PyAPI_FUNC(void) PyStructSequence_SetItem(PyObject*, Py_ssize_t, PyObject*); |
| 42 | PyAPI_FUNC(PyObject*) PyStructSequence_GetItem(PyObject*, Py_ssize_t); |
Skip Montanaro | 41cfce9 | 2007-08-24 21:11:00 +0000 | [diff] [blame] | 43 | |
Guido van Rossum | 98bf58f | 2001-10-18 20:34:25 +0000 | [diff] [blame] | 44 | #ifdef __cplusplus |
| 45 | } |
| 46 | #endif |
| 47 | #endif /* !Py_STRUCTSEQ_H */ |