mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
store :initialize in mrb structure
This commit is contained in:
@@ -238,6 +238,7 @@ typedef struct mrb_state {
|
||||
struct mrb_irep **irep;
|
||||
size_t irep_len, irep_capa;
|
||||
|
||||
mrb_sym init_sym;
|
||||
struct RClass *object_class;
|
||||
struct RClass *class_class;
|
||||
struct RClass *module_class;
|
||||
|
||||
+3
-3
@@ -921,7 +921,7 @@ mrb_funcall(mrb_state *mrb, mrb_value self, const char *name, int argc, ...)
|
||||
void
|
||||
mrb_obj_call_init(mrb_state *mrb, mrb_value obj, int argc, mrb_value *argv)
|
||||
{
|
||||
mrb_funcall_argv(mrb, obj, mrb_intern(mrb, "initialize"), argc, argv);
|
||||
mrb_funcall_argv(mrb, obj, mrb->init_sym, argc, argv);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -960,7 +960,7 @@ mrb_class_new_instance_m(mrb_state *mrb, mrb_value klass)
|
||||
c = (struct RClass*)mrb_obj_alloc(mrb, k->tt, k);
|
||||
c->super = k;
|
||||
obj = mrb_obj_value(c);
|
||||
mrb_funcall_with_block(mrb, obj, mrb_intern(mrb, "initialize"), argc, argv, blk);
|
||||
mrb_funcall_with_block(mrb, obj, mrb->init_sym, argc, argv, blk);
|
||||
|
||||
return obj;
|
||||
}
|
||||
@@ -979,7 +979,7 @@ mrb_instance_new(mrb_state *mrb, mrb_value cv)
|
||||
o = (struct RObject*)mrb_obj_alloc(mrb, ttype, c);
|
||||
obj = mrb_obj_value(o);
|
||||
mrb_get_args(mrb, "*&", &argv, &argc, &blk);
|
||||
mrb_funcall_with_block(mrb, obj, mrb_intern(mrb, "initialize"), argc, argv, blk);
|
||||
mrb_funcall_with_block(mrb, obj, mrb->init_sym, argc, argv, blk);
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
@@ -404,4 +404,5 @@ mrb_init_symbol(mrb_state *mrb)
|
||||
mrb_define_method(mrb, sym, "to_sym", sym_to_sym, ARGS_NONE()); /* 15.2.11.3.4 */
|
||||
mrb_define_method(mrb, sym, "inspect", sym_inspect, ARGS_NONE()); /* 15.2.11.3.5(x) */
|
||||
mrb_define_method(mrb, sym, "<=>", sym_cmp, ARGS_REQ(1));
|
||||
mrb->init_sym = mrb_intern(mrb, "initialize");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user