This commit was manufactured by cvs2svn to create tag 'r23a1-fork'.
[python/dscho.git] / Include / tupleobject.h
blob58bf8968e07e43a4a42b0f9fe5b6bf0454bb57c4
2 /* Tuple object interface */
4 #ifndef Py_TUPLEOBJECT_H
5 #define Py_TUPLEOBJECT_H
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
11 Another generally useful object type is an tuple of object pointers.
12 This is a mutable type: the tuple items can be changed (but not their
13 number). Out-of-range indices or non-tuple objects are ignored.
15 *** WARNING *** PyTuple_SetItem does not increment the new item's reference
16 count, but does decrement the reference count of the item it replaces,
17 if not nil. It does *decrement* the reference count if it is *not*
18 inserted in the tuple. Similarly, PyTuple_GetItem does not increment the
19 returned item's reference count.
22 typedef struct {
23 PyObject_VAR_HEAD
24 PyObject *ob_item[1];
25 } PyTupleObject;
27 PyAPI_DATA(PyTypeObject) PyTuple_Type;
29 #define PyTuple_Check(op) PyObject_TypeCheck(op, &PyTuple_Type)
30 #define PyTuple_CheckExact(op) ((op)->ob_type == &PyTuple_Type)
32 PyAPI_FUNC(PyObject *) PyTuple_New(int size);
33 PyAPI_FUNC(int) PyTuple_Size(PyObject *);
34 PyAPI_FUNC(PyObject *) PyTuple_GetItem(PyObject *, int);
35 PyAPI_FUNC(int) PyTuple_SetItem(PyObject *, int, PyObject *);
36 PyAPI_FUNC(PyObject *) PyTuple_GetSlice(PyObject *, int, int);
37 PyAPI_FUNC(int) _PyTuple_Resize(PyObject **, int);
39 /* Macro, trading safety for speed */
40 #define PyTuple_GET_ITEM(op, i) (((PyTupleObject *)(op))->ob_item[i])
41 #define PyTuple_GET_SIZE(op) (((PyTupleObject *)(op))->ob_size)
43 /* Macro, *only* to be used to fill in brand new tuples */
44 #define PyTuple_SET_ITEM(op, i, v) (((PyTupleObject *)(op))->ob_item[i] = v)
46 #ifdef __cplusplus
48 #endif
49 #endif /* !Py_TUPLEOBJECT_H */