ruby-changes:71725
From: Nobuyoshi <ko1@a...>
Date: Thu, 14 Apr 2022 11:21:21 +0900 (JST)
Subject: [ruby-changes:71725] 5d45afdbbf (master): [DOC] Move the documentations of moved Symbol methods
https://git.ruby-lang.org/ruby.git/commit/?id=5d45afdbbf From 5d45afdbbf058d82ced0b12bf9e4b2978db9f4e0 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Thu, 14 Apr 2022 11:17:37 +0900 Subject: [DOC] Move the documentations of moved Symbol methods --- proc.c | 15 +++++++++++++++ string.c | 47 ++--------------------------------------------- symbol.c | 11 +++++++++++ 3 files changed, 28 insertions(+), 45 deletions(-) diff --git a/proc.c b/proc.c index f2b3c1ff21..d5d0bbdb46 100644 --- a/proc.c +++ b/proc.c @@ -1471,6 +1471,21 @@ rb_hash_proc(st_index_t hash, VALUE prc) https://github.com/ruby/ruby/blob/trunk/proc.c#L1471 return rb_hash_uint(hash, (st_index_t)proc->block.as.captured.ep); } + +/* + * call-seq: + * to_proc + * + * Returns a Proc object which calls the method with name of +self+ + * on the first parameter and passes the remaining parameters to the method. + * + * proc = :to_s.to_proc # => #<Proc:0x000001afe0e48680(&:to_s) (lambda)> + * proc.call(1000) # => "1000" + * proc.call(1000, 16) # => "3e8" + * (1..3).collect(&:to_s) # => ["1", "2", "3"] + * + */ + MJIT_FUNC_EXPORTED VALUE rb_sym_to_proc(VALUE sym) { diff --git a/string.c b/string.c index fe82f7af13..02044821bc 100644 --- a/string.c +++ b/string.c @@ -11407,26 +11407,6 @@ sym_inspect(VALUE sym) https://github.com/ruby/ruby/blob/trunk/string.c#L11407 return str; } -#if 0 /* for RDoc */ -/* - * call-seq: - * name -> string - * - * Returns a frozen string representation of +self+ (not including the leading colon): - * - * :foo.name # => "foo" - * :foo.name.frozen? # => true - * - * Related: Symbol#to_s, Symbol#inspect. - */ -VALUE -rb_sym2str(VALUE sym) -{ - -} -#endif - - /* * call-seq: * to_s -> string @@ -11440,14 +11420,12 @@ rb_sym2str(VALUE sym) https://github.com/ruby/ruby/blob/trunk/string.c#L11420 * Related: Symbol#inspect, Symbol#name. */ - VALUE rb_sym_to_s(VALUE sym) { return str_new_shared(rb_cString, rb_sym2str(sym)); } - /* * call-seq: * to_sym -> self @@ -11477,27 +11455,6 @@ rb_sym_proc_call(ID mid, int argc, const VALUE *argv, int kw_splat, VALUE passed https://github.com/ruby/ruby/blob/trunk/string.c#L11455 return rb_funcall_with_block_kw(obj, mid, argc - 1, argv + 1, passed_proc, kw_splat); } -#if 0 -/* - * call-seq: - * to_proc - * - * Returns a Proc object which calls the method with name of +self+ - * on the first parameter and passes the remaining parameters to the method. - * - * proc = :to_s.to_proc # => #<Proc:0x000001afe0e48680(&:to_s) (lambda)> - * proc.call(1000) # => "1000" - * proc.call(1000, 16) # => "3e8" - * (1..3).collect(&:to_s) # => ["1", "2", "3"] - * - */ - -VALUE -rb_sym_to_proc(VALUE sym) -{ -} -#endif - /* * call-seq: * succ @@ -12050,10 +12007,10 @@ Init_String(void) https://github.com/ruby/ruby/blob/trunk/string.c#L12007 rb_define_method(rb_cSymbol, "inspect", sym_inspect, 0); rb_define_method(rb_cSymbol, "to_s", rb_sym_to_s, 0); rb_define_method(rb_cSymbol, "id2name", rb_sym_to_s, 0); - rb_define_method(rb_cSymbol, "name", rb_sym2str, 0); + rb_define_method(rb_cSymbol, "name", rb_sym2str, 0); /* in symbol.c */ rb_define_method(rb_cSymbol, "intern", sym_to_sym, 0); rb_define_method(rb_cSymbol, "to_sym", sym_to_sym, 0); - rb_define_method(rb_cSymbol, "to_proc", rb_sym_to_proc, 0); + rb_define_method(rb_cSymbol, "to_proc", rb_sym_to_proc, 0); /* in proc.c */ rb_define_method(rb_cSymbol, "succ", sym_succ, 0); rb_define_method(rb_cSymbol, "next", sym_succ, 0); diff --git a/symbol.c b/symbol.c index 5ce95f5b07..f5e876c7d7 100644 --- a/symbol.c +++ b/symbol.c @@ -919,6 +919,17 @@ rb_id2sym(ID x) https://github.com/ruby/ruby/blob/trunk/symbol.c#L919 return get_id_entry(x, ID_ENTRY_SYM); } +/* + * call-seq: + * name -> string + * + * Returns a frozen string representation of +self+ (not including the leading colon): + * + * :foo.name # => "foo" + * :foo.name.frozen? # => true + * + * Related: Symbol#to_s, Symbol#inspect. + */ VALUE rb_sym2str(VALUE sym) -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/