Revision
3186
Author
lsansonetti@apple.com
Date
2010-01-04 14:42:37 -0800 (Mon, 04 Jan 2010)

Log Message

#extend_object: honor nested modules

Modified Paths

Diff

Modified: MacRuby/trunk/eval.c (3185 => 3186)


--- MacRuby/trunk/eval.c	2010-01-04 22:17:59 UTC (rev 3185)
+++ MacRuby/trunk/eval.c	2010-01-04 22:42:37 UTC (rev 3186)
@@ -582,8 +582,22 @@
     }
     else {
 	klass = rb_singleton_class(obj);
-    }	
+    }
+
     rb_include_module(klass, module);
+
+    VALUE m = module;
+    do {
+	VALUE ary = rb_attr_get(m, idIncludedModules);
+	if (ary != Qnil) {
+	    for (int i = 0, count = RARRAY_LEN(ary); i < count; i++) {
+		VALUE mod = RARRAY_AT(ary, i);
+		rb_extend_object(obj, mod);
+	    }
+	}
+	m = RCLASS_SUPER(m);
+    }
+    while (m == 0 || RCLASS_SINGLETON(m));
 }
 
 /*