blob: 0b8d387937e559f8658597f5d7092e92047f51fa [file] [log] [blame]
Guido van Rossum98bf58f2001-10-18 20:34:25 +00001
2/* Tuple object interface */
3
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 Pitrou7f14f0d2010-05-09 16:14:21 +000011 char *name;
12 char *doc;
Guido van Rossum98bf58f2001-10-18 20:34:25 +000013} PyStructSequence_Field;
14
15typedef struct PyStructSequence_Desc {
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +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
Fred Drake330f72c2002-10-17 19:48:27 +000024PyAPI_FUNC(void) PyStructSequence_InitType(PyTypeObject *type,
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +000025 PyStructSequence_Desc *desc);
Fred Drake330f72c2002-10-17 19:48:27 +000026
Mark Hammond91a681d2002-08-12 07:21:58 +000027PyAPI_FUNC(PyObject *) PyStructSequence_New(PyTypeObject* type);
Guido van Rossum98bf58f2001-10-18 20:34:25 +000028
29typedef struct {
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +000030 PyObject_VAR_HEAD
31 PyObject *ob_item[1];
Guido van Rossum98bf58f2001-10-18 20:34:25 +000032} PyStructSequence;
33
34/* Macro, *only* to be used to fill in brand new objects */
35#define PyStructSequence_SET_ITEM(op, i, v) \
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +000036 (((PyStructSequence *)(op))->ob_item[i] = v)
Guido van Rossum98bf58f2001-10-18 20:34:25 +000037
Skip Montanaro41cfce92007-08-24 21:11:00 +000038#define PyStructSequence_GET_ITEM(op, i) \
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +000039 (((PyStructSequence *)(op))->ob_item[i])
Skip Montanaro41cfce92007-08-24 21:11:00 +000040
41
Guido van Rossum98bf58f2001-10-18 20:34:25 +000042#ifdef __cplusplus
43}
44#endif
45#endif /* !Py_STRUCTSEQ_H */