symbian-qemu-0.9.1-12/python-win32-2.6.1/include/listobject.h
changeset 1 2fb8b9db1c86
equal deleted inserted replaced
0:ffa851df0825 1:2fb8b9db1c86
       
     1 
       
     2 /* List object interface */
       
     3 
       
     4 /*
       
     5 Another generally useful object type is an list of object pointers.
       
     6 This is a mutable type: the list items can be changed, and items can be
       
     7 added or removed.  Out-of-range indices or non-list objects are ignored.
       
     8 
       
     9 *** WARNING *** PyList_SetItem does not increment the new item's reference
       
    10 count, but does decrement the reference count of the item it replaces,
       
    11 if not nil.  It does *decrement* the reference count if it is *not*
       
    12 inserted in the list.  Similarly, PyList_GetItem does not increment the
       
    13 returned item's reference count.
       
    14 */
       
    15 
       
    16 #ifndef Py_LISTOBJECT_H
       
    17 #define Py_LISTOBJECT_H
       
    18 #ifdef __cplusplus
       
    19 extern "C" {
       
    20 #endif
       
    21 
       
    22 typedef struct {
       
    23     PyObject_VAR_HEAD
       
    24     /* Vector of pointers to list elements.  list[0] is ob_item[0], etc. */
       
    25     PyObject **ob_item;
       
    26 
       
    27     /* ob_item contains space for 'allocated' elements.  The number
       
    28      * currently in use is ob_size.
       
    29      * Invariants:
       
    30      *     0 <= ob_size <= allocated
       
    31      *     len(list) == ob_size
       
    32      *     ob_item == NULL implies ob_size == allocated == 0
       
    33      * list.sort() temporarily sets allocated to -1 to detect mutations.
       
    34      *
       
    35      * Items must normally not be NULL, except during construction when
       
    36      * the list is not yet visible outside the function that builds it.
       
    37      */
       
    38     Py_ssize_t allocated;
       
    39 } PyListObject;
       
    40 
       
    41 PyAPI_DATA(PyTypeObject) PyList_Type;
       
    42 
       
    43 #define PyList_Check(op) \
       
    44 		PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_LIST_SUBCLASS)
       
    45 #define PyList_CheckExact(op) (Py_TYPE(op) == &PyList_Type)
       
    46 
       
    47 PyAPI_FUNC(PyObject *) PyList_New(Py_ssize_t size);
       
    48 PyAPI_FUNC(Py_ssize_t) PyList_Size(PyObject *);
       
    49 PyAPI_FUNC(PyObject *) PyList_GetItem(PyObject *, Py_ssize_t);
       
    50 PyAPI_FUNC(int) PyList_SetItem(PyObject *, Py_ssize_t, PyObject *);
       
    51 PyAPI_FUNC(int) PyList_Insert(PyObject *, Py_ssize_t, PyObject *);
       
    52 PyAPI_FUNC(int) PyList_Append(PyObject *, PyObject *);
       
    53 PyAPI_FUNC(PyObject *) PyList_GetSlice(PyObject *, Py_ssize_t, Py_ssize_t);
       
    54 PyAPI_FUNC(int) PyList_SetSlice(PyObject *, Py_ssize_t, Py_ssize_t, PyObject *);
       
    55 PyAPI_FUNC(int) PyList_Sort(PyObject *);
       
    56 PyAPI_FUNC(int) PyList_Reverse(PyObject *);
       
    57 PyAPI_FUNC(PyObject *) PyList_AsTuple(PyObject *);
       
    58 PyAPI_FUNC(PyObject *) _PyList_Extend(PyListObject *, PyObject *);
       
    59 
       
    60 /* Macro, trading safety for speed */
       
    61 #define PyList_GET_ITEM(op, i) (((PyListObject *)(op))->ob_item[i])
       
    62 #define PyList_SET_ITEM(op, i, v) (((PyListObject *)(op))->ob_item[i] = (v))
       
    63 #define PyList_GET_SIZE(op)    Py_SIZE(op)
       
    64 
       
    65 #ifdef __cplusplus
       
    66 }
       
    67 #endif
       
    68 #endif /* !Py_LISTOBJECT_H */