strobj.h

Go to the documentation of this file.
00001 /*
00002 # This file is Copyright 2003, 2006, 2007, 2009, 2010 Dean Hall.
00003 #
00004 # This file is part of the PyMite VM.
00005 # The PyMite VM is free software: you can redistribute it and/or modify
00006 # it under the terms of the GNU GENERAL PUBLIC LICENSE Version 2.
00007 #
00008 # The PyMite VM is distributed in the hope that it will be useful,
00009 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00011 # A copy of the GNU GENERAL PUBLIC LICENSE Version 2
00012 # is seen in the file COPYING in this directory.
00013 */
00014 
00015 
00016 #ifndef __STRING_H__
00017 #define __STRING_H__
00018 
00019 
00029 #define USE_STRING_CACHE 1
00030 
00031 
00040 #define string_loadFromImg(ms, paddr, r_pstring) \
00041     string_create((ms), (paddr), (int16_t)-1, (int16_t)1, (r_pstring))
00042 
00049 #define string_new(paddr, r_pstring) \
00050     string_create(MEMSPACE_RAM, (uint8_t const **)(paddr), 0, (int16_t)1, (r_pstring))
00051 
00060 #define string_newWithLen(paddr, len, r_pstring) \
00061     string_create(MEMSPACE_RAM, (uint8_t const **)(paddr), (len), (int16_t)1, \
00062                   (r_pstring))
00063 
00071 #define string_replicate(paddr, n, r_pstring) \
00072     string_create(MEMSPACE_RAM, (paddr), (uint8_t)0, (n), (r_pstring))
00073 
00074 /***************************************************************
00075  * Types
00076  **************************************************************/
00077 
00083 typedef struct PmString_s
00084 {
00086     PmObjDesc_t od;
00087 
00089     uint16_t length;
00090 
00091 #if USE_STRING_CACHE
00092 
00093     struct PmString_s *next;
00094 #endif                          /* USE_STRING_CACHE */
00095 
00102     uint8_t val[1];
00103 } PmString_t,
00104  *pPmString_t;
00105 
00106 
00107 /***************************************************************
00108  * Prototypes
00109  **************************************************************/
00110 
00139 PmReturn_t string_create(PmMemSpace_t memspace, uint8_t const **paddr,
00140                          int16_t len, int16_t n, pPmObj_t *r_pstring);
00141 
00149 PmReturn_t string_newFromChar(uint8_t const c, pPmObj_t *r_pstring);
00150 
00158 int8_t string_compare(pPmString_t pstr1, pPmString_t pstr2);
00159 
00160 #ifdef HAVE_PRINT
00161 
00170 PmReturn_t string_print(pPmObj_t pstr, uint8_t is_escaped);
00171 #endif /* HAVE_PRINT */
00172 
00179 PmReturn_t string_cacheInit(void);
00180 
00181 
00183 PmReturn_t string_getCache(pPmString_t **r_ppstrcache);
00184 
00194 PmReturn_t
00195 string_concat(pPmString_t pstr1, pPmString_t pstr2, pPmObj_t *r_pstring);
00196 
00197 #ifdef HAVE_STRING_FORMAT
00198 
00207 PmReturn_t string_format(pPmString_t pstr, pPmObj_t parg, pPmObj_t *r_pstring);
00208 
00217 PmReturn_t string_printFormattedBytes(uint8_t *pb,
00218                                       uint8_t is_escaped,
00219                                       uint16_t n);
00220 #endif /* HAVE_STRING_FORMAT */
00221 
00222 #endif /* __STRING_H__ */

Generated on Mon Oct 18 07:40:48 2010 for Python-on-a-chip by  doxygen 1.5.9