1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* array.c (rb_ary_sort_bang): respect overridden <=> for String and

Fixnum.  [ruby-core:17708]

* include/ruby/node.h (NOEX_BASIC): basic definition method flag.

* include/ruby/intern.h, vm_method.c (rb_method_basic_definition_p):
  new function to check if the method is not redefined after the
  initialization.

* vm_method.c (rb_obj_respond_to): use rb_method_basic_definition_p.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18360 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2008-08-04 18:29:55 +00:00
parent e370754189
commit a58e3d763b
5 changed files with 65 additions and 17 deletions

View file

@ -1044,6 +1044,15 @@ rb_mod_modfunc(int argc, VALUE *argv, VALUE module)
return module;
}
int
rb_method_basic_definition_p(VALUE klass, ID id)
{
NODE *node = rb_method_node(klass, id);
if (node && (node->nd_noex & NOEX_BASIC))
return 1;
return 0;
}
/*
* call-seq:
* obj.respond_to?(symbol, include_private=false) => true or false
@ -1053,14 +1062,12 @@ rb_mod_modfunc(int argc, VALUE *argv, VALUE module)
* optional second parameter evaluates to +true+.
*/
static NODE *basic_respond_to = 0;
int
rb_obj_respond_to(VALUE obj, ID id, int priv)
{
VALUE klass = CLASS_OF(obj);
if (rb_method_node(klass, idRespond_to) == basic_respond_to) {
if (rb_method_basic_definition_p(klass, idRespond_to)) {
return rb_method_boundp(klass, id, !priv);
}
else {
@ -1108,8 +1115,6 @@ Init_eval_method(void)
#undef rb_intern
rb_define_method(rb_mKernel, "respond_to?", obj_respond_to, -1);
basic_respond_to = rb_method_node(rb_cObject, idRespond_to);
rb_register_mark_object((VALUE)basic_respond_to);
rb_define_private_method(rb_cModule, "remove_method", rb_mod_remove_method, -1);
rb_define_private_method(rb_cModule, "undef_method", rb_mod_undef_method, -1);