?????? Ruby ?У?????????????????????????????????????????????????飩???????????飬?????????????????ν??????????????????????????Ruby ???????????Щ?????????
??????????? Ruby ???????? A?? B?? C ??????飬C ???? A ?? B??
????A = Module.new
????B = Module.new
????module C
????include A?? B    # Inclusion is done by this line
????end
????????? C ?У???? include A?? B ????????????????????????? A?? B ?????????????????????????? C ?? include ????????ж?????????
???????????????????? include ??????????????????? Module#include?????? API ??????????????????????????? append_features ??????????? C ??????
rb_mod_include??
static VALUE
rb_mod_include(int argc?? VALUE *argv?? VALUE module)
{
int i;
ID id_append_features?? id_included;
CONST_ID(id_append_features?? "append_features");
CONST_ID(id_included?? "included");
for (i = 0; i < argc; i++)
Check_Type(argv[i]?? T_MODULE);
while (argc--) {
rb_funcall(argv[argc]?? id_append_features?? 1?? module);
rb_funcall(argv[argc]?? id_included?? 1?? module);
}
return module;
}
?????? Ruby ??????????????????????? append_features ?????????????????? included ???????????????????ò????????????????и????
????append_features ?? included ?????????????? append_features ????????????????????Ruby ???????????????????????????????????????????????????????????????????????????????????????????????????????????? include ???????????????????????? append_features ??????
???????????? append_features ???????? Module#append_features ???????????????? API ?????????????
rb_mod_append_features(VALUE module?? VALUE include)
{
switch (TYPE(include)) {
case T_CLASS:
case T_MODULE:
break;
default:
Check_Type(include?? T_CLASS);
break;
}
rb_include_module(include?? module);
return module;
}