mirror of
https://github.com/ruby/ruby.git
synced 2025-09-15 16:44:01 +02:00
* object.c (rb_obj_inspect): print instance variables only when
Object#to_s is not overridden. [ruby-core:24425] * class.c (rb_obj_basic_to_s_p): new function. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25428 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
b20521ddc5
commit
7eac66b9c6
3 changed files with 23 additions and 2 deletions
10
class.c
10
class.c
|
@ -1257,6 +1257,16 @@ rb_define_attr(VALUE klass, const char *name, int read, int write)
|
|||
rb_attr(klass, rb_intern(name), read, write, FALSE);
|
||||
}
|
||||
|
||||
int
|
||||
rb_obj_basic_to_s_p(obj)
|
||||
{
|
||||
const rb_method_entry_t *me = rb_method_entry(CLASS_OF(obj), rb_intern("to_s"));
|
||||
if (me && me->def && me->def->type == VM_METHOD_TYPE_CFUNC &&
|
||||
me->def->body.cfunc.func == rb_any_to_s)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
int
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue