2004-07-16 02:26:21 -04:00
|
|
|
typedef struct {
|
|
|
|
CELL header;
|
2005-02-20 19:03:37 -05:00
|
|
|
/* tagged num of chars */
|
|
|
|
CELL length;
|
2004-12-28 00:04:20 -05:00
|
|
|
/* tagged */
|
|
|
|
CELL hashcode;
|
2004-12-10 21:46:42 -05:00
|
|
|
} F_STRING;
|
2004-07-16 02:26:21 -04:00
|
|
|
|
2005-02-09 19:58:53 -05:00
|
|
|
#define SREF(string,index) ((CELL)string + sizeof(F_STRING) + index * CHARS)
|
|
|
|
|
2005-05-05 22:30:58 -04:00
|
|
|
INLINE F_STRING* untag_string_fast(CELL tagged)
|
|
|
|
{
|
|
|
|
return (F_STRING*)UNTAG(tagged);
|
|
|
|
}
|
|
|
|
|
2004-12-10 21:46:42 -05:00
|
|
|
INLINE F_STRING* untag_string(CELL tagged)
|
2004-07-16 02:26:21 -04:00
|
|
|
{
|
|
|
|
type_check(STRING_TYPE,tagged);
|
2005-05-05 22:30:58 -04:00
|
|
|
return untag_string_fast(tagged);
|
2004-07-16 02:26:21 -04:00
|
|
|
}
|
|
|
|
|
2005-02-20 19:03:37 -05:00
|
|
|
INLINE CELL string_capacity(F_STRING* str)
|
|
|
|
{
|
|
|
|
return untag_fixnum_fast(str->length);
|
|
|
|
}
|
|
|
|
|
2005-06-16 18:50:49 -04:00
|
|
|
INLINE CELL string_size(CELL size)
|
|
|
|
{
|
|
|
|
return align8(sizeof(F_STRING) + (size + 1) * CHARS);
|
|
|
|
}
|
2005-02-20 19:03:37 -05:00
|
|
|
|
2005-12-24 18:29:31 -05:00
|
|
|
F_STRING* allot_string(F_FIXNUM capacity);
|
|
|
|
F_STRING* string(F_FIXNUM capacity, CELL fill);
|
|
|
|
void primitive_string(void);
|
2004-12-10 21:46:42 -05:00
|
|
|
void rehash_string(F_STRING* str);
|
2005-05-18 16:26:22 -04:00
|
|
|
void primitive_rehash_string(void);
|
2005-06-10 16:08:00 -04:00
|
|
|
F_STRING* resize_string(F_STRING* string, F_FIXNUM capacity, u16 fill);
|
|
|
|
void primitive_resize_string(void);
|
2005-12-12 18:51:45 -05:00
|
|
|
F_ARRAY *string_to_alien(F_STRING *s, bool check);
|
|
|
|
char* to_c_string(F_STRING* s, bool check);
|
2005-04-22 20:09:46 -04:00
|
|
|
void string_to_memory(F_STRING* s, BYTE* string);
|
2004-12-19 21:07:17 -05:00
|
|
|
void primitive_string_to_memory(void);
|
2005-03-03 20:43:55 -05:00
|
|
|
DLLEXPORT void box_c_string(const char* c_string);
|
|
|
|
F_STRING* from_c_string(const char* c_string);
|
2005-04-22 20:09:46 -04:00
|
|
|
F_STRING* memory_to_string(const BYTE* string, CELL length);
|
2004-12-19 21:07:17 -05:00
|
|
|
void primitive_memory_to_string(void);
|
2005-03-03 20:43:55 -05:00
|
|
|
DLLEXPORT char* unbox_c_string(void);
|
2006-02-19 20:53:18 -05:00
|
|
|
char *pop_c_string(void);
|
2005-03-21 20:59:30 -05:00
|
|
|
DLLEXPORT u16* unbox_utf16_string(void);
|
2006-02-21 16:42:56 -05:00
|
|
|
DLLEXPORT void box_utf16_string(u16 *unboxed);
|
2004-07-16 02:26:21 -04:00
|
|
|
|
|
|
|
/* untagged & unchecked */
|
2004-12-10 21:46:42 -05:00
|
|
|
INLINE CELL string_nth(F_STRING* string, CELL index)
|
2004-07-16 02:26:21 -04:00
|
|
|
{
|
|
|
|
return cget(SREF(string,index));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* untagged & unchecked */
|
2005-03-21 20:59:30 -05:00
|
|
|
INLINE void set_string_nth(F_STRING* string, CELL index, u16 value)
|
2004-07-16 02:26:21 -04:00
|
|
|
{
|
|
|
|
cput(SREF(string,index),value);
|
|
|
|
}
|
|
|
|
|
2005-05-05 22:30:58 -04:00
|
|
|
void primitive_char_slot(void);
|
|
|
|
void primitive_set_char_slot(void);
|