[macruby-changes] [813] MacRuby/trunk

source_changes at macosforge.org source_changes at macosforge.org
Fri Feb 13 16:56:22 PST 2009


Revision: 813
          http://trac.macosforge.org/projects/ruby/changeset/813
Author:   lsansonetti at apple.com
Date:     2009-02-13 16:56:22 -0800 (Fri, 13 Feb 2009)
Log Message:
-----------
make sure the primitive methods are added when creating the singleton class of a CF string/array/hash

Modified Paths:
--------------
    MacRuby/trunk/class.c
    MacRuby/trunk/test/ruby/test_array.rb

Modified: MacRuby/trunk/class.c
===================================================================
--- MacRuby/trunk/class.c	2009-02-12 19:06:06 UTC (rev 812)
+++ MacRuby/trunk/class.c	2009-02-14 00:56:22 UTC (rev 813)
@@ -173,7 +173,17 @@
 rb_objc_create_class(const char *name, VALUE super)
 {
     VALUE klass;
-    
+
+    if (super == rb_cCFString) {
+	super = rb_cNSMutableString;
+    }
+    else if (super == rb_cCFArray) {
+	super = rb_cNSMutableArray;
+    }
+    else if (super == rb_cCFHash) {
+	super = rb_cNSMutableHash;
+    }
+
     klass = rb_objc_alloc_class(name, super, T_CLASS, rb_cClass);
     objc_registerClassPair((Class)klass);
    

Modified: MacRuby/trunk/test/ruby/test_array.rb
===================================================================
--- MacRuby/trunk/test/ruby/test_array.rb	2009-02-12 19:06:06 UTC (rev 812)
+++ MacRuby/trunk/test/ruby/test_array.rb	2009-02-14 00:56:22 UTC (rev 813)
@@ -1584,4 +1584,13 @@
   def test_array_subclass
     assert_equal(Array2, Array2[1,2,3].uniq.class, "[ruby-dev:34581]")
   end
+
+  def test_array_singleton_class
+    a = [1,2,3]
+    def a.foo; 42; end
+    assert_equal(42, a.foo)
+    assert_equal([1,2,3], a)
+    a.replace([4,5,6])
+    assert_equal([4,5,6], a)
+  end
 end
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090213/381ea82b/attachment.html>


More information about the macruby-changes mailing list