strobj.h

Go to the documentation of this file.
00001 /*
00002 # This file is Copyright 2003, 2006, 2007, 2009 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 
00038 #define string_loadFromImg(ms, paddr, r_pstring) \
00039     string_create((ms), (paddr), (int16_t)-1, (int16_t)1, (r_pstring))
00040 
00047 #define string_new(paddr, r_pstring) \
00048     string_create(MEMSPACE_RAM, (uint8_t const **)(paddr), 0, (int16_t)1, (r_pstring))
00049 
00058 #define string_newWithLen(paddr, len, r_pstring) \
00059     string_create(MEMSPACE_RAM, (uint8_t const **)(paddr), (len), (int16_t)1, \
00060                   (r_pstring))
00061 
00069 #define string_replicate(paddr, n, r_pstring) \
00070     string_create(MEMSPACE_RAM, (paddr), (uint8_t)0, (n), (r_pstring))
00071 
00072 /***************************************************************
00073  * Types
00074  **************************************************************/
00075 
00081 typedef struct PmString_s
00082 {
00084     PmObjDesc_t od;
00085 
00087     uint16_t length;
00088 
00089 #if USE_STRING_CACHE
00090 
00091     struct PmString_s *next;
00092 #endif                          /* USE_STRING_CACHE */
00093 
00100     uint8_t val[1];
00101 } PmString_t,
00102  *pPmString_t;
00103 
00104 
00105 /***************************************************************
00106  * Prototypes
00107  **************************************************************/
00108 
00136 PmReturn_t string_create(PmMemSpace_t memspace, uint8_t const **paddr,
00137                          int16_t len, int16_t n, pPmObj_t *r_pstring);
00138 ;
00139 
00147 PmReturn_t string_newFromChar(uint8_t const c, pPmObj_t *r_pstring);
00148 
00156 int8_t string_compare(pPmString_t, pPmString_t);
00157 
00158 #ifdef HAVE_PRINT
00159 
00168 PmReturn_t string_print(pPmObj_t pstr, uint8_t marshall);
00169 #endif /* HAVE_PRINT */
00170 
00177 PmReturn_t string_cacheInit(void);
00178 
00179 
00181 PmReturn_t string_getCache(pPmString_t **r_ppstrcache);
00182 
00192 PmReturn_t
00193 string_concat(pPmString_t pstr1, pPmString_t pstr2, pPmObj_t *r_pstring);
00194 
00195 #ifdef HAVE_STRING_FORMAT
00196 
00205 PmReturn_t string_format(pPmString_t pstr, pPmObj_t parg, pPmObj_t *r_pstring);
00206 #endif /* HAVE_STRING_FORMAT */
00207 
00208 #endif /* __STRING_H__ */

Generated on Wed Feb 24 13:37:02 2010 for Python-on-a-chip by  doxygen 1.5.9