Use `MRB_SYM()` more extensively.
MODIFY
mrbgems/mruby-binding-core/src/binding-core.c
mrbgems/mruby-binding-core/src/binding-core.c
@@ -220,7 +220,7 @@ cache_source_location:
mrb_value
mrb_binding_alloc(mrb_state *mrb)
{
- struct RObject *obj = (struct RObject*)mrb_obj_alloc(mrb, MRB_TT_OBJECT, mrb_class_get(mrb, "Binding"));
+ struct RObject *obj = (struct RObject*)mrb_obj_alloc(mrb, MRB_TT_OBJECT, mrb_class_get_id(mrb, MRB_SYM(Binding)));
return mrb_obj_value(obj);
}

MODIFY
mrbgems/mruby-complex/src/complex.c
mrbgems/mruby-complex/src/complex.c
@@ -236,7 +236,7 @@ void mrb_mruby_complex_gem_init(mrb_state *mrb)
#ifdef COMPLEX_USE_ISTRUCT
mrb_assert(sizeof(struct mrb_complex) < ISTRUCT_DATA_SIZE);
#endif
- comp = mrb_define_class(mrb, "Complex", mrb_class_get_id(mrb, MRB_SYM(Numeric)));
+ comp = mrb_define_class_id(mrb, MRB_SYM(Complex), mrb_class_get_id(mrb, MRB_SYM(Numeric)));
#ifdef COMPLEX_USE_ISTRUCT
MRB_SET_INSTANCE_TT(comp, MRB_TT_ISTRUCT);
#else

