mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* vm_method.c (basic_obj_respond_to): should not call
#respond_to_missing? for not implemented methods. [ruby-core:25909] * vm_method.c (rb_method_boundp): returns exceptional value 2 for not-implemented methods when called from #respond_to? (specifies by new contant NOEX_RESPONDS). * method.h (enum): new constant NOEX_RESPONDS added. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25234 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
0e260ef122
commit
e3fc29a71b
3 changed files with 26 additions and 10 deletions
12
ChangeLog
12
ChangeLog
|
@ -1,3 +1,15 @@
|
||||||
|
Mon Oct 5 00:09:57 2009 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
|
* vm_method.c (basic_obj_respond_to): should not call
|
||||||
|
#respond_to_missing? for not implemented methods.
|
||||||
|
[ruby-core:25909]
|
||||||
|
|
||||||
|
* vm_method.c (rb_method_boundp): returns exceptional value 2 for
|
||||||
|
not-implemented methods when called from #respond_to? (specifies
|
||||||
|
by new contant NOEX_RESPONDS).
|
||||||
|
|
||||||
|
* method.h (enum): new constant NOEX_RESPONDS added.
|
||||||
|
|
||||||
Sun Oct 4 22:16:29 2009 Takeyuki FUJIOKA <xibbar@ruby-lang.org>
|
Sun Oct 4 22:16:29 2009 Takeyuki FUJIOKA <xibbar@ruby-lang.org>
|
||||||
|
|
||||||
* lib/cgi/cookie.rb: add default value to @@accept_charset
|
* lib/cgi/cookie.rb: add default value to @@accept_charset
|
||||||
|
|
3
method.h
3
method.h
|
@ -21,7 +21,8 @@ typedef enum {
|
||||||
NOEX_UNDEF = NOEX_NOSUPER,
|
NOEX_UNDEF = NOEX_NOSUPER,
|
||||||
NOEX_MODFUNC = 0x12,
|
NOEX_MODFUNC = 0x12,
|
||||||
NOEX_SUPER = 0x20,
|
NOEX_SUPER = 0x20,
|
||||||
NOEX_VCALL = 0x40
|
NOEX_VCALL = 0x40,
|
||||||
|
NOEX_RESPONDS = 0x80
|
||||||
} rb_method_flag_t;
|
} rb_method_flag_t;
|
||||||
|
|
||||||
#define NOEX_SAFE(n) ((int)((n) >> 8) & 0x0F)
|
#define NOEX_SAFE(n) ((int)((n) >> 8) & 0x0F)
|
||||||
|
|
21
vm_method.c
21
vm_method.c
|
@ -515,12 +515,14 @@ rb_method_boundp(VALUE klass, ID id, int ex)
|
||||||
if (ex && (me->flag & NOEX_PRIVATE)) {
|
if (ex && (me->flag & NOEX_PRIVATE)) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if (!me->def || me->def->type == VM_METHOD_TYPE_NOTIMPLEMENTED) {
|
if (!me->def) return 0;
|
||||||
return FALSE;
|
if (me->def->type == VM_METHOD_TYPE_NOTIMPLEMENTED) {
|
||||||
|
if (ex & NOEX_RESPONDS) return 2;
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
return TRUE;
|
return 1;
|
||||||
}
|
}
|
||||||
return FALSE;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -1151,13 +1153,14 @@ basic_obj_respond_to(VALUE obj, ID id, int pub)
|
||||||
{
|
{
|
||||||
VALUE klass = CLASS_OF(obj);
|
VALUE klass = CLASS_OF(obj);
|
||||||
|
|
||||||
if (!rb_method_boundp(klass, id, pub)) {
|
switch (rb_method_boundp(klass, id, pub|NOEX_RESPONDS)) {
|
||||||
if (!rb_method_basic_definition_p(klass, respond_to_missing)) {
|
case 2:
|
||||||
return RTEST(rb_funcall(obj, respond_to_missing, pub ? 1 : 2, ID2SYM(id), Qtrue));
|
|
||||||
}
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
case 0:
|
||||||
|
return RTEST(rb_funcall(obj, respond_to_missing, pub ? 1 : 2, ID2SYM(id), Qtrue));
|
||||||
|
default:
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
Loading…
Add table
Reference in a new issue