blob: 30c52aca9bac0af030c7eb245116ab844983d179 [file] [log] [blame]
Guido van Rossum98bf58f2001-10-18 20:34:25 +00001
Benjamin Petersonda3b5bf2010-08-09 15:53:58 +00002/* Named tuple object interface */
Guido van Rossum98bf58f2001-10-18 20:34:25 +00003
4#ifndef Py_STRUCTSEQ_H
5#define Py_STRUCTSEQ_H
6#ifdef __cplusplus
7extern "C" {
8#endif
Fred Drake330f72c2002-10-17 19:48:27 +00009
Guido van Rossum98bf58f2001-10-18 20:34:25 +000010typedef struct PyStructSequence_Field {
Antoine Pitrouf95a1b32010-05-09 15:52:27 +000011 char *name;
12 char *doc;
Guido van Rossum98bf58f2001-10-18 20:34:25 +000013} PyStructSequence_Field;
14
15typedef struct PyStructSequence_Desc {
Antoine Pitrouf95a1b32010-05-09 15:52:27 +000016 char *name;
17 char *doc;
18 struct PyStructSequence_Field *fields;
19 int n_in_sequence;
Guido van Rossum98bf58f2001-10-18 20:34:25 +000020} PyStructSequence_Desc;
21
Martin v. Löwisf607bda2002-10-16 18:27:39 +000022extern char* PyStructSequence_UnnamedField;
23
Martin v. Löwis4d0d4712010-12-03 20:14:31 +000024#ifndef Py_LIMITED_API
Fred Drake330f72c2002-10-17 19:48:27 +000025PyAPI_FUNC(void) PyStructSequence_InitType(PyTypeObject *type,
Antoine Pitrouf95a1b32010-05-09 15:52:27 +000026 PyStructSequence_Desc *desc);
Martin v. Löwis4d0d4712010-12-03 20:14:31 +000027#endif
28PyAPI_FUNC(PyTypeObject*) PyStructSequence_NewType(PyStructSequence_Desc *desc);
Fred Drake330f72c2002-10-17 19:48:27 +000029
Mark Hammond91a681d2002-08-12 07:21:58 +000030PyAPI_FUNC(PyObject *) PyStructSequence_New(PyTypeObject* type);
Guido van Rossum98bf58f2001-10-18 20:34:25 +000031
Martin v. Löwis4d0d4712010-12-03 20:14:31 +000032#ifndef Py_LIMITED_API
Benjamin Petersonccabcd42010-07-07 20:54:01 +000033typedef PyTupleObject PyStructSequence;
Guido van Rossum98bf58f2001-10-18 20:34:25 +000034
35/* Macro, *only* to be used to fill in brand new objects */
Benjamin Petersonccabcd42010-07-07 20:54:01 +000036#define PyStructSequence_SET_ITEM(op, i, v) PyTuple_SET_ITEM(op, i, v)
Guido van Rossum98bf58f2001-10-18 20:34:25 +000037
Benjamin Petersonccabcd42010-07-07 20:54:01 +000038#define PyStructSequence_GET_ITEM(op, i) PyTuple_GET_ITEM(op, i)
Martin v. Löwis4d0d4712010-12-03 20:14:31 +000039#endif
Skip Montanaro41cfce92007-08-24 21:11:00 +000040
Martin v. Löwis4d0d4712010-12-03 20:14:31 +000041PyAPI_FUNC(void) PyStructSequence_SetItem(PyObject*, Py_ssize_t, PyObject*);
42PyAPI_FUNC(PyObject*) PyStructSequence_GetItem(PyObject*, Py_ssize_t);
Skip Montanaro41cfce92007-08-24 21:11:00 +000043
Guido van Rossum98bf58f2001-10-18 20:34:25 +000044#ifdef __cplusplus
45}
46#endif
47#endif /* !Py_STRUCTSEQ_H */