Project

General

Profile

Feature #2084

Method#source_location and Methods Created with `attr`

Added by runpaint (Run Paint Run Run) over 10 years ago. Updated over 8 years ago.

Status:
Closed
Priority:
Normal
Target version:
[ruby-core:25532]

Description

=begin
$ cat /tmp/attr.rb
class C
attr :a
end

p C.instance_methods(false)
p C.instance_method(:a).source_location

$ ruby -v /tmp/attr.rb
ruby 1.9.2dev (2009-09-11) [i686-linux]
[:a]
nil

Is it feasible to have Method#source_location work with methods created with attr(and friends)? Given that a common use for this feature is to extract documentation, it would be helpful if such methods could be located by introspection.
=end


Files

save_attr_loc.patch (5.1 KB) save_attr_loc.patch wanabe (_ wanabe), 01/25/2010 09:56 AM

Associated revisions

Revision c46f7139
Added by wanabe (_ wanabe) almost 10 years ago

  • proc.c (rb_method_location): return attr's location if it is setup.
    [Feature #2084]

  • NEWS: follow above.

  • vm_method.c (rb_add_method): save attr's location.

  • gc.c (mark_method_entry): mark attr's location.

  • method.h (rb_method_definition_t): add member to save attr's location.

  • vm_eval.c (vm_call0): follow above.

  • vm_insnhelper.c (vm_call_method): ditto.

  • vm_method.c (rb_method_definition_eq): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27016 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 27016
Added by wanabe (_ wanabe) almost 10 years ago

  • proc.c (rb_method_location): return attr's location if it is setup.
    [Feature #2084]

  • NEWS: follow above.

  • vm_method.c (rb_add_method): save attr's location.

  • gc.c (mark_method_entry): mark attr's location.

  • method.h (rb_method_definition_t): add member to save attr's location.

  • vm_eval.c (vm_call0): follow above.

  • vm_insnhelper.c (vm_call_method): ditto.

  • vm_method.c (rb_method_definition_eq): ditto.

Revision 27016
Added by wanabe (_ wanabe) almost 10 years ago

  • proc.c (rb_method_location): return attr's location if it is setup.
    [Feature #2084]

  • NEWS: follow above.

  • vm_method.c (rb_add_method): save attr's location.

  • gc.c (mark_method_entry): mark attr's location.

  • method.h (rb_method_definition_t): add member to save attr's location.

  • vm_eval.c (vm_call0): follow above.

  • vm_insnhelper.c (vm_call_method): ditto.

  • vm_method.c (rb_method_definition_eq): ditto.

Revision 27016
Added by wanabe (_ wanabe) almost 10 years ago

  • proc.c (rb_method_location): return attr's location if it is setup.
    [Feature #2084]

  • NEWS: follow above.

  • vm_method.c (rb_add_method): save attr's location.

  • gc.c (mark_method_entry): mark attr's location.

  • method.h (rb_method_definition_t): add member to save attr's location.

  • vm_eval.c (vm_call0): follow above.

  • vm_insnhelper.c (vm_call_method): ditto.

  • vm_method.c (rb_method_definition_eq): ditto.

Revision 27016
Added by wanabe (_ wanabe) almost 10 years ago

  • proc.c (rb_method_location): return attr's location if it is setup.
    [Feature #2084]

  • NEWS: follow above.

  • vm_method.c (rb_add_method): save attr's location.

  • gc.c (mark_method_entry): mark attr's location.

  • method.h (rb_method_definition_t): add member to save attr's location.

  • vm_eval.c (vm_call0): follow above.

  • vm_insnhelper.c (vm_call_method): ditto.

  • vm_method.c (rb_method_definition_eq): ditto.

Revision 27016
Added by wanabe (_ wanabe) almost 10 years ago

  • proc.c (rb_method_location): return attr's location if it is setup.
    [Feature #2084]

  • NEWS: follow above.

  • vm_method.c (rb_add_method): save attr's location.

  • gc.c (mark_method_entry): mark attr's location.

  • method.h (rb_method_definition_t): add member to save attr's location.

  • vm_eval.c (vm_call0): follow above.

  • vm_insnhelper.c (vm_call_method): ditto.

  • vm_method.c (rb_method_definition_eq): ditto.

Revision 27016
Added by wanabe (_ wanabe) almost 10 years ago

  • proc.c (rb_method_location): return attr's location if it is setup.
    [Feature #2084]

  • NEWS: follow above.

  • vm_method.c (rb_add_method): save attr's location.

  • gc.c (mark_method_entry): mark attr's location.

  • method.h (rb_method_definition_t): add member to save attr's location.

  • vm_eval.c (vm_call0): follow above.

  • vm_insnhelper.c (vm_call_method): ditto.

  • vm_method.c (rb_method_definition_eq): ditto.

History

#1

Updated by wanabe (_ wanabe) almost 10 years ago

=begin
I wrote a patch. How about this?
=end

#2

Updated by nobu (Nobuyoshi Nakada) almost 10 years ago

  • Status changed from Open to Assigned
  • Assignee set to yugui (Yuki Sonoda)

=begin

=end

#3

Updated by mame (Yusuke Endoh) almost 10 years ago

  • Priority changed from 3 to Normal
  • Target version set to 1.9.2

=begin
Hi,

I wrote a patch. How about this?

+1, and I confirmed it passes make check and RubySpec.

Matz or Yugui, could you approve this?

--
Yusuke Endoh mame@tsg.ne.jp
=end

#4

Updated by mame (Yusuke Endoh) almost 10 years ago

  • Assignee changed from yugui (Yuki Sonoda) to wanabe (_ wanabe)

=begin
Hi,

Matz or Yugui, could you approve this?

Yugui has agreed with this feature on IRC.
But she said she had no responsibility for Method#source_location.
(I had misunderstood that she had committed it)

Well, because this feature is trivial, I guess anyone won't disagree.
Wanabe, could you apply your patch?
If you are reluctant to commit it without explicit approval, I'll
commit it on my own responsibility.

--
Yusuke Endoh mame@tsg.ne.jp
=end

#5

Updated by wanabe (_ wanabe) almost 10 years ago

=begin

If you are reluctant to commit it without explicit approval, I'll
commit it on my own responsibility.

Many thanks for your concern.
I'll apply it soon.
=end

#6

Updated by wanabe (_ wanabe) almost 10 years ago

  • Status changed from Assigned to Closed
  • % Done changed from 0 to 100

=begin
This issue was solved with changeset r27016.
Run Paint, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.

=end

Also available in: Atom PDF