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 __DICT_H__
va009039 0:65f1469d6bfb 10 #define __DICT_H__
va009039 0:65f1469d6bfb 11
va009039 0:65f1469d6bfb 12
va009039 0:65f1469d6bfb 13 /**
va009039 0:65f1469d6bfb 14 * \file
va009039 0:65f1469d6bfb 15 * \brief Dict Object Type
va009039 0:65f1469d6bfb 16 *
va009039 0:65f1469d6bfb 17 * Dict object type header.
va009039 0:65f1469d6bfb 18 */
va009039 0:65f1469d6bfb 19
va009039 0:65f1469d6bfb 20
va009039 0:65f1469d6bfb 21 /**
va009039 0:65f1469d6bfb 22 * Dict
va009039 0:65f1469d6bfb 23 *
va009039 0:65f1469d6bfb 24 * Contains ptr to two seglists,
va009039 0:65f1469d6bfb 25 * one for keys, the other for values;
va009039 0:65f1469d6bfb 26 * and a length, the number of key/value pairs.
va009039 0:65f1469d6bfb 27 */
va009039 0:65f1469d6bfb 28 typedef struct PmDict_s
va009039 0:65f1469d6bfb 29 {
va009039 0:65f1469d6bfb 30 /** object descriptor */
va009039 0:65f1469d6bfb 31 PmObjDesc_t od;
va009039 0:65f1469d6bfb 32 /** number of key,value pairs in the dict */
va009039 0:65f1469d6bfb 33 uint16_t length;
va009039 0:65f1469d6bfb 34 /** ptr to seglist containing keys */
va009039 0:65f1469d6bfb 35 pSeglist_t d_keys;
va009039 0:65f1469d6bfb 36 /** ptr to seglist containing values */
va009039 0:65f1469d6bfb 37 pSeglist_t d_vals;
va009039 0:65f1469d6bfb 38 } PmDict_t,
va009039 0:65f1469d6bfb 39 *pPmDict_t;
va009039 0:65f1469d6bfb 40
va009039 0:65f1469d6bfb 41
va009039 0:65f1469d6bfb 42 /**
va009039 0:65f1469d6bfb 43 * Clears the contents of a dict.
va009039 0:65f1469d6bfb 44 * after this operation, the dict should in the same state
va009039 0:65f1469d6bfb 45 * as if it were just created using dict_new().
va009039 0:65f1469d6bfb 46 *
va009039 0:65f1469d6bfb 47 * @param pdict ptr to dict to clear.
va009039 0:65f1469d6bfb 48 * @return nothing
va009039 0:65f1469d6bfb 49 */
va009039 0:65f1469d6bfb 50 PmReturn_t dict_clear(pPmObj_t pdict);
va009039 0:65f1469d6bfb 51
va009039 0:65f1469d6bfb 52 /**
va009039 0:65f1469d6bfb 53 * Gets the value in the dict using the given key.
va009039 0:65f1469d6bfb 54 *
va009039 0:65f1469d6bfb 55 * @param pdict ptr to dict to search
va009039 0:65f1469d6bfb 56 * @param pkey ptr to key obj
va009039 0:65f1469d6bfb 57 * @param r_pobj Return; addr of ptr to obj
va009039 0:65f1469d6bfb 58 * @return Return status
va009039 0:65f1469d6bfb 59 */
va009039 0:65f1469d6bfb 60 PmReturn_t dict_getItem(pPmObj_t pdict, pPmObj_t pkey, pPmObj_t *r_pobj);
va009039 0:65f1469d6bfb 61
va009039 0:65f1469d6bfb 62 #ifdef HAVE_DEL
va009039 0:65f1469d6bfb 63 /**
va009039 0:65f1469d6bfb 64 * Removes a key and value from the dict.
va009039 0:65f1469d6bfb 65 * Throws TypeError if pdict is not a dict.
va009039 0:65f1469d6bfb 66 * Throws KeyError if pkey does not exist in pdict.
va009039 0:65f1469d6bfb 67 *
va009039 0:65f1469d6bfb 68 * @param pdict Ptr to dict to search
va009039 0:65f1469d6bfb 69 * @param pkey Ptr to key obj
va009039 0:65f1469d6bfb 70 * @return Return status
va009039 0:65f1469d6bfb 71 */
va009039 0:65f1469d6bfb 72 PmReturn_t dict_delItem(pPmObj_t pdict, pPmObj_t pkey);
va009039 0:65f1469d6bfb 73 #endif /* HAVE_DEL */
va009039 0:65f1469d6bfb 74
va009039 0:65f1469d6bfb 75 /**
va009039 0:65f1469d6bfb 76 * Allocates space for a new Dict.
va009039 0:65f1469d6bfb 77 * Return a pointer to the dict by reference.
va009039 0:65f1469d6bfb 78 *
va009039 0:65f1469d6bfb 79 * @param r_pdict Return; Addr of ptr to dict
va009039 0:65f1469d6bfb 80 * @return Return status
va009039 0:65f1469d6bfb 81 */
va009039 0:65f1469d6bfb 82 PmReturn_t dict_new(pPmObj_t *r_pdict);
va009039 0:65f1469d6bfb 83
va009039 0:65f1469d6bfb 84 /**
va009039 0:65f1469d6bfb 85 * Sets a value in the dict using the given key.
va009039 0:65f1469d6bfb 86 *
va009039 0:65f1469d6bfb 87 * If the dict already contains a matching key, the value is
va009039 0:65f1469d6bfb 88 * replaced; otherwise the new key,val pair is inserted
va009039 0:65f1469d6bfb 89 * at the front of the dict (for fast lookup).
va009039 0:65f1469d6bfb 90 * In the later case, the length of the dict is incremented.
va009039 0:65f1469d6bfb 91 *
va009039 0:65f1469d6bfb 92 * @param pdict ptr to dict in which (key,val) will go
va009039 0:65f1469d6bfb 93 * @param pkey ptr to key obj
va009039 0:65f1469d6bfb 94 * @param pval ptr to val obj
va009039 0:65f1469d6bfb 95 * @return Return status
va009039 0:65f1469d6bfb 96 */
va009039 0:65f1469d6bfb 97 PmReturn_t dict_setItem(pPmObj_t pdict, pPmObj_t pkey, pPmObj_t pval);
va009039 0:65f1469d6bfb 98
va009039 0:65f1469d6bfb 99 #ifdef HAVE_PRINT
va009039 0:65f1469d6bfb 100 /**
va009039 0:65f1469d6bfb 101 * Prints out a dict. Uses obj_print() to print elements.
va009039 0:65f1469d6bfb 102 *
va009039 0:65f1469d6bfb 103 * @param pobj Object to print.
va009039 0:65f1469d6bfb 104 * @return Return status
va009039 0:65f1469d6bfb 105 */
va009039 0:65f1469d6bfb 106 PmReturn_t dict_print(pPmObj_t pdict);
va009039 0:65f1469d6bfb 107 #endif /* HAVE_PRINT */
va009039 0:65f1469d6bfb 108
va009039 0:65f1469d6bfb 109 /**
va009039 0:65f1469d6bfb 110 * Updates the destination dict with the key,value pairs from the source dict
va009039 0:65f1469d6bfb 111 *
va009039 0:65f1469d6bfb 112 * @param pdestdict ptr to destination dict in which key,val pairs will go
va009039 0:65f1469d6bfb 113 * @param psourcedict ptr to source dict which has all key,val pairs to copy
va009039 0:65f1469d6bfb 114 * @param omit_underscored Boolean set to true to omit key,val pairs where
va009039 0:65f1469d6bfb 115 * the key starts with an underscore '_'.
va009039 0:65f1469d6bfb 116 * @return Return status
va009039 0:65f1469d6bfb 117 */
va009039 0:65f1469d6bfb 118 PmReturn_t dict_update(pPmObj_t pdestdict, pPmObj_t psourcedict,
va009039 0:65f1469d6bfb 119 uint8_t omit_underscored);
va009039 0:65f1469d6bfb 120
va009039 0:65f1469d6bfb 121 /**
va009039 0:65f1469d6bfb 122 * Returns C_SAME if the two given dictionaries have the same contents
va009039 0:65f1469d6bfb 123 *
va009039 0:65f1469d6bfb 124 * @param d1 ptr to a dictionary object
va009039 0:65f1469d6bfb 125 * @param d2 ptr to another dictionary object
va009039 0:65f1469d6bfb 126 * @return C_DIFFER or C_SAME
va009039 0:65f1469d6bfb 127 */
va009039 0:65f1469d6bfb 128 int8_t dict_compare(pPmObj_t d1, pPmObj_t d2);
va009039 0:65f1469d6bfb 129
va009039 0:65f1469d6bfb 130 #endif /* __DICT_H__ */