summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-09-05 08:40:27 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-09-05 08:40:27 +0000
commitdf27d91fc4de9215d6af58de191b2c105ef88678 (patch)
treed017ac4f0a339440fb13d2473673f254ce98ec38
parent48653d5ef0ed47469d64170d70c8c2a9f21f159e (diff)
* lib/observer.rb: a patch from nornagon <nornagon@gmail.com>
merged to allow arbitrary names for update methods. [ruby-core:05416] * eval.c (rb_f_fcall): new method to avoid inefficiency of obj.instance_eval{send(...)} tricks. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9082 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog19
-rw-r--r--class.c3
-rw-r--r--eval.c64
-rw-r--r--ext/tk/lib/tk/font.rb4
-rw-r--r--ext/tk/lib/tkextlib/ICONS/icons.rb2
-rw-r--r--ext/tk/sample/tkextlib/treectrl/demo.rb2
6 files changed, 75 insertions, 19 deletions
diff --git a/ChangeLog b/ChangeLog
index 82c0becf11..45511ac3ef 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+Mon Sep 5 17:03:07 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * lib/ostruct.rb: a patch from Florian Gross <florgro@gmail.com>
+ merged to allow recursive inspect (and to_s) for OpenStruct.
+ [ruby-core:05532]
+
+Mon Sep 5 08:20:19 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * lib/observer.rb: a patch from nornagon <nornagon@gmail.com>
+ merged to allow arbitrary names for update methods.
+ [ruby-core:05416]
+
Mon Sep 5 07:01:12 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
* ext/openssl/openssl/lib/openssl/buffering.rb (Buffering#do_write):
@@ -8,6 +20,11 @@ Sun Sep 4 15:01:35 2005 Minero Aoki <aamine@loveruby.net>
* parse.y (f_arg): Ripper should not do semantic check.
[ruby-dev:26948]
+Sat Sep 3 23:52:35 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_f_fcall): new method to avoid inefficiency of
+ obj.instance_eval{send(...)} tricks.
+
Sat Sep 3 13:59:31 2005 Tanaka Akira <akr@m17n.org>
* lib/pathname.rb (Pathname#descend): Pathname.new("./a/b/c").descend
@@ -3333,7 +3350,7 @@ Fri Mar 4 12:45:17 2005 Charles Mills <cmills@freeshell.org>
(rb_define_const), accessors (rb_define_attr), and makes a
couple fixes. [ruby-core:4307]
-Fri Mar 4 12:45:17 2005 Florian Gro <florgro@gmail.com>
+Fri Mar 4 12:45:17 2005 Florian Gross <florgro@gmail.com>
* lib/rdoc/parsers/parse_rb.rb: Logic for def Builtin.method() end
[ruby-core:4302]
diff --git a/class.c b/class.c
index b3cec55065..a950b44de2 100644
--- a/class.c
+++ b/class.c
@@ -407,7 +407,8 @@ rb_include_module(klass, module)
break;
}
}
- c = RCLASS(c)->super = include_class_new(module, RCLASS(c)->super);
+ RCLASS(c)->super = include_class_new(module, RCLASS(c)->super);
+ c = RCLASS(c)->super;
changed = 1;
skip:
module = RCLASS(module)->super;
diff --git a/eval.c b/eval.c
index c52d889d62..3e7504ae05 100644
--- a/eval.c
+++ b/eval.c
@@ -6062,6 +6062,25 @@ rb_apply(recv, mid, args)
return rb_call(CLASS_OF(recv), recv, mid, argc, argv, 1);
}
+static VALUE
+send_fcall(argc, argv, recv, scope)
+ int argc;
+ VALUE *argv;
+ VALUE recv;
+ int scope;
+{
+ VALUE vid;
+
+ if (argc == 0) rb_raise(rb_eArgError, "no method name given");
+
+ vid = *argv++; argc--;
+ PUSH_ITER(rb_block_given_p()?ITER_PRE:ITER_NOT);
+ vid = rb_call(CLASS_OF(recv), recv, rb_to_id(vid), argc, argv, scope);
+ POP_ITER();
+
+ return vid;
+}
+
/*
* call-seq:
* obj.send(symbol [, args...]) => obj
@@ -6069,7 +6088,9 @@ rb_apply(recv, mid, args)
*
* Invokes the method identified by _symbol_, passing it any
* arguments specified. You can use <code>__send__</code> if the name
- * +send+ clashes with an existing method in _obj_.
+ * +send+ clashes with an existing method in _obj_. Raises an
+ * NoMethodError exception for private methods except when it is
+ * called in function call style.
*
* class Klass
* def hello(*args)
@@ -6078,6 +6099,9 @@ rb_apply(recv, mid, args)
* end
* k = Klass.new
* k.send :hello, "gentle", "readers" #=> "Hello gentle readers"
+ *
+ * 1.send(:puts, "foo") # NoMethodError exception
+ * send(:puts, "foo") # prints "foo"
*/
static VALUE
@@ -6086,17 +6110,30 @@ rb_f_send(argc, argv, recv)
VALUE *argv;
VALUE recv;
{
- VALUE vid;
int scope = (ruby_frame->flags & FRAME_FUNC) ? 1 : 0;
- if (argc == 0) rb_raise(rb_eArgError, "no method name given");
+ return send_fcall(argc, argv, recv, scope);
+}
- vid = *argv++; argc--;
- PUSH_ITER(rb_block_given_p()?ITER_PRE:ITER_NOT);
- vid = rb_call(CLASS_OF(recv), recv, rb_to_id(vid), argc, argv, scope);
- POP_ITER();
+/*
+ * call-seq:
+ * obj.fcall(symbol [, args...]) => obj
+ *
+ * Invokes the method identified by _symbol_, passing it any
+ * arguments specified. Unlike send, which calls private methods only
+ * when it is invoked in function call style, fcall always aware of
+ * private methods.
+ *
+ * 1.fcall(:puts, "hello") # prints "foo"
+ */
- return vid;
+static VALUE
+rb_f_fcall(argc, argv, recv)
+ int argc;
+ VALUE *argv;
+ VALUE recv;
+{
+ return send_fcall(argc, argv, recv, 1);
}
VALUE
@@ -7458,18 +7495,18 @@ rb_mod_modfunc(argc, argv, module)
*/
static VALUE
-rb_mod_append_features(module, include)
- VALUE module, include;
+rb_mod_append_features(module, dest)
+ VALUE module, dest;
{
- switch (TYPE(include)) {
+ switch (TYPE(dest)) {
case T_CLASS:
case T_MODULE:
break;
default:
- Check_Type(include, T_CLASS);
+ Check_Type(dest, T_CLASS);
break;
}
- rb_include_module(include, module);
+ rb_include_module(dest, module);
return module;
}
@@ -7907,6 +7944,7 @@ Init_eval()
rb_define_method(rb_mKernel, "send", rb_f_send, -1);
rb_define_method(rb_mKernel, "__send__", rb_f_send, -1);
+ rb_define_method(rb_mKernel, "fcall", rb_f_fcall, -1);
rb_define_method(rb_mKernel, "instance_eval", rb_obj_instance_eval, -1);
rb_define_private_method(rb_cModule, "append_features", rb_mod_append_features, 1);
diff --git a/ext/tk/lib/tk/font.rb b/ext/tk/lib/tk/font.rb
index 8e63558cae..73e0ac4682 100644
--- a/ext/tk/lib/tk/font.rb
+++ b/ext/tk/lib/tk/font.rb
@@ -1186,13 +1186,13 @@ class TkFont
def dup
src = self
obj = super()
- obj.instance_eval{ initialize(src) }
+ obj.fcall(:initialize, src)
obj
end
def clone
src = self
obj = super()
- obj.instance_eval{ initialize(src) }
+ obj.fcall(:initialize, src)
obj
end
=end
diff --git a/ext/tk/lib/tkextlib/ICONS/icons.rb b/ext/tk/lib/tkextlib/ICONS/icons.rb
index 8a37e35ebf..e02b579d0a 100644
--- a/ext/tk/lib/tkextlib/ICONS/icons.rb
+++ b/ext/tk/lib/tkextlib/ICONS/icons.rb
@@ -78,7 +78,7 @@ module Tk
def self.new(name, keys=nil)
unless obj = Tk_IMGTBL["::icon::#{name}"]
obj = allocate()
- obj.instance_eval{initialize(name, keys)}
+ obj.fcall(:initialize, name, keys)
end
obj
end
diff --git a/ext/tk/sample/tkextlib/treectrl/demo.rb b/ext/tk/sample/tkextlib/treectrl/demo.rb
index e3d0180584..dc8cfadaf2 100644
--- a/ext/tk/sample/tkextlib/treectrl/demo.rb
+++ b/ext/tk/sample/tkextlib/treectrl/demo.rb
@@ -710,7 +710,7 @@ class TkTreeCtrl_demo
systemHighlightText = @SystemHighlightText
proc_disp_styles_in_item = proc{|item|
- master.instance_eval{ display_styles_in_item(item) }
+ master.fcall(:display_styles_in_item, item)
}
@demo_scripts.instance_eval{