Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
src/vm/bytearray.h@0:14e5e829dffe, 2010-07-21 (annotated)
- Committer:
- dadaista
- Date:
- Wed Jul 21 12:50:41 2010 +0000
- Revision:
- 0:14e5e829dffe
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
dadaista | 0:14e5e829dffe | 1 | /* |
dadaista | 0:14e5e829dffe | 2 | # This file is Copyright 2010 Dean Hall. |
dadaista | 0:14e5e829dffe | 3 | # |
dadaista | 0:14e5e829dffe | 4 | # This file is part of the PyMite VM. |
dadaista | 0:14e5e829dffe | 5 | # The PyMite VM is free software: you can redistribute it and/or modify |
dadaista | 0:14e5e829dffe | 6 | # it under the terms of the GNU GENERAL PUBLIC LICENSE Version 2. |
dadaista | 0:14e5e829dffe | 7 | # |
dadaista | 0:14e5e829dffe | 8 | # The PyMite VM is distributed in the hope that it will be useful, |
dadaista | 0:14e5e829dffe | 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
dadaista | 0:14e5e829dffe | 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
dadaista | 0:14e5e829dffe | 11 | # A copy of the GNU GENERAL PUBLIC LICENSE Version 2 |
dadaista | 0:14e5e829dffe | 12 | # is seen in the file COPYING in this directory. |
dadaista | 0:14e5e829dffe | 13 | */ |
dadaista | 0:14e5e829dffe | 14 | |
dadaista | 0:14e5e829dffe | 15 | |
dadaista | 0:14e5e829dffe | 16 | #ifndef __BYTEARRAY_H__ |
dadaista | 0:14e5e829dffe | 17 | #define __BYTEARRAY_H__ |
dadaista | 0:14e5e829dffe | 18 | |
dadaista | 0:14e5e829dffe | 19 | /** |
dadaista | 0:14e5e829dffe | 20 | * \file |
dadaista | 0:14e5e829dffe | 21 | * \brief Bytearray Object Type |
dadaista | 0:14e5e829dffe | 22 | * |
dadaista | 0:14e5e829dffe | 23 | * Bytearray object type header. |
dadaista | 0:14e5e829dffe | 24 | */ |
dadaista | 0:14e5e829dffe | 25 | |
dadaista | 0:14e5e829dffe | 26 | |
dadaista | 0:14e5e829dffe | 27 | /** |
dadaista | 0:14e5e829dffe | 28 | * Bytes container |
dadaista | 0:14e5e829dffe | 29 | * |
dadaista | 0:14e5e829dffe | 30 | * Holds actual byte payload |
dadaista | 0:14e5e829dffe | 31 | */ |
dadaista | 0:14e5e829dffe | 32 | typedef struct PmBytes_s |
dadaista | 0:14e5e829dffe | 33 | { |
dadaista | 0:14e5e829dffe | 34 | /** Object descriptor */ |
dadaista | 0:14e5e829dffe | 35 | PmObjDesc_t od; |
dadaista | 0:14e5e829dffe | 36 | |
dadaista | 0:14e5e829dffe | 37 | /** Physical number of bytes in the C array (below) */ |
dadaista | 0:14e5e829dffe | 38 | int16_t length; |
dadaista | 0:14e5e829dffe | 39 | |
dadaista | 0:14e5e829dffe | 40 | /** C array of bytes */ |
dadaista | 0:14e5e829dffe | 41 | uint8_t val[1]; |
dadaista | 0:14e5e829dffe | 42 | } PmBytes_t, |
dadaista | 0:14e5e829dffe | 43 | *pPmBytes_t; |
dadaista | 0:14e5e829dffe | 44 | |
dadaista | 0:14e5e829dffe | 45 | |
dadaista | 0:14e5e829dffe | 46 | /** |
dadaista | 0:14e5e829dffe | 47 | * Bytearray obj |
dadaista | 0:14e5e829dffe | 48 | * |
dadaista | 0:14e5e829dffe | 49 | * Mutable ordered sequence of bytes. Contains ptr to chunk of bytes. |
dadaista | 0:14e5e829dffe | 50 | */ |
dadaista | 0:14e5e829dffe | 51 | typedef struct PmBytearray_s |
dadaista | 0:14e5e829dffe | 52 | { |
dadaista | 0:14e5e829dffe | 53 | /** Object descriptor */ |
dadaista | 0:14e5e829dffe | 54 | PmObjDesc_t od; |
dadaista | 0:14e5e829dffe | 55 | |
dadaista | 0:14e5e829dffe | 56 | /** Bytearray length; logical number of bytes */ |
dadaista | 0:14e5e829dffe | 57 | int16_t length; |
dadaista | 0:14e5e829dffe | 58 | |
dadaista | 0:14e5e829dffe | 59 | /** Ptr to bytes container (may hold more bytes than length) */ |
dadaista | 0:14e5e829dffe | 60 | pPmBytes_t val; |
dadaista | 0:14e5e829dffe | 61 | } PmBytearray_t, |
dadaista | 0:14e5e829dffe | 62 | *pPmBytearray_t; |
dadaista | 0:14e5e829dffe | 63 | |
dadaista | 0:14e5e829dffe | 64 | |
dadaista | 0:14e5e829dffe | 65 | PmReturn_t bytearray_new(pPmObj_t pobj, pPmObj_t *r_pobj); |
dadaista | 0:14e5e829dffe | 66 | PmReturn_t bytearray_getItem(pPmObj_t pobj, int16_t index, pPmObj_t *r_pobj); |
dadaista | 0:14e5e829dffe | 67 | PmReturn_t bytearray_setItem(pPmObj_t pba, int16_t index, pPmObj_t pobj); |
dadaista | 0:14e5e829dffe | 68 | PmReturn_t bytearray_print(pPmObj_t pobj); |
dadaista | 0:14e5e829dffe | 69 | |
dadaista | 0:14e5e829dffe | 70 | #endif /* __BYTEARRAY_H__ */ |