[macruby-changes] [542] MacRuby/trunk

source_changes at macosforge.org source_changes at macosforge.org
Mon Sep 1 14:08:39 PDT 2008


Revision: 542
          http://trac.macosforge.org/projects/ruby/changeset/542
Author:   lsansonetti at apple.com
Date:     2008-09-01 14:08:39 -0700 (Mon, 01 Sep 2008)
Log Message:
-----------
fix for #120

Modified Paths:
--------------
    MacRuby/trunk/test/ruby/test_objc.rb
    MacRuby/trunk/vm_insnhelper.c

Modified: MacRuby/trunk/test/ruby/test_objc.rb
===================================================================
--- MacRuby/trunk/test/ruby/test_objc.rb	2008-09-01 21:08:22 UTC (rev 541)
+++ MacRuby/trunk/test/ruby/test_objc.rb	2008-09-01 21:08:39 UTC (rev 542)
@@ -372,9 +372,13 @@
     assert(o.respond_to?(:foo=))
     assert(o.respond_to?(:setFoo))
     o.setFoo(42)
-    assert(42, o.foo)
-    o.performSelector('setFoo:', withObject:42)
-    assert(42, o.foo)
+    assert_equal(42, o.foo)
+    assert_equal(nil, o.performSelector('setFoo:', withObject:42))
+    assert_equal(42, o.foo)
+    assert_equal(nil, o.send('setFoo', 42))
+    assert_equal(42, o.foo)
+    assert_equal(nil, o.send('setFoo:', 42))
+    assert_equal(42, o.foo)
   end
 
   def test_respond_to_objc_methods

Modified: MacRuby/trunk/vm_insnhelper.c
===================================================================
--- MacRuby/trunk/vm_insnhelper.c	2008-09-01 21:08:22 UTC (rev 541)
+++ MacRuby/trunk/vm_insnhelper.c	2008-09-01 21:08:39 UTC (rev 542)
@@ -495,17 +495,20 @@
 	if (node->nd_cfnc == rb_f_send) {
 	    int i = *num - 1;
 	    VALUE sym = TOPN(i);
-	    *id = SYMBOL_P(sym) ? SYM2ID(sym) : rb_to_id(sym);
+	    ID new_id = SYMBOL_P(sym) ? SYM2ID(sym) : rb_to_id(sym);
+	    NODE *new_node = rb_method_node(klass, new_id);
+	    if (new_node != NULL) {
+		/* shift arguments */
+		if (i > 0) {
+		    MEMMOVE(&TOPN(i), &TOPN(i-1), VALUE, i);
+		}
 
-	    /* shift arguments */
-	    if (i > 0) {
-		MEMMOVE(&TOPN(i), &TOPN(i-1), VALUE, i);
+		*mn = new_node;
+		*id = new_id;
+		*num -= 1;
+		DEC_SP(1);
+		*flag |= VM_CALL_FCALL_BIT;
 	    }
-
-	    *mn = rb_method_node(klass, *id);
-	    *num -= 1;
-	    DEC_SP(1);
-	    *flag |= VM_CALL_FCALL_BIT;
 	}
     }
 }
@@ -695,7 +698,7 @@
 rcall_dispatch:
 
     if (flag & VM_CALL_SEND_BIT) {
-	vm_send_optimize(cfp, (NODE **)&mn, (rb_num_t *)&flag, (rb_num_t *)&num, (ID *)&id, klass);  
+	vm_send_optimize(cfp, (NODE **)&mn, (rb_num_t *)&flag, (rb_num_t *)&num, (ID *)&id, klass);
     }
 
     DLOG("RCALL", "%c[<%s %p> %s] node=%p cached=%d", class_isMetaClass((Class)klass) ? '+' : '-', class_getName((Class)klass), (void *)recv, (char *)rb_id2name(id), mn, cached);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macruby-changes/attachments/20080901/a18a620a/attachment.html 


More information about the macruby-changes mailing list