Add MRB_IMPROVE_META_PROGRAMMING configuration

This commit is contained in:
dearblue
2018-09-07 22:00:18 +09:00
parent 9b0ef58a48
commit 1997fcf98f
2 changed files with 13 additions and 0 deletions
+3
View File
@@ -110,6 +110,9 @@
/* fixed size state atexit stack */
//#define MRB_FIXED_STATE_ATEXIT_STACK
/* improve meta programming support */
//#define MRB_IMPROVE_META_PROGRAMMING
/* -DMRB_DISABLE_XXXX to drop following features */
//#define MRB_DISABLE_STDIO /* use of stdio */
+10
View File
@@ -344,7 +344,9 @@ mrb_iv_get(mrb_state *mrb, mrb_value obj, mrb_sym sym)
return mrb_nil_value();
}
#ifdef MRB_IMPROVE_META_PROGRAMMING
static inline void assign_class_name(mrb_state *mrb, struct RObject *obj, mrb_sym sym, mrb_value v);
#endif
MRB_API void
mrb_obj_iv_set(mrb_state *mrb, struct RObject *obj, mrb_sym sym, mrb_value v)
@@ -354,7 +356,9 @@ mrb_obj_iv_set(mrb_state *mrb, struct RObject *obj, mrb_sym sym, mrb_value v)
if (MRB_FROZEN_P(obj)) {
mrb_raisef(mrb, E_FROZEN_ERROR, "can't modify frozen %S", mrb_obj_value(obj));
}
#ifdef MRB_IMPROVE_META_PROGRAMMING
assign_class_name(mrb, obj, sym, v);
#endif
if (!obj->iv) {
obj->iv = iv_new(mrb);
}
@@ -363,6 +367,7 @@ mrb_obj_iv_set(mrb_state *mrb, struct RObject *obj, mrb_sym sym, mrb_value v)
mrb_write_barrier(mrb, (struct RBasic*)obj);
}
#ifdef MRB_IMPROVE_META_PROGRAMMING
static inline mrb_bool
is_namespace(enum mrb_vtype tt)
{
@@ -392,6 +397,7 @@ assign_class_name(mrb_state *mrb, struct RObject *obj, mrb_sym sym, mrb_value v)
}
}
}
#endif
MRB_API void
mrb_iv_set(mrb_state *mrb, mrb_value obj, mrb_sym sym, mrb_value v)
@@ -1102,10 +1108,14 @@ mrb_class_find_path(mrb_state *mrb, struct RClass *c)
str = mrb_sym2name_len(mrb, name, &len);
mrb_str_cat(mrb, path, str, len);
#ifdef MRB_IMPROVE_META_PROGRAMMING
if (RSTRING_PTR(path)[0] != '#') {
#endif
iv_del(mrb, c->iv, mrb_intern_lit(mrb, "__outer__"), NULL);
iv_put(mrb, c->iv, mrb_intern_lit(mrb, "__classname__"), path);
mrb_field_write_barrier_value(mrb, (struct RBasic*)c, path);
#ifdef MRB_IMPROVE_META_PROGRAMMING
}
#endif
return path;
}