Ruby????????????
???????????? ???????[ 2014/3/20 11:04:23 ] ????????Ruby ??? ????
?????? 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;
}
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11