extracted declare_under
This commit is contained in:
parent
8dc5fe6e89
commit
42edb05626
@ -3548,15 +3548,20 @@ vm_check_if_module(ID id, VALUE mod)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static VALUE
|
||||||
|
declare_under(ID id, VALUE cbase, VALUE c)
|
||||||
|
{
|
||||||
|
rb_set_class_path_string(c, cbase, rb_id2str(id));
|
||||||
|
rb_const_set(cbase, id, c);
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
vm_declare_class(ID id, rb_num_t flags, VALUE cbase, VALUE super)
|
vm_declare_class(ID id, rb_num_t flags, VALUE cbase, VALUE super)
|
||||||
{
|
{
|
||||||
/* new class declaration */
|
/* new class declaration */
|
||||||
VALUE s = VM_DEFINECLASS_HAS_SUPERCLASS_P(flags) ? super : rb_cObject;
|
VALUE s = VM_DEFINECLASS_HAS_SUPERCLASS_P(flags) ? super : rb_cObject;
|
||||||
VALUE c = rb_define_class_id(id, s);
|
VALUE c = declare_under(id, cbase, rb_define_class_id(id, s));
|
||||||
|
|
||||||
rb_set_class_path_string(c, cbase, rb_id2str(id));
|
|
||||||
rb_const_set(cbase, id, c);
|
|
||||||
rb_class_inherited(s, c);
|
rb_class_inherited(s, c);
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
@ -3565,10 +3570,7 @@ static VALUE
|
|||||||
vm_declare_module(ID id, VALUE cbase)
|
vm_declare_module(ID id, VALUE cbase)
|
||||||
{
|
{
|
||||||
/* new module declaration */
|
/* new module declaration */
|
||||||
VALUE mod = rb_define_module_id(id);
|
return declare_under(id, cbase, rb_define_module_id(id));
|
||||||
rb_set_class_path_string(mod, cbase, rb_id2str(id));
|
|
||||||
rb_const_set(cbase, id, mod);
|
|
||||||
return mod;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NORETURN(static void unmatched_redefinition(const char *type, VALUE cbase, ID id, VALUE old));
|
NORETURN(static void unmatched_redefinition(const char *type, VALUE cbase, ID id, VALUE old));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user