[macruby-changes] [4381] MacRuby/trunk

source_changes at macosforge.org source_changes at macosforge.org
Sat Jul 24 20:14:10 PDT 2010


Revision: 4381
          http://trac.macosforge.org/projects/ruby/changeset/4381
Author:   lsansonetti at apple.com
Date:     2010-07-24 20:14:06 -0700 (Sat, 24 Jul 2010)
Log Message:
-----------
a better fix for ignored selectors, which handle the case where they are unique pointers

Modified Paths:
--------------
    MacRuby/trunk/compiler.cpp
    MacRuby/trunk/objc.h
    MacRuby/trunk/objc.m
    MacRuby/trunk/vm.cpp
    MacRuby/trunk/vm.h

Modified: MacRuby/trunk/compiler.cpp
===================================================================
--- MacRuby/trunk/compiler.cpp	2010-07-25 00:55:44 UTC (rev 4380)
+++ MacRuby/trunk/compiler.cpp	2010-07-25 03:14:06 UTC (rev 4381)
@@ -323,13 +323,17 @@
 {
     SEL sel;
     const char *mid_str = rb_id2name(mid);
+    char buf[100];
     if (mid_str[strlen(mid_str) - 1] != ':' && arity > 0) {
-	char buf[100];
 	snprintf(buf, sizeof buf, "%s:", mid_str);
 	sel = sel_registerName(buf);
     }
     else {
 	sel = sel_registerName(mid_str);
+	if (rb_objc_ignored_sel(sel)) {
+	    snprintf(buf, sizeof buf, "__hidden__%s", mid_str);
+	    sel = sel_registerName(buf);
+	}
     }
     return sel;
 }
@@ -2257,7 +2261,6 @@
 	    return NULL;
 	}
 	SEL new_sel = mid_to_sel(SYM2ID(sym), argc - 1);
-	new_sel = rb_objc_ignored_sel(new_sel);
 
 	GlobalVariable *is_redefined = GET_CORE()->redefined_op_gvar(sel, true);
 
@@ -2975,7 +2978,6 @@
     SEL sel;
     if (mid != 0) {
 	sel = mid_to_sel(mid, positive_arity ? 1 : 0);
-	sel = rb_objc_ignored_sel(sel);
 	sel_val = compile_sel(sel);
 	if (block_declaration && super_call) {
 	    // A super call inside a block. The selector cannot

Modified: MacRuby/trunk/objc.h
===================================================================
--- MacRuby/trunk/objc.h	2010-07-25 00:55:44 UTC (rev 4380)
+++ MacRuby/trunk/objc.h	2010-07-25 03:14:06 UTC (rev 4381)
@@ -216,7 +216,7 @@
 
 void rb_objc_exception_raise(const char *name, const char *message);
 
-SEL rb_objc_ignored_sel(SEL sel);
+bool rb_objc_ignored_sel(SEL sel);
 bool rb_objc_isEqual(VALUE x, VALUE y); 
 void rb_objc_force_class_initialize(Class klass);
 void rb_objc_fix_relocatable_load_path(void);

Modified: MacRuby/trunk/objc.m
===================================================================
--- MacRuby/trunk/objc.m	2010-07-25 00:55:44 UTC (rev 4380)
+++ MacRuby/trunk/objc.m	2010-07-25 03:14:06 UTC (rev 4381)
@@ -639,25 +639,14 @@
     return (VALUE)obj;
 }
 
-SEL
+bool
 rb_objc_ignored_sel(SEL sel)
 {
-    if (sel == @selector(retain)) {
-	return @selector(__hidden__retain);
-    }
-    if (sel == @selector(release)) {
-	return @selector(__hidden__release);
-    }
-    if (sel == @selector(autorelease)) {
-	return @selector(__hidden__autorelease);
-    }
-    if (sel == @selector(retainCount)) {
-	return @selector(__hidden__retainCount);
-    }
-    if (sel == @selector(dealloc)) {
-	return @selector(__hidden__dealloc);
-    }
-    return sel;
+    return sel == @selector(retain)
+	|| sel == @selector(release)
+	|| sel == @selector(autorelease)
+	|| sel == @selector(retainCount)
+	|| sel == @selector(dealloc);
 }
 
 bool

Modified: MacRuby/trunk/vm.cpp
===================================================================
--- MacRuby/trunk/vm.cpp	2010-07-25 00:55:44 UTC (rev 4380)
+++ MacRuby/trunk/vm.cpp	2010-07-25 03:14:06 UTC (rev 4381)
@@ -1996,7 +1996,9 @@
 	flags |= VM_METHOD_PROTECTED;
     }
 
-    sel = rb_objc_ignored_sel(sel);
+    if (rb_objc_ignored_sel(sel)) {
+	return;
+    }
 
     const char *sel_name = sel_getName(sel);
     const bool genuine_selector = sel_name[strlen(sel_name) - 1] == ':';
@@ -2149,7 +2151,7 @@
 static void
 push_method(VALUE ary, SEL sel, int flags, int (*filter) (VALUE, ID, VALUE))
 {
-    if (rb_objc_ignored_sel(sel) != sel) {
+    if (rb_objc_ignored_sel(sel)) {
 	return; 
     }
 
@@ -2485,7 +2487,9 @@
 {
     assert(klass != NULL);
 
-    sel = rb_objc_ignored_sel(sel);
+    if (rb_objc_ignored_sel(sel)) {
+	return NULL;
+    }
 
     const char *sel_name = sel_getName(sel);
     const bool genuine_selector = sel_name[strlen(sel_name) - 1] == ':';

Modified: MacRuby/trunk/vm.h
===================================================================
--- MacRuby/trunk/vm.h	2010-07-25 00:55:44 UTC (rev 4380)
+++ MacRuby/trunk/vm.h	2010-07-25 03:14:06 UTC (rev 4381)
@@ -596,12 +596,9 @@
 	    argc, argv);
 }
 
-SEL rb_objc_ignored_sel(SEL);
-
 static inline VALUE
 rb_vm_call(VALUE self, SEL sel, int argc, const VALUE *argv)
 {
-    sel = rb_objc_ignored_sel(sel);
     return rb_vm_call0(rb_vm_current_vm(), 0, self, (Class)CLASS_OF(self), sel,
 	    NULL, DISPATCH_FCALL, argc, argv);
 }
@@ -609,7 +606,6 @@
 static inline VALUE
 rb_vm_call_super(VALUE self, SEL sel, int argc, const VALUE *argv)
 {
-    sel = rb_objc_ignored_sel(sel);
     return rb_vm_call0(rb_vm_current_vm(), 0, self, (Class)CLASS_OF(self), sel,
 	    NULL, DISPATCH_SUPER, argc, argv);
 }
@@ -621,7 +617,6 @@
     if (klass == 0) {
 	klass = CLASS_OF(self);
     }
-    sel = rb_objc_ignored_sel(sel);
     return rb_vm_call0(rb_vm_current_vm(), 0, self, (Class)klass, sel, block,
 	    DISPATCH_FCALL, argc, argv);
 }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20100724/82a4cef3/attachment-0001.html>


More information about the macruby-changes mailing list