python-on-a-chip online compiler

Dependencies:   mbed TSI

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers bytearray.h Source File

bytearray.h

Go to the documentation of this file.
00001 /*
00002 # This file is Copyright 2010 Dean Hall.
00003 # This file is part of the PyMite VM.
00004 # This file is licensed under the MIT License.
00005 # See the LICENSE file for details.
00006 */
00007 
00008 
00009 #ifndef __BYTEARRAY_H__
00010 #define __BYTEARRAY_H__
00011 
00012 /**
00013  * \file
00014  * \brief Bytearray Object Type
00015  *
00016  * Bytearray object type header.
00017  */
00018 
00019 
00020 /**
00021  * Bytes container
00022  *
00023  * Holds actual byte payload
00024  */
00025 typedef struct PmBytes_s
00026 {
00027     /** Object descriptor */
00028     PmObjDesc_t od;
00029 
00030     /** Physical number of bytes in the C array (below) */
00031     uint16_t length;
00032 
00033     /** C array of bytes */
00034     uint8_t val[1];
00035 } PmBytes_t,
00036  *pPmBytes_t;
00037 
00038 
00039 /**
00040  * Bytearray obj
00041  *
00042  * Mutable ordered sequence of bytes.  Contains ptr to chunk of bytes.
00043  */
00044 typedef struct PmBytearray_s
00045 {
00046     /** Object descriptor */
00047     PmObjDesc_t od;
00048 
00049     /** Bytearray length; logical number of bytes */
00050     uint16_t length;
00051 
00052     /** Ptr to bytes container (may hold more bytes than length) */
00053     pPmBytes_t val;
00054 } PmBytearray_t,
00055  *pPmBytearray_t;
00056 
00057  
00058 PmReturn_t bytearray_new(pPmObj_t pobj, pPmObj_t *r_pobj);
00059 PmReturn_t bytearray_getItem(pPmObj_t pobj, int16_t index, pPmObj_t *r_pobj);
00060 PmReturn_t bytearray_setItem(pPmObj_t pba, int16_t index, pPmObj_t pobj);
00061 PmReturn_t bytearray_print(pPmObj_t pobj);
00062 
00063 #endif /* __BYTEARRAY_H__ */