MODIFY
mrbgems/mruby-eval/src/eval.c
mrbgems/mruby-eval/src/eval.c
@@ -28,8 +28,8 @@ create_proc_from_string(mrb_state *mrb, const char *s, mrb_int len, mrb_value bi
if (!mrb_nil_p(binding)) {
mrb_value scope_obj;
- if (!mrb_class_defined(mrb, "Binding")
- || !mrb_obj_is_kind_of(mrb, binding, mrb_class_get(mrb, "Binding"))) {
+ if (!mrb_class_defined_id(mrb, MRB_SYM(Binding))
+ || !mrb_obj_is_kind_of(mrb, binding, mrb_class_get_id(mrb, MRB_SYM(Binding)))) {
mrb_raisef(mrb, E_TYPE_ERROR, "wrong argument type %C (expected binding)",
mrb_obj_class(mrb, binding));
}
@@ -234,7 +234,7 @@ void
mrb_mruby_eval_gem_init(mrb_state* mrb)
{
mrb_define_module_function(mrb, mrb->kernel_module, "eval", f_eval, MRB_ARGS_ARG(1, 3));
- mrb_define_method(mrb, mrb_class_get_id(mrb, MRB_SYM(BasicObject)), "instance_eval", f_instance_eval, MRB_ARGS_OPT(3)|MRB_ARGS_BLOCK());
+ mrb_define_method_id(mrb, mrb_class_get_id(mrb, MRB_SYM(BasicObject)), MRB_SYM(instance_eval), f_instance_eval, MRB_ARGS_OPT(3)|MRB_ARGS_BLOCK());
}
void

MODIFY
mrbgems/mruby-io/include/mruby/ext/io.h
mrbgems/mruby-io/include/mruby/ext/io.h
@@ -59,8 +59,8 @@ struct mrb_io {
#define MRB_O_READABLE_P(f) ((mrb_bool)((((f) & MRB_O_ACCMODE) | 2) == 2))
#define MRB_O_WRITABLE_P(f) ((mrb_bool)(((((f) & MRB_O_ACCMODE) + 1) & 2) == 2))
-#define E_IO_ERROR (mrb_class_get(mrb, "IOError"))
-#define E_EOF_ERROR (mrb_class_get(mrb, "EOFError"))
+#define E_IO_ERROR (mrb_exc_get(mrb, "IOError"))
+#define E_EOF_ERROR (mrb_exc_get(mrb, "EOFError"))
int mrb_io_fileno(mrb_state *mrb, mrb_value io);

MODIFY
mrbgems/mruby-io/src/file.c
mrbgems/mruby-io/src/file.c
@@ -593,7 +593,7 @@ mrb_init_file(mrb_state *mrb)
{
struct RClass *io, *file, *cnst;
- io = mrb_class_get(mrb, "IO");
+ io = mrb_class_get_id(mrb, MRB_SYM(IO));
file = mrb_define_class(mrb, "File", io);
MRB_SET_INSTANCE_TT(file, MRB_TT_DATA);
mrb_define_class_method(mrb, file, "umask", mrb_file_s_umask, MRB_ARGS_OPT(1));

MODIFY
mrbgems/mruby-method/src/method.c
mrbgems/mruby-method/src/method.c
@@ -175,7 +175,7 @@ method_unbind(mrb_state *mrb, mrb_value self)
mrb_value proc = mrb_iv_get(mrb, self, MRB_SYM(_proc));
mrb_value klass = mrb_iv_get(mrb, self, MRB_SYM(_klass));
- ume = method_object_alloc(mrb, mrb_class_get(mrb, "UnboundMethod"));
+ ume = method_object_alloc(mrb, mrb_class_get_id(mrb, MRB_SYM(UnboundMethod)));
mrb_obj_iv_set(mrb, ume, MRB_SYM(_owner), owner);
mrb_obj_iv_set(mrb, ume, MRB_SYM(_recv), mrb_nil_value());
mrb_obj_iv_set(mrb, ume, MRB_SYM(_name), name);
@@ -356,7 +356,7 @@ mrb_kernel_method(mrb_state *mrb, mrb_value self)
mrb_search_method_owner(mrb, mrb_class(mrb, self), self, name, &owner, &proc, FALSE);
- me = method_object_alloc(mrb, mrb_class_get(mrb, "Method"));
+ me = method_object_alloc(mrb, mrb_class_get_id(mrb, MRB_SYM(Method)));
mrb_obj_iv_set(mrb, me, MRB_SYM(_owner), mrb_obj_value(owner));
mrb_obj_iv_set(mrb, me, MRB_SYM(_recv), self);
mrb_obj_iv_set(mrb, me, MRB_SYM(_name), mrb_symbol_value(name));
@@ -378,7 +378,7 @@ mrb_module_instance_method(mrb_state *mrb, mrb_value self)
mrb_search_method_owner(mrb, mrb_class_ptr(self), self, name, &owner, &proc, TRUE);
- ume = method_object_alloc(mrb, mrb_class_get(mrb, "UnboundMethod"));
+ ume = method_object_alloc(mrb, mrb_class_get_id(mrb, MRB_SYM(UnboundMethod)));
mrb_obj_iv_set(mrb, ume, MRB_SYM(_owner), mrb_obj_value(owner));
mrb_obj_iv_set(mrb, ume, MRB_SYM(_recv), mrb_nil_value());
mrb_obj_iv_set(mrb, ume, MRB_SYM(_name), mrb_symbol_value(name));
@@ -409,8 +409,8 @@ method_name(mrb_state *mrb, mrb_value self)
void
mrb_mruby_method_gem_init(mrb_state* mrb)
{
- struct RClass *unbound_method = mrb_define_class(mrb, "UnboundMethod", mrb->object_class);
- struct RClass *method = mrb_define_class(mrb, "Method", mrb->object_class);
+ struct RClass *unbound_method = mrb_define_class_id(mrb, MRB_SYM(UnboundMethod), mrb->object_class);
+ struct RClass *method = mrb_define_class_id(mrb, MRB_SYM(Method), mrb->object_class);
mrb_undef_class_method(mrb, unbound_method, "new");
mrb_define_method(mrb, unbound_method, "bind", unbound_method_bind, MRB_ARGS_REQ(1));

MODIFY
mrbgems/mruby-random/src/random.c
mrbgems/mruby-random/src/random.c
@@ -168,7 +168,7 @@ random_check(mrb_state *mrb, mrb_value random) {
static mrb_value
random_default(mrb_state *mrb) {
- struct RClass *c = mrb_class_get(mrb, "Random");
+ struct RClass *c = mrb_class_get_id(mrb, MRB_SYM(Random));
mrb_value d = mrb_const_get(mrb, mrb_obj_value(c), MRB_SYM(DEFAULT));
if (!mrb_obj_is_kind_of(mrb, d, c)) {
mrb_raise(mrb, E_TYPE_ERROR, "Random::DEFAULT replaced");

Use `MRB_SYM()` more extensively.