python-on-a-chip online compiler

Dependencies:   mbed TSI

/media/uploads/va009039/p14p-f446re.png

more info: python-on-a-chip

Committer:
va009039
Date:
Thu Apr 14 22:32:57 2016 +0000
Revision:
15:94ca5c8003e5
Parent:
0:65f1469d6bfb
update Nucleo-F401RE.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
va009039 0:65f1469d6bfb 1 /*
va009039 0:65f1469d6bfb 2 # This file is Copyright 2002 Dean Hall.
va009039 0:65f1469d6bfb 3 # This file is part of the PyMite VM.
va009039 0:65f1469d6bfb 4 # This file is licensed under the MIT License.
va009039 0:65f1469d6bfb 5 # See the LICENSE file for details.
va009039 0:65f1469d6bfb 6 */
va009039 0:65f1469d6bfb 7
va009039 0:65f1469d6bfb 8
va009039 0:65f1469d6bfb 9 #ifndef __LIST_H__
va009039 0:65f1469d6bfb 10 #define __LIST_H__
va009039 0:65f1469d6bfb 11
va009039 0:65f1469d6bfb 12 /**
va009039 0:65f1469d6bfb 13 * \file
va009039 0:65f1469d6bfb 14 * \brief List Object Type
va009039 0:65f1469d6bfb 15 *
va009039 0:65f1469d6bfb 16 * List object type header.
va009039 0:65f1469d6bfb 17 */
va009039 0:65f1469d6bfb 18
va009039 0:65f1469d6bfb 19 /**
va009039 0:65f1469d6bfb 20 * List obj
va009039 0:65f1469d6bfb 21 *
va009039 0:65f1469d6bfb 22 * Mutable ordered sequence of objects. Contains ptr to linked list of nodes.
va009039 0:65f1469d6bfb 23 */
va009039 0:65f1469d6bfb 24 typedef struct PmList_s
va009039 0:65f1469d6bfb 25 {
va009039 0:65f1469d6bfb 26 /** Object descriptor */
va009039 0:65f1469d6bfb 27 PmObjDesc_t od;
va009039 0:65f1469d6bfb 28
va009039 0:65f1469d6bfb 29 /** List length; number of objs linked */
va009039 0:65f1469d6bfb 30 uint16_t length;
va009039 0:65f1469d6bfb 31
va009039 0:65f1469d6bfb 32 /** Ptr to linked list of nodes */
va009039 0:65f1469d6bfb 33 pSeglist_t val;
va009039 0:65f1469d6bfb 34 } PmList_t,
va009039 0:65f1469d6bfb 35 *pPmList_t;
va009039 0:65f1469d6bfb 36
va009039 0:65f1469d6bfb 37
va009039 0:65f1469d6bfb 38 /**
va009039 0:65f1469d6bfb 39 * Allocates a new List object.
va009039 0:65f1469d6bfb 40 *
va009039 0:65f1469d6bfb 41 * If there is not enough memory to allocate the List,
va009039 0:65f1469d6bfb 42 * the return status will indicate an OutOfMemoryError
va009039 0:65f1469d6bfb 43 * that must be passed up to the interpreter.
va009039 0:65f1469d6bfb 44 * Otherwise, a ptr to the list is returned by reference
va009039 0:65f1469d6bfb 45 * and the return status is OK.
va009039 0:65f1469d6bfb 46 *
va009039 0:65f1469d6bfb 47 * @param r_pobj Return; addr of ptr to obj
va009039 0:65f1469d6bfb 48 * @return Return status
va009039 0:65f1469d6bfb 49 */
va009039 0:65f1469d6bfb 50 PmReturn_t list_new(pPmObj_t *r_pobj);
va009039 0:65f1469d6bfb 51
va009039 0:65f1469d6bfb 52 /**
va009039 0:65f1469d6bfb 53 * Gets the object in the list at the index.
va009039 0:65f1469d6bfb 54 *
va009039 0:65f1469d6bfb 55 * @param plist Ptr to list obj
va009039 0:65f1469d6bfb 56 * @param index Index into list
va009039 0:65f1469d6bfb 57 * @param r_pobj Return by reference; ptr to item
va009039 0:65f1469d6bfb 58 * @return Return status
va009039 0:65f1469d6bfb 59 */
va009039 0:65f1469d6bfb 60 PmReturn_t list_getItem(pPmObj_t plist, int16_t index, pPmObj_t *r_pobj);
va009039 0:65f1469d6bfb 61
va009039 0:65f1469d6bfb 62 /**
va009039 0:65f1469d6bfb 63 * Sets the item in the list at the index.
va009039 0:65f1469d6bfb 64 *
va009039 0:65f1469d6bfb 65 * @param plist Ptr to list
va009039 0:65f1469d6bfb 66 * @param index Index into list
va009039 0:65f1469d6bfb 67 * @param pobj Ptr to obj to put into list
va009039 0:65f1469d6bfb 68 * @return Return status
va009039 0:65f1469d6bfb 69 */
va009039 0:65f1469d6bfb 70 PmReturn_t list_setItem(pPmObj_t plist, int16_t index, pPmObj_t pobj);
va009039 0:65f1469d6bfb 71
va009039 0:65f1469d6bfb 72 /**
va009039 0:65f1469d6bfb 73 * Makes a copy of the given list.
va009039 0:65f1469d6bfb 74 *
va009039 0:65f1469d6bfb 75 * Allocate the necessary memory for root and nodes.
va009039 0:65f1469d6bfb 76 * Duplicate ptrs to objs.
va009039 0:65f1469d6bfb 77 *
va009039 0:65f1469d6bfb 78 * @param pobj Ptr to source list
va009039 0:65f1469d6bfb 79 * @param r_pobj Return; Addr of ptr to return obj
va009039 0:65f1469d6bfb 80 * @return Return status
va009039 0:65f1469d6bfb 81 */
va009039 0:65f1469d6bfb 82 PmReturn_t list_copy(pPmObj_t pobj, pPmObj_t *r_pobj);
va009039 0:65f1469d6bfb 83
va009039 0:65f1469d6bfb 84 /**
va009039 0:65f1469d6bfb 85 * Appends the given obj to the end of the given list.
va009039 0:65f1469d6bfb 86 *
va009039 0:65f1469d6bfb 87 * Allocate the memory for the node.
va009039 0:65f1469d6bfb 88 * Do not copy obj, just reuse ptr.
va009039 0:65f1469d6bfb 89 *
va009039 0:65f1469d6bfb 90 * @param plist Ptr to list
va009039 0:65f1469d6bfb 91 * @param pobj Ptr to item to append
va009039 0:65f1469d6bfb 92 * @return Return status
va009039 0:65f1469d6bfb 93 */
va009039 0:65f1469d6bfb 94 PmReturn_t list_append(pPmObj_t plist, pPmObj_t pobj);
va009039 0:65f1469d6bfb 95
va009039 0:65f1469d6bfb 96 /**
va009039 0:65f1469d6bfb 97 * Creates a new list with the contents of psrclist
va009039 0:65f1469d6bfb 98 * copied pint number of times.
va009039 0:65f1469d6bfb 99 * This implements the python code "[0,...] * N"
va009039 0:65f1469d6bfb 100 * where the list can be any list and N is an integer.
va009039 0:65f1469d6bfb 101 *
va009039 0:65f1469d6bfb 102 * @param psrclist The source list to replicate
va009039 0:65f1469d6bfb 103 * @param n The integer number of times to replicate it
va009039 0:65f1469d6bfb 104 * @param r_pnewlist Return; new list with its contents set.
va009039 0:65f1469d6bfb 105 * @return Return status
va009039 0:65f1469d6bfb 106 */
va009039 0:65f1469d6bfb 107 PmReturn_t list_replicate(pPmObj_t psrclist, int16_t n, pPmObj_t *r_pnewlist);
va009039 0:65f1469d6bfb 108
va009039 0:65f1469d6bfb 109 /**
va009039 0:65f1469d6bfb 110 * Inserts the object into the list at the desired index.
va009039 0:65f1469d6bfb 111 *
va009039 0:65f1469d6bfb 112 * @param plist Ptr to list obj
va009039 0:65f1469d6bfb 113 * @param pobj Ptr to obj to insert
va009039 0:65f1469d6bfb 114 * @param index Index of where to insert obj
va009039 0:65f1469d6bfb 115 * @return Return status
va009039 0:65f1469d6bfb 116 */
va009039 0:65f1469d6bfb 117 PmReturn_t list_insert(pPmObj_t plist, int16_t index, pPmObj_t pobj);
va009039 0:65f1469d6bfb 118
va009039 0:65f1469d6bfb 119 /**
va009039 0:65f1469d6bfb 120 * Removes a given object from the list.
va009039 0:65f1469d6bfb 121 *
va009039 0:65f1469d6bfb 122 * @param plist Ptr to list obj
va009039 0:65f1469d6bfb 123 * @param item Ptr to object to be removed
va009039 0:65f1469d6bfb 124 * @return Return status
va009039 0:65f1469d6bfb 125 */
va009039 0:65f1469d6bfb 126 PmReturn_t list_remove(pPmObj_t plist, pPmObj_t item);
va009039 0:65f1469d6bfb 127
va009039 0:65f1469d6bfb 128 /**
va009039 0:65f1469d6bfb 129 * Finds the first index of the item that matches pitem.
va009039 0:65f1469d6bfb 130 * Returns an ValueError Exception if the item is not found.
va009039 0:65f1469d6bfb 131 *
va009039 0:65f1469d6bfb 132 * @param plist Ptr to list obj
va009039 0:65f1469d6bfb 133 * @param pitem Ptr to object to be removed
va009039 0:65f1469d6bfb 134 * @param r_index Return by reference; ptr to index (C uint16)
va009039 0:65f1469d6bfb 135 * @return Return status
va009039 0:65f1469d6bfb 136 */
va009039 0:65f1469d6bfb 137 PmReturn_t list_index(pPmObj_t plist, pPmObj_t pitem, uint16_t *r_index);
va009039 0:65f1469d6bfb 138
va009039 0:65f1469d6bfb 139 /**
va009039 0:65f1469d6bfb 140 * Removes the item at the given index.
va009039 0:65f1469d6bfb 141 * Raises a TypeError if the first argument is not a list.
va009039 0:65f1469d6bfb 142 * Raises an IndexError if the index is out of bounds.
va009039 0:65f1469d6bfb 143 *
va009039 0:65f1469d6bfb 144 * @param plist Ptr to list obj
va009039 0:65f1469d6bfb 145 * @param index Index of item to remove
va009039 0:65f1469d6bfb 146 * @return Return status
va009039 0:65f1469d6bfb 147 */
va009039 0:65f1469d6bfb 148 PmReturn_t list_delItem(pPmObj_t plist, int16_t index);
va009039 0:65f1469d6bfb 149
va009039 0:65f1469d6bfb 150 #ifdef HAVE_PRINT
va009039 0:65f1469d6bfb 151 /**
va009039 0:65f1469d6bfb 152 * Prints out a list. Uses obj_print() to print elements.
va009039 0:65f1469d6bfb 153 *
va009039 0:65f1469d6bfb 154 * @param pobj Object to print.
va009039 0:65f1469d6bfb 155 * @return Return status
va009039 0:65f1469d6bfb 156 */
va009039 0:65f1469d6bfb 157 PmReturn_t list_print(pPmObj_t pobj);
va009039 0:65f1469d6bfb 158 #endif /* HAVE_PRINT */
va009039 0:65f1469d6bfb 159
va009039 0:65f1469d6bfb 160 /**
va009039 0:65f1469d6bfb 161 * Removes all items from the list and zeroes the length.
va009039 0:65f1469d6bfb 162 *
va009039 0:65f1469d6bfb 163 * @param plist List to clear
va009039 0:65f1469d6bfb 164 * @return Return status
va009039 0:65f1469d6bfb 165 */
va009039 0:65f1469d6bfb 166 PmReturn_t list_clear(pPmObj_t plist);
va009039 0:65f1469d6bfb 167
va009039 0:65f1469d6bfb 168 #endif /* __LIST_H__ */