[macruby-changes] [2975] MacRuby/trunk/object.c
source_changes at macosforge.org
source_changes at macosforge.org
Fri Nov 6 19:41:51 PST 2009
Revision: 2975
http://trac.macosforge.org/projects/ruby/changeset/2975
Author: lsansonetti at apple.com
Date: 2009-11-06 19:41:48 -0800 (Fri, 06 Nov 2009)
Log Message:
-----------
Module#<=: fixed to honor included modules
Modified Paths:
--------------
MacRuby/trunk/object.c
Modified: MacRuby/trunk/object.c
===================================================================
--- MacRuby/trunk/object.c 2009-11-07 03:11:14 UTC (rev 2974)
+++ MacRuby/trunk/object.c 2009-11-07 03:41:48 UTC (rev 2975)
@@ -1574,28 +1574,46 @@
*
*/
+static inline bool
+rb_class_mixin_inherited(VALUE mod, VALUE arg)
+{
+ VALUE ary = rb_attr_get(mod, idIncludedModules);
+ if (ary != Qnil) {
+ for (int i = 0; i < RARRAY_LEN(ary); i++) {
+ if (RARRAY_AT(ary, i) == arg) {
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
VALUE
rb_class_inherited_p(VALUE mod, VALUE arg)
{
VALUE start = mod;
- if (mod == arg) return Qtrue;
+ if (mod == arg) {
+ return Qtrue;
+ }
switch (TYPE(arg)) {
- case T_MODULE:
- case T_CLASS:
- break;
- default:
- rb_raise(rb_eTypeError, "compared with non class/module");
+ case T_MODULE:
+ case T_CLASS:
+ break;
+ default:
+ rb_raise(rb_eTypeError, "compared with non class/module");
}
while (mod) {
- if (mod == arg)
+ if (mod == arg || rb_class_mixin_inherited(mod, arg)) {
return Qtrue;
+ }
mod = RCLASS_SUPER(mod);
}
/* not mod < arg; check if mod > arg */
while (arg) {
- if (arg == start)
+ if (arg == start || rb_class_mixin_inherited(arg, start)) {
return Qfalse;
+ }
arg = RCLASS_SUPER(arg);
}
return Qnil;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20091106/8ce0dbcb/attachment-0001.html>
More information about the macruby-changes
mailing list