Add a macro `mrb_frozen_p` that points to `MRB_FROZEN_P`.
MODIFY
include/mruby.h
include/mruby.h
@@ -1221,7 +1221,7 @@ MRB_API void mrb_check_type(mrb_state *mrb, mrb_value x, enum mrb_vtype t);
MRB_INLINE void mrb_check_frozen(mrb_state *mrb, void *o)
{
- if (MRB_FROZEN_P((struct RBasic*)o)) mrb_frozen_error(mrb, o);
+ if (mrb_frozen_p((struct RBasic*)o)) mrb_frozen_error(mrb, o);
}
typedef enum call_type {

MODIFY
include/mruby/object.h
include/mruby/object.h
@@ -25,6 +25,7 @@ struct RBasic {
#define MRB_FROZEN_P(o) ((o)->flags & MRB_FL_OBJ_IS_FROZEN)
#define MRB_SET_FROZEN_FLAG(o) ((o)->flags |= MRB_FL_OBJ_IS_FROZEN)
#define MRB_UNSET_FROZEN_FLAG(o) ((o)->flags &= ~MRB_FL_OBJ_IS_FROZEN)
+#define mrb_frozen_p(o) MRB_FROZEN_P(o)
struct RObject {
MRB_OBJECT_HEADER;

MODIFY
mrbgems/mruby-string-ext/src/string.c
mrbgems/mruby-string-ext/src/string.c
@@ -1081,7 +1081,7 @@ mrb_str_del_prefix_bang(mrb_state *mrb, mrb_value self)
if (plen > slen) return mrb_nil_value();
s = RSTR_PTR(str);
if (memcmp(s, ptr, plen) != 0) return mrb_nil_value();
- if (!MRB_FROZEN_P(str) && (RSTR_SHARED_P(str) || RSTR_FSHARED_P(str))) {
+ if (!mrb_frozen_p(str) && (RSTR_SHARED_P(str) || RSTR_FSHARED_P(str))) {
str->as.heap.ptr += plen;
}
else {
@@ -1138,7 +1138,7 @@ mrb_str_del_suffix_bang(mrb_state *mrb, mrb_value self)
if (plen > slen) return mrb_nil_value();
s = RSTR_PTR(str);
if (memcmp(s+slen-plen, ptr, plen) != 0) return mrb_nil_value();
- if (!MRB_FROZEN_P(str) && (RSTR_SHARED_P(str) || RSTR_FSHARED_P(str))) {
+ if (!mrb_frozen_p(str) && (RSTR_SHARED_P(str) || RSTR_FSHARED_P(str))) {
/* no need to modify string */
}
else {

MODIFY
src/array.c
src/array.c
@@ -388,7 +388,7 @@ ary_replace(mrb_state *mrb, struct RArray *a, struct RArray *b)
mrb_write_barrier(mrb, (struct RBasic*)a);
return;
}
- if (!MRB_FROZEN_P(b) && len > ARY_REPLACE_SHARED_MIN) {
+ if (!mrb_frozen_p(b) && len > ARY_REPLACE_SHARED_MIN) {
ary_make_shared(mrb, b);
goto shared_b;
}

MODIFY
src/error.c
src/error.c
@@ -233,7 +233,7 @@ mrb_exc_set(mrb_state *mrb, mrb_value exc)
(struct RBasic*)mrb->exc == mrb->gc.arena[mrb->gc.arena_idx-1]) {
mrb->gc.arena_idx--;
}
- if (!mrb->gc.out_of_memory && !MRB_FROZEN_P(mrb->exc)) {
+ if (!mrb->gc.out_of_memory && !mrb_frozen_p(mrb->exc)) {
exc_debug_info(mrb, mrb->exc);
mrb_keep_backtrace(mrb, exc);
}

MODIFY
src/hash.c
src/hash.c
@@ -576,7 +576,7 @@ static void mrb_hash_modify(mrb_state *mrb, mrb_value hash);
static inline mrb_value
ht_key(mrb_state *mrb, mrb_value key)
{
- if (mrb_string_p(key) && !MRB_FROZEN_P(mrb_str_ptr(key))) {
+ if (mrb_string_p(key) && !mrb_frozen_p(mrb_str_ptr(key))) {
key = mrb_str_dup(mrb, key);
MRB_SET_FROZEN_FLAG(mrb_str_ptr(key));
}

MODIFY
src/kernel.c
src/kernel.c
@@ -436,7 +436,7 @@ mrb_obj_freeze(mrb_state *mrb, mrb_value self)
{
if (!mrb_immediate_p(self)) {
struct RBasic *b = mrb_basic_ptr(self);
- if (!MRB_FROZEN_P(b)) {
+ if (!mrb_frozen_p(b)) {
MRB_SET_FROZEN_FLAG(b);
if (b->c->tt == MRB_TT_SCLASS) MRB_SET_FROZEN_FLAG(b->c);
}
@@ -447,7 +447,7 @@ mrb_obj_freeze(mrb_state *mrb, mrb_value self)
static mrb_value
mrb_obj_frozen(mrb_state *mrb, mrb_value self)
{
- return mrb_bool_value(mrb_immediate_p(self) || MRB_FROZEN_P(mrb_basic_ptr(self)));
+ return mrb_bool_value(mrb_immediate_p(self) || mrb_frozen_p(mrb_basic_ptr(self)));
}
/* 15.3.1.3.15 */

MODIFY
src/string.c
src/string.c
@@ -535,7 +535,7 @@ str_make_shared(mrb_state *mrb, struct RString *orig, struct RString *s)
else if (RSTR_FSHARED_P(orig)) {
str_init_fshared(orig, s, orig->as.heap.aux.fshared);
}
- else if (MRB_FROZEN_P(orig) && !RSTR_POOL_P(orig)) {
+ else if (mrb_frozen_p(orig) && !RSTR_POOL_P(orig)) {
str_init_fshared(orig, s, orig);
}
else {
@@ -2405,7 +2405,7 @@ mrb_string_value_cstr(mrb_state *mrb, mrb_value *ptr)
if (p[len] == '\0') {
return p;
}
- if (MRB_FROZEN_P(ps) || RSTR_CAPA(ps) == len) {
+ if (mrb_frozen_p(ps) || RSTR_CAPA(ps) == len) {
ps = str_new(mrb, NULL, len+1);
memcpy(RSTR_PTR(ps), p, len);
RSTR_SET_LEN(ps, len);

Add a macro `mrb_frozen_p` that points to `MRB_FROZEN_P`.