structseq.h 1.19 KB
Newer Older
1

Benjamin Peterson's avatar
Benjamin Peterson committed
2
/* Named tuple object interface */
3 4 5 6 7 8

#ifndef Py_STRUCTSEQ_H
#define Py_STRUCTSEQ_H
#ifdef __cplusplus
extern "C" {
#endif
9

10
typedef struct PyStructSequence_Field {
11 12
    char *name;
    char *doc;
13 14 15
} PyStructSequence_Field;

typedef struct PyStructSequence_Desc {
16 17 18 19
    char *name;
    char *doc;
    struct PyStructSequence_Field *fields;
    int n_in_sequence;
20 21
} PyStructSequence_Desc;

22 23
extern char* PyStructSequence_UnnamedField;

24
#ifndef Py_LIMITED_API
25
PyAPI_FUNC(void) PyStructSequence_InitType(PyTypeObject *type,
26
                                           PyStructSequence_Desc *desc);
27 28
#endif
PyAPI_FUNC(PyTypeObject*) PyStructSequence_NewType(PyStructSequence_Desc *desc);
29

30
PyAPI_FUNC(PyObject *) PyStructSequence_New(PyTypeObject* type);
31

32
#ifndef Py_LIMITED_API
33
typedef PyTupleObject PyStructSequence;
34 35

/* Macro, *only* to be used to fill in brand new objects */
36
#define PyStructSequence_SET_ITEM(op, i, v) PyTuple_SET_ITEM(op, i, v)
37

38
#define PyStructSequence_GET_ITEM(op, i) PyTuple_GET_ITEM(op, i)
39
#endif
40

41 42
PyAPI_FUNC(void) PyStructSequence_SetItem(PyObject*, Py_ssize_t, PyObject*);
PyAPI_FUNC(PyObject*) PyStructSequence_GetItem(PyObject*, Py_ssize_t);
43

44 45 46 47
#ifdef __cplusplus
}
#endif
#endif /* !Py_STRUCTSEQ_H */