Norimasa Okamoto
/
pymite
python-on-a-chip online compiler
- http://pymbed.appspot.com/
- https://code.google.com/p/python-on-a-chip/
- http://www.youtube.com/watch?v=Oyqc2bFRW9I
- https://bitbucket.org/va009039/pymbed/
more info: python-on-a-chip
vm/bytearray.h@15:94ca5c8003e5, 2016-04-14 (annotated)
- 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?
User | Revision | Line number | New contents of line |
---|---|---|---|
va009039 | 0:65f1469d6bfb | 1 | /* |
va009039 | 0:65f1469d6bfb | 2 | # This file is Copyright 2010 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 __BYTEARRAY_H__ |
va009039 | 0:65f1469d6bfb | 10 | #define __BYTEARRAY_H__ |
va009039 | 0:65f1469d6bfb | 11 | |
va009039 | 0:65f1469d6bfb | 12 | /** |
va009039 | 0:65f1469d6bfb | 13 | * \file |
va009039 | 0:65f1469d6bfb | 14 | * \brief Bytearray Object Type |
va009039 | 0:65f1469d6bfb | 15 | * |
va009039 | 0:65f1469d6bfb | 16 | * Bytearray object type header. |
va009039 | 0:65f1469d6bfb | 17 | */ |
va009039 | 0:65f1469d6bfb | 18 | |
va009039 | 0:65f1469d6bfb | 19 | |
va009039 | 0:65f1469d6bfb | 20 | /** |
va009039 | 0:65f1469d6bfb | 21 | * Bytes container |
va009039 | 0:65f1469d6bfb | 22 | * |
va009039 | 0:65f1469d6bfb | 23 | * Holds actual byte payload |
va009039 | 0:65f1469d6bfb | 24 | */ |
va009039 | 0:65f1469d6bfb | 25 | typedef struct PmBytes_s |
va009039 | 0:65f1469d6bfb | 26 | { |
va009039 | 0:65f1469d6bfb | 27 | /** Object descriptor */ |
va009039 | 0:65f1469d6bfb | 28 | PmObjDesc_t od; |
va009039 | 0:65f1469d6bfb | 29 | |
va009039 | 0:65f1469d6bfb | 30 | /** Physical number of bytes in the C array (below) */ |
va009039 | 0:65f1469d6bfb | 31 | uint16_t length; |
va009039 | 0:65f1469d6bfb | 32 | |
va009039 | 0:65f1469d6bfb | 33 | /** C array of bytes */ |
va009039 | 0:65f1469d6bfb | 34 | uint8_t val[1]; |
va009039 | 0:65f1469d6bfb | 35 | } PmBytes_t, |
va009039 | 0:65f1469d6bfb | 36 | *pPmBytes_t; |
va009039 | 0:65f1469d6bfb | 37 | |
va009039 | 0:65f1469d6bfb | 38 | |
va009039 | 0:65f1469d6bfb | 39 | /** |
va009039 | 0:65f1469d6bfb | 40 | * Bytearray obj |
va009039 | 0:65f1469d6bfb | 41 | * |
va009039 | 0:65f1469d6bfb | 42 | * Mutable ordered sequence of bytes. Contains ptr to chunk of bytes. |
va009039 | 0:65f1469d6bfb | 43 | */ |
va009039 | 0:65f1469d6bfb | 44 | typedef struct PmBytearray_s |
va009039 | 0:65f1469d6bfb | 45 | { |
va009039 | 0:65f1469d6bfb | 46 | /** Object descriptor */ |
va009039 | 0:65f1469d6bfb | 47 | PmObjDesc_t od; |
va009039 | 0:65f1469d6bfb | 48 | |
va009039 | 0:65f1469d6bfb | 49 | /** Bytearray length; logical number of bytes */ |
va009039 | 0:65f1469d6bfb | 50 | uint16_t length; |
va009039 | 0:65f1469d6bfb | 51 | |
va009039 | 0:65f1469d6bfb | 52 | /** Ptr to bytes container (may hold more bytes than length) */ |
va009039 | 0:65f1469d6bfb | 53 | pPmBytes_t val; |
va009039 | 0:65f1469d6bfb | 54 | } PmBytearray_t, |
va009039 | 0:65f1469d6bfb | 55 | *pPmBytearray_t; |
va009039 | 0:65f1469d6bfb | 56 | |
va009039 | 0:65f1469d6bfb | 57 | |
va009039 | 0:65f1469d6bfb | 58 | PmReturn_t bytearray_new(pPmObj_t pobj, pPmObj_t *r_pobj); |
va009039 | 0:65f1469d6bfb | 59 | PmReturn_t bytearray_getItem(pPmObj_t pobj, int16_t index, pPmObj_t *r_pobj); |
va009039 | 0:65f1469d6bfb | 60 | PmReturn_t bytearray_setItem(pPmObj_t pba, int16_t index, pPmObj_t pobj); |
va009039 | 0:65f1469d6bfb | 61 | PmReturn_t bytearray_print(pPmObj_t pobj); |
va009039 | 0:65f1469d6bfb | 62 | |
va009039 | 0:65f1469d6bfb | 63 | #endif /* __BYTEARRAY_H__ */ |