Exemple #1
0
static VALUE
rb_obj_superclass(VALUE klass, SEL sel)
{
    VALUE cl = RCLASS_SUPER(klass);
    while (rb_class_hidden(cl)) {
	cl = RCLASS_SUPER(cl);
    }
    return rb_class_real(cl, true);
}
Exemple #2
0
static void
check_class_super(ID id, VALUE klass, VALUE super)
{
    VALUE k = klass;
    do {
	k = RCLASS_SUPER(k);
    }
    while (k != 0 && rb_class_hidden(k));

    if (rb_class_real(k, true) != super) {
	rb_name_error(id, "%s is already defined", rb_id2name(id));
    }
}
Exemple #3
0
VALUE
rb_mod_ancestors(VALUE mod)
{
    // This method should return a new array without classes that should be
    // ignored.
    VALUE ary = rb_mod_ancestors_nocopy(mod);
    VALUE filtered = rb_ary_new();
    for (int i = 0, count = RARRAY_LEN(ary); i < count; i++) {
	VALUE p = RARRAY_AT(ary, i);
	if (!rb_class_hidden(p)) {
	    rb_ary_push(filtered, p);
	}
    }
    return filtered;
}