Annotate Symbol#to_s as leaf (#9769)
This commit is contained in:
parent
a322b2faa4
commit
51753ec7fa
13
string.c
13
string.c
@ -11693,17 +11693,6 @@ sym_inspect(VALUE sym)
|
|||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* call-seq:
|
|
||||||
* to_s -> string
|
|
||||||
*
|
|
||||||
* Returns a string representation of +self+ (not including the leading colon):
|
|
||||||
*
|
|
||||||
* :foo.to_s # => "foo"
|
|
||||||
*
|
|
||||||
* Related: Symbol#inspect, Symbol#name.
|
|
||||||
*/
|
|
||||||
|
|
||||||
VALUE
|
VALUE
|
||||||
rb_sym_to_s(VALUE sym)
|
rb_sym_to_s(VALUE sym)
|
||||||
{
|
{
|
||||||
@ -12270,8 +12259,6 @@ Init_String(void)
|
|||||||
rb_define_method(rb_cSymbol, "==", sym_equal, 1);
|
rb_define_method(rb_cSymbol, "==", sym_equal, 1);
|
||||||
rb_define_method(rb_cSymbol, "===", sym_equal, 1);
|
rb_define_method(rb_cSymbol, "===", sym_equal, 1);
|
||||||
rb_define_method(rb_cSymbol, "inspect", sym_inspect, 0);
|
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); /* in symbol.c */
|
rb_define_method(rb_cSymbol, "name", rb_sym2str, 0); /* in symbol.c */
|
||||||
rb_define_method(rb_cSymbol, "to_proc", rb_sym_to_proc, 0); /* in proc.c */
|
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, "succ", sym_succ, 0);
|
||||||
|
15
symbol.rb
15
symbol.rb
@ -1,4 +1,19 @@
|
|||||||
class Symbol
|
class Symbol
|
||||||
|
# call-seq:
|
||||||
|
# to_s -> string
|
||||||
|
#
|
||||||
|
# Returns a string representation of +self+ (not including the leading colon):
|
||||||
|
#
|
||||||
|
# :foo.to_s # => "foo"
|
||||||
|
#
|
||||||
|
# Related: Symbol#inspect, Symbol#name.
|
||||||
|
def to_s
|
||||||
|
Primitive.attr! :leaf
|
||||||
|
Primitive.cexpr! 'rb_sym_to_s(self)'
|
||||||
|
end
|
||||||
|
|
||||||
|
alias id2name to_s
|
||||||
|
|
||||||
# call-seq:
|
# call-seq:
|
||||||
# to_sym -> self
|
# to_sym -> self
|
||||||
#
|
#
|
||||||
|
Loading…
x
Reference in New Issue
Block a user