mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
string.c: rename type setting macro
This commit is contained in:
@@ -38,7 +38,7 @@ struct RStringEmbed {
|
||||
char ary[RSTRING_EMBED_LEN_MAX+1];
|
||||
};
|
||||
|
||||
#define RSTR_SET_TYPE_FLAG(s, type) (RSTR_UNSET_TYPE_FLAG(s), (s)->flags |= MRB_STR_##type)
|
||||
#define RSTR_SET_TYPE(s, type) (RSTR_UNSET_TYPE_FLAG(s), (s)->flags |= MRB_STR_##type)
|
||||
#define RSTR_UNSET_TYPE_FLAG(s) ((s)->flags &= ~(MRB_STR_TYPE_MASK|MRB_STR_EMBED_LEN_MASK))
|
||||
|
||||
#define RSTR_EMBED_P(s) ((s)->flags & MRB_STR_EMBED)
|
||||
@@ -107,6 +107,7 @@ struct RStringEmbed {
|
||||
#define RSTRING_END(s) (RSTRING_PTR(s) + RSTRING_LEN(s))
|
||||
#define RSTRING_CSTR(mrb,s) mrb_string_cstr(mrb, s)
|
||||
|
||||
#define MRB_STR_NORMAL 0
|
||||
#define MRB_STR_SHARED 1
|
||||
#define MRB_STR_FSHARED 2
|
||||
#define MRB_STR_NOFREE 4
|
||||
|
||||
+5
-5
@@ -61,7 +61,7 @@ str_init_normal_capa(mrb_state *mrb, struct RString *s,
|
||||
s->as.heap.ptr = dst;
|
||||
s->as.heap.len = len;
|
||||
s->as.heap.aux.capa = capa;
|
||||
RSTR_UNSET_TYPE_FLAG(s);
|
||||
RSTR_SET_TYPE(s, NORMAL);
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ str_init_embed(struct RString *s, const char *p, mrb_int len)
|
||||
mrb_assert(len >= 0);
|
||||
if (p) memcpy(RSTR_EMBED_PTR(s), p, len);
|
||||
RSTR_EMBED_PTR(s)[len] = '\0';
|
||||
RSTR_SET_TYPE_FLAG(s, EMBED);
|
||||
RSTR_SET_TYPE(s, EMBED);
|
||||
RSTR_SET_EMBED_LEN(s, len);
|
||||
return s;
|
||||
}
|
||||
@@ -88,7 +88,7 @@ str_init_nofree(struct RString *s, const char *p, mrb_int len)
|
||||
s->as.heap.ptr = (char*)p;
|
||||
s->as.heap.len = len;
|
||||
s->as.heap.aux.capa = 0; /* nofree */
|
||||
RSTR_SET_TYPE_FLAG(s, NOFREE);
|
||||
RSTR_SET_TYPE(s, NOFREE);
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ str_init_shared(mrb_state *mrb, const struct RString *orig, struct RString *s, m
|
||||
s->as.heap.ptr = orig->as.heap.ptr;
|
||||
s->as.heap.len = orig->as.heap.len;
|
||||
s->as.heap.aux.shared = shared;
|
||||
RSTR_SET_TYPE_FLAG(s, SHARED);
|
||||
RSTR_SET_TYPE(s, SHARED);
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ str_init_fshared(const struct RString *orig, struct RString *s, struct RString *
|
||||
s->as.heap.ptr = orig->as.heap.ptr;
|
||||
s->as.heap.len = orig->as.heap.len;
|
||||
s->as.heap.aux.fshared = fshared;
|
||||
RSTR_SET_TYPE_FLAG(s, FSHARED);
|
||||
RSTR_SET_TYPE(s, FSHARED);
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user