19#define RSTRING_EMBED_LEN_MAX \
20 ((mrb_int)(sizeof(void*) * 3 + sizeof(void*) - 32 / CHAR_BIT - 1))
38 char ary[RSTRING_EMBED_LEN_MAX+1];
41#define RSTR_SET_TYPE_FLAG(s, type) (RSTR_UNSET_TYPE_FLAG(s), (s)->flags |= MRB_STR_##type)
42#define RSTR_UNSET_TYPE_FLAG(s) ((s)->flags &= ~(MRB_STR_TYPE_MASK|MRB_STR_EMBED_LEN_MASK))
44#define RSTR_EMBED_P(s) ((s)->flags & MRB_STR_EMBED)
45#define RSTR_SET_EMBED_FLAG(s) ((s)->flags |= MRB_STR_EMBED)
46#define RSTR_UNSET_EMBED_FLAG(s) ((s)->flags &= ~(MRB_STR_EMBED|MRB_STR_EMBED_LEN_MASK))
47#define RSTR_SET_EMBED_LEN(s, n) do {\
49 (s)->flags &= ~MRB_STR_EMBED_LEN_MASK;\
50 (s)->flags |= (tmp_n) << MRB_STR_EMBED_LEN_SHIFT;\
52#define RSTR_SET_LEN(s, n) do {\
53 if (RSTR_EMBED_P(s)) {\
54 RSTR_SET_EMBED_LEN((s),(n));\
57 (s)->as.heap.len = (mrb_ssize)(n);\
60#define RSTR_EMBED_PTR(s) (((struct RStringEmbed*)(s))->ary)
61#define RSTR_EMBED_LEN(s)\
62 (mrb_int)(((s)->flags & MRB_STR_EMBED_LEN_MASK) >> MRB_STR_EMBED_LEN_SHIFT)
63#define RSTR_EMBEDDABLE_P(len) ((len) <= RSTRING_EMBED_LEN_MAX)
65#define RSTR_PTR(s) ((RSTR_EMBED_P(s)) ? RSTR_EMBED_PTR(s) : (s)->as.heap.ptr)
66#define RSTR_LEN(s) ((RSTR_EMBED_P(s)) ? RSTR_EMBED_LEN(s) : (s)->as.heap.len)
67#define RSTR_CAPA(s) (RSTR_EMBED_P(s) ? RSTRING_EMBED_LEN_MAX : (s)->as.heap.aux.capa)
69#define RSTR_SHARED_P(s) ((s)->flags & MRB_STR_SHARED)
70#define RSTR_SET_SHARED_FLAG(s) ((s)->flags |= MRB_STR_SHARED)
71#define RSTR_UNSET_SHARED_FLAG(s) ((s)->flags &= ~MRB_STR_SHARED)
73#define RSTR_FSHARED_P(s) ((s)->flags & MRB_STR_FSHARED)
74#define RSTR_SET_FSHARED_FLAG(s) ((s)->flags |= MRB_STR_FSHARED)
75#define RSTR_UNSET_FSHARED_FLAG(s) ((s)->flags &= ~MRB_STR_FSHARED)
77#define RSTR_NOFREE_P(s) ((s)->flags & MRB_STR_NOFREE)
78#define RSTR_SET_NOFREE_FLAG(s) ((s)->flags |= MRB_STR_NOFREE)
79#define RSTR_UNSET_NOFREE_FLAG(s) ((s)->flags &= ~MRB_STR_NOFREE)
82# define RSTR_ASCII_P(s) ((s)->flags & MRB_STR_ASCII)
83# define RSTR_SET_ASCII_FLAG(s) ((s)->flags |= MRB_STR_ASCII)
84# define RSTR_UNSET_ASCII_FLAG(s) ((s)->flags &= ~MRB_STR_ASCII)
85# define RSTR_WRITE_ASCII_FLAG(s, v) (RSTR_UNSET_ASCII_FLAG(s), (s)->flags |= v)
86# define RSTR_COPY_ASCII_FLAG(dst, src) RSTR_WRITE_ASCII_FLAG(dst, RSTR_ASCII_P(src))
88# define RSTR_ASCII_P(s) (void)0
89# define RSTR_SET_ASCII_FLAG(s) (void)0
90# define RSTR_UNSET_ASCII_FLAG(s) (void)0
91# define RSTR_WRITE_ASCII_FLAG(s, v) (void)0
92# define RSTR_COPY_ASCII_FLAG(dst, src) (void)0
98#define mrb_str_ptr(s) ((struct RString*)(mrb_ptr(s)))
99#define RSTRING(s) mrb_str_ptr(s)
100#define RSTRING_PTR(s) RSTR_PTR(RSTRING(s))
101#define RSTRING_EMBED_LEN(s) RSTR_EMBED_LEN(RSTRING(s))
102#define RSTRING_LEN(s) RSTR_LEN(RSTRING(s))
103#define RSTRING_CAPA(s) RSTR_CAPA(RSTRING(s))
104#define RSTRING_END(s) (RSTRING_PTR(s) + RSTRING_LEN(s))
105#define RSTRING_CSTR(mrb,s) mrb_string_cstr(mrb, s)
107#define MRB_STR_SHARED 1
108#define MRB_STR_FSHARED 2
109#define MRB_STR_NOFREE 4
110#define MRB_STR_EMBED 8
111#define MRB_STR_ASCII 16
112#define MRB_STR_EMBED_LEN_SHIFT 6
113#define MRB_STR_EMBED_LEN_BIT 5
114#define MRB_STR_EMBED_LEN_MASK (((1 << MRB_STR_EMBED_LEN_BIT) - 1) << MRB_STR_EMBED_LEN_SHIFT)
115#define MRB_STR_TYPE_MASK 15
125#define mrb_str_index_lit(mrb, str, lit, off) mrb_str_index(mrb, str, lit, mrb_strlen_lit(lit), off);
325#define mrb_str_buf_new(mrb, capa) mrb_str_new_capa(mrb, (capa))
332#define mrb_string_value_ptr(mrb, str) RSTRING_PTR(str)
334#define mrb_string_value_len(mrb, str) RSTRING_LEN(str)
336#define mrb_str_strlen(mrb, s) strlen(RSTR_PTR(s))
359#define mrb_str_to_inum(mrb, str, base, badcheck) mrb_str_to_integer(mrb, str, base, badcheck)
395#define mrb_str_cat_lit(mrb, str, lit) mrb_str_cat(mrb, str, lit, mrb_strlen_lit(lit))
425#define mrb_str_cat2(mrb, str, ptr) mrb_str_cat_cstr(mrb, str, ptr)
426#define mrb_str_buf_cat(mrb, str, ptr, len) mrb_str_cat(mrb, str, ptr, len)
427#define mrb_str_buf_append(mrb, str, str2) mrb_str_cat_str(mrb, str, str2)
mruby common platform definition"
#define MRB_END_DECL
End declarations in C mode.
Definition common.h:28
#define MRB_BEGIN_DECL
Start declarations in C mode.
Definition common.h:26
#define MRB_API
Declare a public mruby API function.
Definition common.h:79
const char mrb_digitmap[]
String class.
Definition string.c:27
mrb_value mrb_str_cat(mrb_state *mrb, mrb_value str, const char *ptr, size_t len)
Returns a concatenated string comprised of a Ruby string and a C string.
Definition string.c:2701
mrb_value mrb_str_append(mrb_state *mrb, mrb_value str, mrb_value str2)
Adds str2 to the end of str1.
Definition string.c:2751
mrb_int mrb_str_index(mrb_state *mrb, mrb_value str, const char *p, mrb_int len, mrb_int offset)
Finds the index of a substring in a string.
Definition string.c:599
mrb_value mrb_str_plus(mrb_state *mrb, mrb_value a, mrb_value b)
Adds two strings together.
Definition string.c:810
mrb_value mrb_str_resize(mrb_state *mrb, mrb_value str, mrb_int len)
Resizes the string's length.
Definition string.c:772
mrb_bool mrb_str_equal(mrb_state *mrb, mrb_value str1, mrb_value str2)
Returns true if the strings match and false if the strings don't match.
Definition string.c:996
mrb_value mrb_str_cat_cstr(mrb_state *mrb, mrb_value str, const char *ptr)
Returns a concatenated string comprised of a Ruby string and a C string.
Definition string.c:2736
mrb_value mrb_obj_as_string(mrb_state *mrb, mrb_value obj)
Returns an object as a Ruby string.
Definition string.c:1886
mrb_value mrb_str_substr(mrb_state *mrb, mrb_value str, mrb_int beg, mrb_int len)
Returns a sub string.
Definition string.c:1657
mrb_value mrb_str_intern(mrb_state *mrb, mrb_value self)
Returns a symbol from a passed in Ruby string.
Definition string.c:1880
char * mrb_str_to_cstr(mrb_state *mrb, mrb_value str)
Returns a newly allocated C string from a Ruby string.
Definition string.c:791
mrb_value mrb_str_dup(mrb_state *mrb, mrb_value str)
Duplicates a string object.
Definition string.c:1023
mrb_value mrb_ptr_to_str(mrb_state *mrb, void *p)
Converts pointer into a Ruby string.
Definition string.c:1905
void mrb_str_concat(mrb_state *mrb, mrb_value self, mrb_value other)
Appends self to other.
Definition string.c:803
int mrb_str_cmp(mrb_state *mrb, mrb_value str1, mrb_value str2)
Returns 0 if both Ruby strings are equal.
Definition string.c:923
Definition boxing_nan.h:40