ruby-changes:53188
From: nobu <ko1@a...>
Date: Sun, 28 Oct 2018 10:56:34 +0900 (JST)
Subject: [ruby-changes:53188] nobu:r65403 (trunk): rdoc/parser/c.rb: ignore dynamically added methods
nobu 2018-10-28 10:56:28 +0900 (Sun, 28 Oct 2018) New Revision: 65403 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=65403 Log: rdoc/parser/c.rb: ignore dynamically added methods * lib/rdoc/parser/c.rb (RDoc::Parser::C#deduplicate_call_seq): skip dynamically added methods at runtime, because the class name is unknown and the defined methods are not accessible from that class. Modified files: trunk/lib/rdoc/parser/c.rb trunk/test/rdoc/test_rdoc_parser_c.rb Index: test/rdoc/test_rdoc_parser_c.rb =================================================================== --- test/rdoc/test_rdoc_parser_c.rb (revision 65402) +++ test/rdoc/test_rdoc_parser_c.rb (revision 65403) @@ -1630,6 +1630,19 @@ Init_IO(void) { https://github.com/ruby/ruby/blob/trunk/test/rdoc/test_rdoc_parser_c.rb#L1630 assert read_method.singleton end + def test_define_method_dynamically + content = <<-EOF +void +Init_foo(void) +{ + rb_define_singleton_method(obj, "foo", foo, -1); +} + EOF + + klass = util_get_class content, 'obj' + assert_nil klass + end + def test_define_method_with_prototype content = <<-EOF static VALUE rb_io_s_read(int, VALUE*, VALUE); Index: lib/rdoc/parser/c.rb =================================================================== --- lib/rdoc/parser/c.rb (revision 65402) +++ lib/rdoc/parser/c.rb (revision 65403) @@ -217,6 +217,7 @@ class RDoc::Parser::C < RDoc::Parser https://github.com/ruby/ruby/blob/trunk/lib/rdoc/parser/c.rb#L217 def deduplicate_call_seq @methods.each do |var_name, functions| class_name = @known_classes[var_name] + next unless class_name class_obj = find_class var_name, class_name functions.each_value do |method_names| -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/