blob: 46a003135dd9a7772164e88065f5f34bd4040d74 [file] [log] [blame]
Guido van Rossum85a5fbb1990-10-14 12:07:46 +00001/* Tuple object interface */
2
3/*
4123456789-123456789-123456789-123456789-123456789-123456789-123456789-12
5
6Another generally useful object type is an tuple of object pointers.
7This is a mutable type: the tuple items can be changed (but not their
8number). Out-of-range indices or non-tuple objects are ignored.
9
10*** WARNING *** settupleitem does not increment the new item's reference
11count, but does decrement the reference count of the item it replaces,
12if not nil. It does *decrement* the reference count if it is *not*
13inserted in the tuple. Similarly, gettupleitem does not increment the
14returned item's reference count.
15*/
16
Guido van Rossum3f5da241990-12-20 15:06:42 +000017typedef struct {
18 OB_VARHEAD
19 object *ob_item[1];
20} tupleobject;
21
Guido van Rossum85a5fbb1990-10-14 12:07:46 +000022extern typeobject Tupletype;
23
24#define is_tupleobject(op) ((op)->ob_type == &Tupletype)
25
26extern object *newtupleobject PROTO((int size));
27extern int gettuplesize PROTO((object *));
28extern object *gettupleitem PROTO((object *, int));
29extern int settupleitem PROTO((object *, int, object *));
Guido van Rossum3f5da241990-12-20 15:06:42 +000030
31/* Macro, trading safety for speed */
32#define GETTUPLEITEM(op, i) ((op)->ob_item[i])