[macruby-changes] [2991] MacRuby/trunk/dispatcher.cpp

source_changes at macosforge.org source_changes at macosforge.org
Tue Nov 10 21:48:03 PST 2009


Revision: 2991
          http://trac.macosforge.org/projects/ruby/changeset/2991
Author:   lsansonetti at apple.com
Date:     2009-11-10 21:48:02 -0800 (Tue, 10 Nov 2009)
Log Message:
-----------
make sure we rubyfy objc-like selectors and box arguments into a Hash before calling #method_missing

Modified Paths:
--------------
    MacRuby/trunk/dispatcher.cpp

Modified: MacRuby/trunk/dispatcher.cpp
===================================================================
--- MacRuby/trunk/dispatcher.cpp	2009-11-11 05:46:34 UTC (rev 2990)
+++ MacRuby/trunk/dispatcher.cpp	2009-11-11 05:48:02 UTC (rev 2991)
@@ -612,27 +612,26 @@
 		    char *tmp = (char *)alloca(selname_len);
 		    strncpy(tmp, selname, p - selname + 1);
 		    tmp[p - selname + 1] = '\0';
-		    SEL new_sel = sel_registerName(tmp);
-		    Method m = class_getInstanceMethod(klass, new_sel);
-		    if (m != NULL) {
-			VALUE h = rb_hash_new();
-			bool ok = true;
-			p += 1;
-			for (int i = 1; i < argc; i++) {
-			    const char *p2 = strchr(p, ':');
-			    if (p2 == NULL) {
-				ok = false;
-				break;
-			    }
-			    strlcpy(tmp, p, selname_len);
-			    tmp[p2 - p] = '\0';
-			    p = p2 + 1; 
-			    rb_hash_aset(h, ID2SYM(rb_intern(tmp)), argv[i]);
+		    sel = sel_registerName(tmp);
+		    VALUE h = rb_hash_new();
+		    bool ok = true;
+		    p += 1;
+		    for (int i = 1; i < argc; i++) {
+			const char *p2 = strchr(p, ':');
+			if (p2 == NULL) {
+			    ok = false;
+			    break;
 			}
-			if (ok) {
-			    argc = 2;
-			    ((VALUE *)argv)[1] = h; // bad, I know...
-			    sel = new_sel;
+			strlcpy(tmp, p, selname_len);
+			tmp[p2 - p] = '\0';
+			p = p2 + 1; 
+			rb_hash_aset(h, ID2SYM(rb_intern(tmp)), argv[i]);
+		    }
+		    if (ok) {
+			argc = 2;
+			((VALUE *)argv)[1] = h; // bad, I know...
+			Method m = class_getInstanceMethod(klass, sel);
+			if (m != NULL) {	
 			    method = m;
 			    do_rcache = false;
 			    goto recache2;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20091110/9fb24b1a/attachment.html>


More information about the macruby-changes mailing list