Permalink
Browse files

overwrite -[NSObject description] in every new subclass + optimized o…

…ther overloaded methods

git-svn-id: http://svn.macosforge.org/repository/ruby/MacRuby/branches/experimental@2132 23306eb0-4c56-4727-a40e-e92c0eb68959
  • Loading branch information...
1 parent 808073f commit a3ff57f45fc961db2b3450fcc95bc4e4973f3d03 @lrz lrz committed Aug 2, 2009
Showing with 14 additions and 2 deletions.
  1. +10 −2 class.c
  2. +2 −0 id.c
  3. +2 −0 id.h
View
12 class.c
@@ -75,16 +75,23 @@ rb_obj_imp_isEqual(void *rcv, SEL sel, void *obj)
return RFIXNUM(rcv)->value == RFIXNUM(obj)->value;
}
- return rb_funcall((VALUE)rcv, idEq, 1, OC2RB(obj)) == Qtrue;
+ VALUE arg = OC2RB(obj);
+ return rb_vm_call((VALUE)rcv, selEq, 1, &arg, false) == Qtrue;
}
static void *
rb_obj_imp_init(void *rcv, SEL sel)
{
- rb_funcall((VALUE)rcv, idInitialize, 0);
+ rb_vm_call((VALUE)rcv, selInitialize, 0, NULL, false);
return rcv;
}
+static void *
+rb_obj_imp_description(void *rcv, SEL sel)
+{
+ return (void *)rb_vm_call((VALUE)rcv, selToS, 0, NULL, false);
+}
+
static VALUE
rb_objc_init(VALUE rcv, SEL sel)
{
@@ -117,6 +124,7 @@ rb_define_object_special_methods(VALUE klass)
(IMP)rb_obj_imp_allocWithZone);
rb_objc_install_method((Class)klass, selIsEqual, (IMP)rb_obj_imp_isEqual);
rb_objc_install_method((Class)klass, selInit, (IMP)rb_obj_imp_init);
+ rb_objc_install_method((Class)klass, selDescription, (IMP)rb_obj_imp_description);
}
static VALUE
View
2 id.c
@@ -65,6 +65,8 @@ Init_id(void)
selInit = sel_registerName("init");
selInitialize = sel_registerName("initialize");
selInitialize2 = sel_registerName("initialize:");
+ selDescription = sel_registerName("description");
+ selInspect = sel_registerName("inspect");
selNew = sel_registerName("new");
selRespondTo = sel_registerName("respond_to?:");
selMethodMissing = sel_registerName("method_missing:");
View
2 id.h
@@ -75,6 +75,8 @@ extern SEL selAllocWithZone;
extern SEL selInit;
extern SEL selInitialize;
extern SEL selInitialize2;
+extern SEL selDescription;
+extern SEL selInspect;
extern SEL selNew;
extern SEL selRespondTo;
extern SEL selMethodMissing;

0 comments on commit a3ff57f

Please sign in to comment.