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); }
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)); } }
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; }