factor/native/string.h

59 lines
1.5 KiB
C
Raw Normal View History

2004-07-16 02:26:21 -04:00
typedef struct {
CELL header;
/* untagged */
CELL capacity;
/* untagged */
2004-08-01 19:26:43 -04:00
FIXNUM hashcode;
2004-07-16 02:26:21 -04:00
} STRING;
INLINE STRING* untag_string(CELL tagged)
{
type_check(STRING_TYPE,tagged);
return (STRING*)UNTAG(tagged);
}
2004-08-27 02:09:24 -04:00
STRING* allot_string(FIXNUM capacity);
STRING* string(FIXNUM capacity, CELL fill);
2004-07-16 02:26:21 -04:00
void hash_string(STRING* str);
2004-08-27 02:09:24 -04:00
STRING* grow_string(STRING* string, FIXNUM capacity, CHAR fill);
BYTE* to_c_string(STRING* s);
STRING* from_c_string(const BYTE* c_string);
2004-07-16 02:26:21 -04:00
#define SREF(string,index) ((CELL)string + sizeof(STRING) + index * CHARS)
#define SSIZE(pointer) align8(sizeof(STRING) + \
((STRING*)pointer)->capacity * CHARS)
/* untagged & unchecked */
INLINE CELL string_nth(STRING* string, CELL index)
{
return cget(SREF(string,index));
}
/* untagged & unchecked */
INLINE void set_string_nth(STRING* string, CELL index, CHAR value)
{
cput(SREF(string,index),value);
}
void primitive_stringp(void);
void primitive_string_length(void);
void primitive_string_nth(void);
FIXNUM string_compare_head(STRING* s1, STRING* s2, CELL len);
2004-07-16 02:26:21 -04:00
FIXNUM string_compare(STRING* s1, STRING* s2);
void primitive_string_compare(void);
void primitive_string_eq(void);
void primitive_string_hashcode(void);
void primitive_index_of(void);
void primitive_substring(void);
2004-08-12 23:40:28 -04:00
INLINE STRING* fixup_untagged_string(STRING* str)
{
return (STRING*)((CELL)str + (active.base - relocation_base));
2004-08-12 23:40:28 -04:00
}
INLINE STRING* copy_untagged_string(STRING* str)
{
return copy_untagged_object(str,SSIZE(str));
}