annotate Include/listobject.h @ 27998:e27f58a50737 legacy-trunk

SF bug #690377: Dud footnote reference in distutils docs
author Raymond Hettinger <python@rcn.com>
date Fri, 21 Feb 2003 02:47:09 +0000
parents c1eb668525e1
children f30aaac00195
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
145
853b736a6a9e Added copyright notice.
Guido van Rossum <guido@python.org>
parents: 86
diff changeset
1
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2 /* List object interface */
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
3
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
4 /*
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
5 Another generally useful object type is an list of object pointers.
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
6 This is a mutable type: the list items can be changed, and items can be
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
7 added or removed. Out-of-range indices or non-list objects are ignored.
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
8
2129
05360cd616ae The great renaming, phase two: all header files have been updated to
Guido van Rossum <guido@python.org>
parents: 2058
diff changeset
9 *** WARNING *** PyList_SetItem does not increment the new item's reference
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
10 count, but does decrement the reference count of the item it replaces,
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
11 if not nil. It does *decrement* the reference count if it is *not*
2129
05360cd616ae The great renaming, phase two: all header files have been updated to
Guido van Rossum <guido@python.org>
parents: 2058
diff changeset
12 inserted in the list. Similarly, PyList_GetItem does not increment the
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
13 returned item's reference count.
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
14 */
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
15
13444
5709ddba423c ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
16 #ifndef Py_LISTOBJECT_H
5709ddba423c ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
17 #define Py_LISTOBJECT_H
5709ddba423c ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
18 #ifdef __cplusplus
5709ddba423c ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
19 extern "C" {
5709ddba423c ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
20 #endif
5709ddba423c ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
21
86
a6934380c6e7 "Compiling" version
Guido van Rossum <guido@python.org>
parents: 48
diff changeset
22 typedef struct {
13444
5709ddba423c ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
23 PyObject_VAR_HEAD
5709ddba423c ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
24 PyObject **ob_item;
2129
05360cd616ae The great renaming, phase two: all header files have been updated to
Guido van Rossum <guido@python.org>
parents: 2058
diff changeset
25 } PyListObject;
86
a6934380c6e7 "Compiling" version
Guido van Rossum <guido@python.org>
parents: 48
diff changeset
26
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 20275
diff changeset
27 PyAPI_DATA(PyTypeObject) PyList_Type;
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
28
18933
09df3254b49d Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents: 14375
diff changeset
29 #define PyList_Check(op) PyObject_TypeCheck(op, &PyList_Type)
20275
167e7f98b51f Introduced the oddly-missing PyList_CheckExact(), and used it to replace
Tim Peters <tim.peters@gmail.com>
parents: 18933
diff changeset
30 #define PyList_CheckExact(op) ((op)->ob_type == &PyList_Type)
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
31
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 20275
diff changeset
32 PyAPI_FUNC(PyObject *) PyList_New(int size);
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 20275
diff changeset
33 PyAPI_FUNC(int) PyList_Size(PyObject *);
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 20275
diff changeset
34 PyAPI_FUNC(PyObject *) PyList_GetItem(PyObject *, int);
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 20275
diff changeset
35 PyAPI_FUNC(int) PyList_SetItem(PyObject *, int, PyObject *);
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 20275
diff changeset
36 PyAPI_FUNC(int) PyList_Insert(PyObject *, int, PyObject *);
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 20275
diff changeset
37 PyAPI_FUNC(int) PyList_Append(PyObject *, PyObject *);
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 20275
diff changeset
38 PyAPI_FUNC(PyObject *) PyList_GetSlice(PyObject *, int, int);
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 20275
diff changeset
39 PyAPI_FUNC(int) PyList_SetSlice(PyObject *, int, int, PyObject *);
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 20275
diff changeset
40 PyAPI_FUNC(int) PyList_Sort(PyObject *);
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 20275
diff changeset
41 PyAPI_FUNC(int) PyList_Reverse(PyObject *);
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 20275
diff changeset
42 PyAPI_FUNC(PyObject *) PyList_AsTuple(PyObject *);
86
a6934380c6e7 "Compiling" version
Guido van Rossum <guido@python.org>
parents: 48
diff changeset
43
a6934380c6e7 "Compiling" version
Guido van Rossum <guido@python.org>
parents: 48
diff changeset
44 /* Macro, trading safety for speed */
4896
50abb0850740 added PyList_GET_SIZE macro
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
45 #define PyList_GET_ITEM(op, i) (((PyListObject *)(op))->ob_item[i])
8138
9d0310143600 Fred's right -- we need PyList_SET_ITEM().
Guido van Rossum <guido@python.org>
parents: 4896
diff changeset
46 #define PyList_SET_ITEM(op, i, v) (((PyListObject *)(op))->ob_item[i] = (v))
4896
50abb0850740 added PyList_GET_SIZE macro
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
47 #define PyList_GET_SIZE(op) (((PyListObject *)(op))->ob_size)
1329
519c25039c6a * Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents: 1313
diff changeset
48
519c25039c6a * Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents: 1313
diff changeset
49 #ifdef __cplusplus
519c25039c6a * Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents: 1313
diff changeset
50 }
519c25039c6a * Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents: 1313
diff changeset
51 #endif
519c25039c6a * Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents: 1313
diff changeset
52 #endif /* !Py_LISTOBJECT_H */