Exemplo n.º 1
0
static VALUE rb_mixin(VALUE self, VALUE module)
{
    VALUE nested_modules;
    int index;

    /* check that module is valid */
    if (TYPE(module) != T_MODULE)
        rb_raise(rb_eArgError, "error: parameter must be a module");

    rb_unmix(self, module);
    nested_modules = rb_mod_included_modules(module);

    for (index = RARRAY_LEN(nested_modules); index > 0; index--) {
        VALUE nested_module = RARRAY_PTR(nested_modules)[index - 1];
        add_module(self, nested_module);
    }

    add_module(self, module);

    rb_clear_cache();

    /* If the module is added, call the mixed_in(obj) hook on
     * the added module */
    rb_funcall(module, rb_intern("mixed_in"), 1, self);

    return self;
}
Exemplo n.º 2
0
Arquivo: class.c Projeto: MSch/MacRuby
static void
rb_mod_included_modules_nosuper(VALUE mod, VALUE ary)
{
    VALUE inc_mods = rb_attr_get(mod, idIncludedModules);
    if (inc_mods != Qnil) {
	int i, count = RARRAY_LEN(inc_mods);
	for (i = 0; i < count; i++) {
	    VALUE imod = RARRAY_AT(inc_mods, i);
	    rb_ary_push(ary, imod);
	    rb_ary_concat(ary, rb_mod_included_modules(imod));
	}
    }
}
Exemplo n.º 3
0
static VALUE included_modules_list(VALUE module)
{
  VALUE included_modules = rb_mod_included_modules(module);
  VALUE included_module_list = rb_ary_new();
  long j;

  for(j = 0; j < RARRAY_LEN(included_modules); ++j)
  {
    rb_ary_push(
        included_module_list,
        rb_mod_name(RARRAY_PTR(included_modules)[j]));
  }

  return included_module_list;
}
Exemplo n.º 4
0
Arquivo: class.c Projeto: MSch/MacRuby
VALUE
rb_mod_include_p(VALUE mod, SEL sel, VALUE mod2)
{
    return rb_ary_includes(rb_mod_included_modules(mod), mod2);
}
Exemplo n.º 5
0
VALUE
rb_mod_include_p(VALUE mod, SEL sel, VALUE mod2)
{
    Check_Type(mod2, T_MODULE);
    return rb_ary_includes(rb_mod_included_modules(mod), mod2);
}