mrb_value mrb_class_find_path(mrb_state *mrb, struct RClass *c) { mrb_value outer, path; mrb_sym name; const char *str; mrb_int len; mrb_sym osym = mrb_intern_lit(mrb, "__outer__"); outer = mrb_obj_iv_get(mrb, (struct RObject*)c, osym); if (mrb_nil_p(outer)) return outer; name = find_class_sym(mrb, mrb_class_ptr(outer), c); if (name == 0) return mrb_nil_value(); str = mrb_class_name(mrb, mrb_class_ptr(outer)); path = mrb_str_new_capa(mrb, 40); mrb_str_cat_cstr(mrb, path, str); mrb_str_cat_cstr(mrb, path, "::"); str = mrb_sym2name_len(mrb, name, &len); mrb_str_cat(mrb, path, str, len); iv_del(mrb, c->iv, osym, NULL); iv_put(mrb, c->iv, mrb_intern_lit(mrb, "__classname__"), path); mrb_field_write_barrier_value(mrb, (struct RBasic*)c, path); return path; }
mrb_value mrb_class_find_path(mrb_state *mrb, struct RClass *c) { struct RClass *outer; mrb_value path; mrb_sym name; const char *str; mrb_int len; if (detect_outer_loop(mrb, c)) return mrb_nil_value(); outer = outer_class(mrb, c); if (outer == NULL) return mrb_nil_value(); name = find_class_sym(mrb, outer, c); if (name == 0) return mrb_nil_value(); str = mrb_class_name(mrb, outer); path = mrb_str_new_capa(mrb, 40); mrb_str_cat_cstr(mrb, path, str); mrb_str_cat_cstr(mrb, path, "::"); str = mrb_sym2name_len(mrb, name, &len); mrb_str_cat(mrb, path, str, len); if (RSTRING_PTR(path)[0] != '#') { 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); } return path; }
MRB_API void mrb_gv_remove(mrb_state *mrb, mrb_sym sym) { if (!mrb->globals) { return; } iv_del(mrb, mrb->globals, sym, NULL); }
mrb_value mrb_iv_remove(mrb_state *mrb, mrb_value obj, mrb_sym sym) { if (obj_iv_p(obj)) { iv_tbl *t = mrb_obj_ptr(obj)->iv; mrb_value val; if (t && iv_del(mrb, t, sym, &val)) { return val; } } return mrb_undef_value(); }
MRB_API void mrb_gv_remove(mrb_state *mrb, mrb_sym sym) { iv_del(mrb, mrb->globals, sym, NULL); }