[macruby-changes] [2072] MacRuby/branches/experimental
source_changes at macosforge.org
source_changes at macosforge.org
Fri Jul 24 16:47:40 PDT 2009
Revision: 2072
http://trac.macosforge.org/projects/ruby/changeset/2072
Author: pthomson at apple.com
Date: 2009-07-24 16:47:39 -0700 (Fri, 24 Jul 2009)
Log Message:
-----------
Implemented a cleaner solution to the adding of singleton methods to objects (thanks to Laurent), and wrote about it in the TODO file.
Modified Paths:
--------------
MacRuby/branches/experimental/TODO
MacRuby/branches/experimental/ext/readline/readline.c
Modified: MacRuby/branches/experimental/TODO
===================================================================
--- MacRuby/branches/experimental/TODO 2009-07-24 21:23:15 UTC (rev 2071)
+++ MacRuby/branches/experimental/TODO 2009-07-24 23:47:39 UTC (rev 2072)
@@ -44,13 +44,18 @@
// etc.
- In the case of rb_define_global_function(), replace it by
+ In the case of rb_define_global_function(), replace it with
rb_objc_define_method(rb_mKernel, ...)
- In the case of rb_define_singleton_method(), replace it by
+ In the case of rb_define_singleton_method() for defining class
+ functions and module-level functions, replace it with
rb_objc_define_method(*(VALUE *)klass, ...)
- In the case of rb_define_alloc_func(), replace it by
+ In the case of rb_define_singleton_method() for defining methods on
+ individual instances of objects, replace it with
+ rb_objc_define_method(rb_singleton_class(obj), ...)
+
+ In the case of rb_define_alloc_func(), replace it with
rb_objc_define_method(*(VALUE *)klass, "alloc", ..., 0)
[/] port all rb_funcall() calls to rb_vm_call()
Modified: MacRuby/branches/experimental/ext/readline/readline.c
===================================================================
--- MacRuby/branches/experimental/ext/readline/readline.c 2009-07-24 21:23:15 UTC (rev 2071)
+++ MacRuby/branches/experimental/ext/readline/readline.c 2009-07-24 23:47:39 UTC (rev 2072)
@@ -800,13 +800,13 @@
rb_objc_define_method(*(VALUE *)history, "delete_at", hist_delete_at, 1);
rb_define_const(mReadline, "HISTORY", history);
- fcomp = rb_singleton_class_clone(rb_obj_alloc(rb_cObject));
- rb_objc_define_method(*(VALUE *)fcomp, "call",
+ fcomp = rb_obj_alloc(rb_cObject);
+ rb_objc_define_method(rb_singleton_class(fcomp), "call",
filename_completion_proc_call, 1);
rb_define_const(mReadline, "FILENAME_COMPLETION_PROC", fcomp);
- ucomp = rb_singleton_class_clone(rb_obj_alloc(rb_cObject));
- rb_objc_define_method(*(VALUE *)ucomp, "call",
+ ucomp = rb_obj_alloc(rb_cObject);
+ rb_objc_define_method(rb_singleton_class(ucomp), "call",
username_completion_proc_call, 1);
rb_define_const(mReadline, "USERNAME_COMPLETION_PROC", ucomp);
#if defined HAVE_RL_LIBRARY_VERSION
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090724/3fec0177/attachment.html>
More information about the macruby-changes
mailing list