2020-02-07 16:20:22 +08:00
|
|
|
/* List object interface
|
1991-02-19 20:39:46 +08:00
|
|
|
|
2020-02-07 16:20:22 +08:00
|
|
|
Another generally useful object type is a list of object pointers.
|
|
|
|
This is a mutable type: the list items can be changed, and items can be
|
|
|
|
added or removed. Out-of-range indices or non-list objects are ignored.
|
1990-10-14 20:07:46 +08:00
|
|
|
|
2020-02-07 16:20:22 +08:00
|
|
|
WARNING: PyList_SetItem does not increment the new item's reference count,
|
|
|
|
but does decrement the reference count of the item it replaces, if not nil.
|
|
|
|
It does *decrement* the reference count if it is *not* inserted in the list.
|
|
|
|
Similarly, PyList_GetItem does not increment the returned item's reference
|
|
|
|
count.
|
1990-10-14 20:07:46 +08:00
|
|
|
*/
|
|
|
|
|
2000-07-09 08:20:36 +08:00
|
|
|
#ifndef Py_LISTOBJECT_H
|
|
|
|
#define Py_LISTOBJECT_H
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2002-08-12 15:21:58 +08:00
|
|
|
PyAPI_DATA(PyTypeObject) PyList_Type;
|
2007-11-30 06:35:39 +08:00
|
|
|
PyAPI_DATA(PyTypeObject) PyListIter_Type;
|
|
|
|
PyAPI_DATA(PyTypeObject) PyListRevIter_Type;
|
1990-10-14 20:07:46 +08:00
|
|
|
|
2007-02-26 04:39:11 +08:00
|
|
|
#define PyList_Check(op) \
|
2014-05-27 06:12:28 +08:00
|
|
|
PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_LIST_SUBCLASS)
|
2022-06-16 19:49:43 +08:00
|
|
|
#define PyList_CheckExact(op) Py_IS_TYPE((op), &PyList_Type)
|
1990-10-14 20:07:46 +08:00
|
|
|
|
2006-02-16 01:27:45 +08:00
|
|
|
PyAPI_FUNC(PyObject *) PyList_New(Py_ssize_t size);
|
|
|
|
PyAPI_FUNC(Py_ssize_t) PyList_Size(PyObject *);
|
2020-02-07 16:20:22 +08:00
|
|
|
|
2006-02-16 01:27:45 +08:00
|
|
|
PyAPI_FUNC(PyObject *) PyList_GetItem(PyObject *, Py_ssize_t);
|
|
|
|
PyAPI_FUNC(int) PyList_SetItem(PyObject *, Py_ssize_t, PyObject *);
|
|
|
|
PyAPI_FUNC(int) PyList_Insert(PyObject *, Py_ssize_t, PyObject *);
|
2002-08-12 15:21:58 +08:00
|
|
|
PyAPI_FUNC(int) PyList_Append(PyObject *, PyObject *);
|
2020-02-07 16:20:22 +08:00
|
|
|
|
2006-02-16 01:27:45 +08:00
|
|
|
PyAPI_FUNC(PyObject *) PyList_GetSlice(PyObject *, Py_ssize_t, Py_ssize_t);
|
|
|
|
PyAPI_FUNC(int) PyList_SetSlice(PyObject *, Py_ssize_t, Py_ssize_t, PyObject *);
|
2020-02-07 16:20:22 +08:00
|
|
|
|
2002-08-12 15:21:58 +08:00
|
|
|
PyAPI_FUNC(int) PyList_Sort(PyObject *);
|
|
|
|
PyAPI_FUNC(int) PyList_Reverse(PyObject *);
|
|
|
|
PyAPI_FUNC(PyObject *) PyList_AsTuple(PyObject *);
|
1990-12-20 23:06:42 +08:00
|
|
|
|
2010-12-04 04:14:31 +08:00
|
|
|
#ifndef Py_LIMITED_API
|
2020-02-07 16:20:22 +08:00
|
|
|
# define Py_CPYTHON_LISTOBJECT_H
|
2021-10-15 07:50:04 +08:00
|
|
|
# include "cpython/listobject.h"
|
2020-02-07 16:20:22 +08:00
|
|
|
# undef Py_CPYTHON_LISTOBJECT_H
|
2010-12-04 04:14:31 +08:00
|
|
|
#endif
|
1993-07-28 17:05:47 +08:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif /* !Py_LISTOBJECT_H */
|