diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-12-31 18:54:37 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-12-31 18:54:37 +0000 |
commit | 63e6152c973b66d1927c382b23865a288c7ceef1 (patch) | |
tree | 1a7bb16275e95acb75b8747196b88f5a9333e7ad | |
parent | bd969c733108a7678a1341bd53e6390e3d71995a (diff) | |
download | ruby-63e6152c973b66d1927c382b23865a288c7ceef1.tar.gz |
* eval.c (rb_mod_define_method): set implicit visibility only when
it's called for the target class (ruby_cbase).
* eval.c (splat): no error for non-array splat.
* lib/rss/xml-stylesheet.rb (RSS::XMLStyleSheet::initialize): no
need for unnecessary splat in calling arguments.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/matzruby@11442 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 12 | ||||
-rw-r--r-- | eval.c | 49 | ||||
-rw-r--r-- | lib/rss/parser.rb | 2 | ||||
-rw-r--r-- | lib/rss/xml-stylesheet.rb | 2 | ||||
-rw-r--r-- | test/rss/rss-assertions.rb | 2 | ||||
-rw-r--r-- | test/rss/test_xml-stylesheet.rb | 6 | ||||
-rw-r--r-- | test/socket/test_socket.rb | 9 |
7 files changed, 41 insertions, 41 deletions
@@ -274,6 +274,18 @@ Sun Nov 26 16:36:46 2006 URABE Shyouhei <shyouhei@ruby-lang.org> * version.h: addition of RUBY_PATCHLEVEL. * version.c: ditto. +Thu Nov 23 10:38:40 2006 Yukihiro Matsumoto <matz@ruby-lang.org> + + * eval.c (rb_mod_define_method): set implicit visibility only when + it's called for the target class (ruby_cbase). + +Thu Nov 23 02:48:41 2006 Yukihiro Matsumoto <matz@ruby-lang.org> + + * eval.c (splat): no error for non-array splat. + + * lib/rss/xml-stylesheet.rb (RSS::XMLStyleSheet::initialize): no + need for unnecessary splat in calling arguments. + Wed Nov 22 16:00:49 2006 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp> * ext/tk/extconf.rb: support --with-X11/--without-X11 option. @@ -2617,34 +2617,19 @@ call_trace_func(rb_event_t event, NODE *node, VALUE self, ID id, VALUE klass /* } static VALUE -splat(VALUE v, int strict) +splat(VALUE v) { VALUE tmp; if (v == Qundef) return rb_ary_new2(0); tmp = rb_check_convert_type(v, T_ARRAY, "Array", "to_splat"); if (NIL_P(tmp)) { - if (strict) { - rb_raise(rb_eTypeError, "failed to splat"); - } return rb_ary_new3(1, v); } return tmp; } static VALUE -svalue_to_avalue(VALUE v) -{ - return splat(v, Qfalse); -} - -static VALUE -splat_value(VALUE v) -{ - return splat(v, Qtrue); -} - -static VALUE class_prefix(VALUE self, NODE *cpath) { if (!cpath) { @@ -2730,7 +2715,7 @@ when_check(NODE *tag, VALUE val, VALUE self) case NODE_SPLAT: tag = tag->nd_head; splat: - elm = splat_value(rb_eval(self, tag)); + elm = splat(rb_eval(self, tag)); for (i=0; i<RARRAY_LEN(elm); i++) { if (when_cond(val, RARRAY_PTR(elm)[i])) { return Qtrue; @@ -3004,7 +2989,7 @@ rb_eval(VALUE self, NODE *n) break; case NODE_SPLAT: - result = splat_value(rb_eval(self, node->nd_head)); + result = splat(rb_eval(self, node->nd_head)); break; case NODE_TO_ARY: @@ -3165,7 +3150,7 @@ rb_eval(VALUE self, NODE *n) case NODE_ARGSCAT: { VALUE args = rb_eval(self, node->nd_head); - result = rb_ary_concat(args, splat_value(rb_eval(self, node->nd_body))); + result = rb_ary_concat(args, splat(rb_eval(self, node->nd_body))); } break; @@ -4781,7 +4766,7 @@ rb_yield_0(VALUE val, VALUE self, VALUE klass /* OK */, int flags) goto block_var; } else if (nd_type(var) == NODE_ARGS) { - if (!(flags & YIELD_VALUES)) val = svalue_to_avalue(val); + if (!(flags & YIELD_VALUES)) val = splat(val); formal_assign(self, var, RARRAY_LEN(val), RARRAY_PTR(val), 0); } else if (nd_type(var) == NODE_BLOCK) { @@ -4843,7 +4828,7 @@ rb_yield_0(VALUE val, VALUE self, VALUE klass /* OK */, int flags) redo: if (nd_type(node) == NODE_CFUNC || nd_type(node) == NODE_IFUNC) { if (node->nd_state == YIELD_FUNC_AVALUE) { - val = svalue_to_avalue(val); + val = splat(val); } else { if (val == Qundef && node->nd_state != YIELD_FUNC_SVALUE) @@ -5525,7 +5510,7 @@ method_missing(VALUE obj, ID id, int argc, const VALUE *argv, argc = -argc; n = argc / 256 - 1; argc %= 256; - tmp = svalue_to_avalue(argv[argc]); + tmp = splat(argv[argc]); nargv = ALLOCA_N(VALUE, argc + RARRAY_LEN(tmp) + n + 1); MEMCPY(nargv+1, argv, VALUE, argc); MEMCPY(nargv+1+argc, RARRAY_PTR(tmp), VALUE, RARRAY_LEN(tmp)); @@ -5745,7 +5730,7 @@ rb_call0(VALUE klass, VALUE recv, ID id, ID oid, argc = -argc; n = argc / 256 - 1; argc %= 256; - tmp = svalue_to_avalue(argv[argc]); + tmp = splat(argv[argc]); nargv = TMP_ALLOC(argc + RARRAY_LEN(tmp) + n); MEMCPY(nargv, argv, VALUE, argc); MEMCPY(nargv+argc, RARRAY_PTR(tmp), VALUE, RARRAY_LEN(tmp)); @@ -9427,7 +9412,7 @@ bmcall(VALUE args, VALUE method) volatile VALUE a; VALUE ret; - a = svalue_to_avalue(args); + a = splat(args); ret = rb_method_call(RARRAY_LEN(a), RARRAY_PTR(a), method); a = Qnil; /* prevent tail call */ return ret; @@ -9573,14 +9558,14 @@ rb_mod_define_method(int argc, VALUE *argv, VALUE mod) rb_raise(rb_eTypeError, "wrong argument type (expected Proc/Method)"); } - if (VIS_TEST(VIS_PRIVATE)) { - noex = NOEX_PRIVATE; - } - else if (VIS_TEST(VIS_PROTECTED)) { - noex = NOEX_PROTECTED; - } - else { - noex = NOEX_PUBLIC; + noex = NOEX_PUBLIC; + if (ruby_cbase == mod) { + if (VIS_TEST(VIS_PRIVATE)) { + noex = NOEX_PRIVATE; + } + else if (VIS_TEST(VIS_PROTECTED)) { + noex = NOEX_PROTECTED; + } } rb_add_method(mod, id, node, noex); return body; diff --git a/lib/rss/parser.rb b/lib/rss/parser.rb index e63e06e20d..9bfd8cf04c 100644 --- a/lib/rss/parser.rb +++ b/lib/rss/parser.rb @@ -283,7 +283,7 @@ module RSS if name == "xml-stylesheet" params = parse_pi_content(content) if params.has_key?("href") - @xml_stylesheets << XMLStyleSheet.new(*params) + @xml_stylesheets << XMLStyleSheet.new(params) end end end diff --git a/lib/rss/xml-stylesheet.rb b/lib/rss/xml-stylesheet.rb index 66e3161dd0..d40859e874 100644 --- a/lib/rss/xml-stylesheet.rb +++ b/lib/rss/xml-stylesheet.rb @@ -34,7 +34,7 @@ module RSS attr_accessor(*ATTRIBUTES) attr_accessor(:do_validate) - def initialize(*attrs) + def initialize(attrs={}) @do_validate = true ATTRIBUTES.each do |attr| __send__("#{attr}=", nil) diff --git a/test/rss/rss-assertions.rb b/test/rss/rss-assertions.rb index f90eb7f3f2..87dadb189b 100644 --- a/test/rss/rss-assertions.rb +++ b/test/rss/rss-assertions.rb @@ -145,7 +145,7 @@ module RSS rss ||= ::RSS::RDF.new() xss_strs = [] attrs_ary.each do |attrs| - xss = ::RSS::XMLStyleSheet.new(*attrs) + xss = ::RSS::XMLStyleSheet.new(attrs) xss_strs.push(xss.to_s) rss.xml_stylesheets.push(xss) end diff --git a/test/rss/test_xml-stylesheet.rb b/test/rss/test_xml-stylesheet.rb index c88a858f56..b946af1294 100644 --- a/test/rss/test_xml-stylesheet.rb +++ b/test/rss/test_xml-stylesheet.rb @@ -14,7 +14,7 @@ module RSS {:media => "print", :title => "FOO"}, {:charset => "UTF-8", :alternate => "yes"}, ].each do |attrs| - assert_xml_stylesheet_attrs(attrs, XMLStyleSheet.new(*attrs)) + assert_xml_stylesheet_attrs(attrs, XMLStyleSheet.new(attrs)) end end @@ -35,8 +35,8 @@ module RSS :media => "printer", :charset => "UTF-8", :alternate => "yes"}, ].each do |attrs| - target, contents = parse_pi(XMLStyleSheet.new(*attrs).to_s) - assert_xml_stylesheet(target, attrs, XMLStyleSheet.new(*contents)) + target, contents = parse_pi(XMLStyleSheet.new(attrs).to_s) + assert_xml_stylesheet(target, attrs, XMLStyleSheet.new(contents)) end end diff --git a/test/socket/test_socket.rb b/test/socket/test_socket.rb index 00a16b1529..0591b7148b 100644 --- a/test/socket/test_socket.rb +++ b/test/socket/test_socket.rb @@ -38,7 +38,8 @@ class TestBasicSocket < Test::Unit::TestCase s.close linger } - inet_stream do |s| + inet_stream do |sock| + s = sock assert_equal(0, s.setsockopt(Socket::SOL_SOCKET, Socket::SO_LINGER, linger)) assert_raise(IOError) { @@ -51,7 +52,8 @@ class TestBasicSocket < Test::Unit::TestCase s.close Socket::SO_LINGER } - inet_stream do |s| + inet_stream do |sock| + s = sock assert_raise(IOError) { s.setsockopt(Socket::SOL_SOCKET, val, linger) } @@ -65,7 +67,8 @@ class TestBasicSocket < Test::Unit::TestCase s.close 2 } - inet_stream do |s| + inet_stream do |sock| + s = sock assert_raise(IOError) { s.listen(log) } |