Last set of CW Pro 5 projects (probably)
[python/dscho.git] / Include / tupleobject.h
blobacfac8b2e96f33b0e2170c08339f10baaae86314
1 /***********************************************************
2 Copyright (c) 2000, BeOpen.com.
3 Copyright (c) 1995-2000, Corporation for National Research Initiatives.
4 Copyright (c) 1990-1995, Stichting Mathematisch Centrum.
5 All rights reserved.
7 See the file "Misc/COPYRIGHT" for information on usage and
8 redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
9 ******************************************************************/
11 /* Tuple object interface */
13 #ifndef Py_TUPLEOBJECT_H
14 #define Py_TUPLEOBJECT_H
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
20 Another generally useful object type is an tuple of object pointers.
21 This is a mutable type: the tuple items can be changed (but not their
22 number). Out-of-range indices or non-tuple objects are ignored.
24 *** WARNING *** PyTuple_SetItem does not increment the new item's reference
25 count, but does decrement the reference count of the item it replaces,
26 if not nil. It does *decrement* the reference count if it is *not*
27 inserted in the tuple. Similarly, PyTuple_GetItem does not increment the
28 returned item's reference count.
31 typedef struct {
32 PyObject_VAR_HEAD
33 PyObject *ob_item[1];
34 } PyTupleObject;
36 extern DL_IMPORT(PyTypeObject) PyTuple_Type;
38 #define PyTuple_Check(op) ((op)->ob_type == &PyTuple_Type)
40 extern DL_IMPORT(PyObject *) PyTuple_New(int size);
41 extern DL_IMPORT(int) PyTuple_Size(PyObject *);
42 extern DL_IMPORT(PyObject *) PyTuple_GetItem(PyObject *, int);
43 extern DL_IMPORT(int) PyTuple_SetItem(PyObject *, int, PyObject *);
44 extern DL_IMPORT(PyObject *) PyTuple_GetSlice(PyObject *, int, int);
45 extern DL_IMPORT(int) _PyTuple_Resize(PyObject **, int, int);
47 /* Macro, trading safety for speed */
48 #define PyTuple_GET_ITEM(op, i) (((PyTupleObject *)(op))->ob_item[i])
49 #define PyTuple_GET_SIZE(op) (((PyTupleObject *)(op))->ob_size)
51 /* Macro, *only* to be used to fill in brand new tuples */
52 #define PyTuple_SET_ITEM(op, i, v) (((PyTupleObject *)(op))->ob_item[i] = v)
54 #ifdef __cplusplus
56 #endif
57 #endif /* !Py_TUPLEOBJECT_H */