class.c: ensure_includable
* class.c (ensure_includable): extract checks to include and prepend. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58082 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
0d0eefd9c6
commit
19a1f70364
16
class.c
16
class.c
@ -849,14 +849,20 @@ rb_include_class_new(VALUE module, VALUE super)
|
|||||||
|
|
||||||
static int include_modules_at(const VALUE klass, VALUE c, VALUE module, int search_super);
|
static int include_modules_at(const VALUE klass, VALUE c, VALUE module, int search_super);
|
||||||
|
|
||||||
|
static void
|
||||||
|
ensure_includable(VALUE klass, VALUE module)
|
||||||
|
{
|
||||||
|
rb_frozen_class_p(klass);
|
||||||
|
Check_Type(module, T_MODULE);
|
||||||
|
OBJ_INFECT(klass, module);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
rb_include_module(VALUE klass, VALUE module)
|
rb_include_module(VALUE klass, VALUE module)
|
||||||
{
|
{
|
||||||
int changed = 0;
|
int changed = 0;
|
||||||
|
|
||||||
rb_frozen_class_p(klass);
|
ensure_includable(klass, module);
|
||||||
Check_Type(module, T_MODULE);
|
|
||||||
OBJ_INFECT(klass, module);
|
|
||||||
|
|
||||||
changed = include_modules_at(klass, RCLASS_ORIGIN(klass), module, TRUE);
|
changed = include_modules_at(klass, RCLASS_ORIGIN(klass), module, TRUE);
|
||||||
if (changed < 0)
|
if (changed < 0)
|
||||||
@ -966,9 +972,7 @@ rb_prepend_module(VALUE klass, VALUE module)
|
|||||||
VALUE origin;
|
VALUE origin;
|
||||||
int changed = 0;
|
int changed = 0;
|
||||||
|
|
||||||
rb_frozen_class_p(klass);
|
ensure_includable(klass, module);
|
||||||
Check_Type(module, T_MODULE);
|
|
||||||
OBJ_INFECT(klass, module);
|
|
||||||
|
|
||||||
origin = RCLASS_ORIGIN(klass);
|
origin = RCLASS_ORIGIN(klass);
|
||||||
if (origin == klass) {
|
if (origin == klass) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user