Skip to content
Browse files

a better fix for ignored selectors, which handle the case where they …

…are unique pointers

git-svn-id: http://svn.macosforge.org/repository/ruby/MacRuby/trunk@4381 23306eb0-4c56-4727-a40e-e92c0eb68959
  • Loading branch information...
1 parent 87a2df1 commit d40a42f689b1f2208a666d95c6929e84f2b05abe Laurent Sansonetti committed Jul 25, 2010
Showing with 19 additions and 29 deletions.
  1. +5 −3 compiler.cpp
  2. +1 −1 objc.h
  3. +6 −17 objc.m
  4. +7 −3 vm.cpp
  5. +0 −5 vm.h
View
8 compiler.cpp
@@ -323,13 +323,17 @@ RoxorCompiler::mid_to_sel(ID mid, int arity)
{
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 @@ RoxorCompiler::compile_optimized_dispatch_call(SEL sel, int argc,
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 @@ RoxorCompiler::compile_call(NODE *node)
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
View
2 objc.h
@@ -216,7 +216,7 @@ rb_ocid_to_rval(id obj)
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);
View
23 objc.m
@@ -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
View
10 vm.cpp
@@ -1996,7 +1996,9 @@ prepare_method(Class klass, bool dynamic_class, SEL sel, void *data,
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 @@ rb_vm_prepare_method2(Class klass, unsigned char dynamic_class, SEL sel,
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 @@ __rb_vm_define_method(Class klass, SEL sel, IMP objc_imp, IMP ruby_imp,
{
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] == ':';
View
5 vm.h
@@ -596,20 +596,16 @@ rb_vm_call0(void *vm, VALUE top, VALUE self, Class klass, SEL sel,
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);
}
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 @@ rb_vm_call2(rb_vm_block_t *block, VALUE self, VALUE klass, SEL sel, int argc,
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);
}

0 comments on commit d40a42f

Please sign in to comment.
Something went wrong with that request. Please try again.