structseq.h 1.34 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
    const char *name;
    const char *doc;
13 14 15
} PyStructSequence_Field;

typedef struct PyStructSequence_Desc {
16 17
    const char *name;
    const char *doc;
18 19
    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
PyAPI_FUNC(int) PyStructSequence_InitType2(PyTypeObject *type,
                                           PyStructSequence_Desc *desc);
29 30
#endif
PyAPI_FUNC(PyTypeObject*) PyStructSequence_NewType(PyStructSequence_Desc *desc);
31

32
PyAPI_FUNC(PyObject *) PyStructSequence_New(PyTypeObject* type);
33

34
#ifndef Py_LIMITED_API
35
typedef PyTupleObject PyStructSequence;
36 37

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

40
#define PyStructSequence_GET_ITEM(op, i) PyTuple_GET_ITEM(op, i)
41
#endif
42

43 44
PyAPI_FUNC(void) PyStructSequence_SetItem(PyObject*, Py_ssize_t, PyObject*);
PyAPI_FUNC(PyObject*) PyStructSequence_GetItem(PyObject*, Py_ssize_t);
45

46 47 48 49
#ifdef __cplusplus
}
#endif
#endif /* !Py_STRUCTSEQ_H */