mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* eval.c (rb_obj_respond_to): check if obj responds to the given
method with the given visibility. [ruby-dev:27408] * eval.c (rb_respond_to): conform to Object#respond_to?. [ruby-dev:27411] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9376 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
a3cb2093ef
commit
cc2334bd7b
4 changed files with 23 additions and 23 deletions
|
@ -1,4 +1,4 @@
|
|||
Tue Oct 11 21:30:11 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
Tue Oct 11 21:41:58 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* configure.in (RUBY_FUNC_ATTRIBUTE): check prefixed attribute form
|
||||
first. [ruby-dev:27398]
|
||||
|
@ -9,10 +9,10 @@ Tue Oct 11 21:30:11 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
|||
* util.h (qsort): removed the definition incompatible to ANSI.
|
||||
fixed: [ruby-core:06147]
|
||||
|
||||
Mon Oct 10 00:09:54 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
* eval.c (rb_obj_respond_to): check if obj responds to the given
|
||||
method with the given visibility. [ruby-dev:27408]
|
||||
|
||||
* parse.y (ripper_initialize): rollback obj_respond_to().
|
||||
fixed: [ruby-dev:27406]
|
||||
* eval.c (rb_respond_to): conform to Object#respond_to?. [ruby-dev:27411]
|
||||
|
||||
Sat Oct 8 19:49:42 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
|
|
26
eval.c
26
eval.c
|
@ -4011,19 +4011,27 @@ module_setup(VALUE module, NODE *n)
|
|||
static NODE *basic_respond_to = 0;
|
||||
|
||||
int
|
||||
rb_respond_to(VALUE obj, ID id)
|
||||
rb_obj_respond_to(VALUE obj, ID id, int priv)
|
||||
{
|
||||
VALUE klass = CLASS_OF(obj);
|
||||
if (rb_method_node(klass, respond_to) == basic_respond_to &&
|
||||
rb_method_boundp(klass, id, 0)) {
|
||||
return Qtrue;
|
||||
|
||||
if (rb_method_node(klass, respond_to) == basic_respond_to) {
|
||||
return rb_method_boundp(klass, id, !priv);
|
||||
}
|
||||
else{
|
||||
return rb_funcall(obj, respond_to, 1, ID2SYM(id));
|
||||
else {
|
||||
VALUE args[2];
|
||||
int n = 0;
|
||||
args[n++] = ID2SYM(id);
|
||||
if (priv) args[n++] = Qtrue;
|
||||
return rb_funcall2(obj, respond_to, n, args);
|
||||
}
|
||||
return Qfalse;
|
||||
}
|
||||
|
||||
int
|
||||
rb_respond_to(VALUE obj, ID id)
|
||||
{
|
||||
return rb_obj_respond_to(obj, id, Qfalse);
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
|
@ -4035,7 +4043,7 @@ rb_respond_to(VALUE obj, ID id)
|
|||
*/
|
||||
|
||||
static VALUE
|
||||
rb_obj_respond_to(int argc, VALUE *argv, VALUE obj)
|
||||
obj_respond_to(int argc, VALUE *argv, VALUE obj)
|
||||
{
|
||||
VALUE mid, priv;
|
||||
ID id;
|
||||
|
@ -7553,7 +7561,7 @@ Init_eval(void)
|
|||
rb_define_global_function("method_missing", rb_method_missing, -1);
|
||||
rb_define_global_function("loop", rb_f_loop, 0);
|
||||
|
||||
rb_define_method(rb_mKernel, "respond_to?", rb_obj_respond_to, -1);
|
||||
rb_define_method(rb_mKernel, "respond_to?", obj_respond_to, -1);
|
||||
respond_to = rb_intern("respond_to?");
|
||||
basic_respond_to = rb_method_node(rb_cObject, respond_to);
|
||||
rb_global_variable((VALUE*)&basic_respond_to);
|
||||
|
|
1
intern.h
1
intern.h
|
@ -221,6 +221,7 @@ void rb_dvar_asgn(ID, VALUE);
|
|||
void rb_dvar_push(ID, VALUE);
|
||||
VALUE *rb_svar(int);
|
||||
VALUE rb_eval_cmd(VALUE, VALUE, int);
|
||||
int rb_obj_respond_to(VALUE, ID, int);
|
||||
int rb_respond_to(VALUE, ID);
|
||||
void rb_interrupt(void);
|
||||
VALUE rb_apply(VALUE, ID, VALUE);
|
||||
|
|
11
parse.y
11
parse.y
|
@ -8953,15 +8953,6 @@ ripper_s_allocate(VALUE klass)
|
|||
return self;
|
||||
}
|
||||
|
||||
static int
|
||||
obj_respond_to(VALUE obj, VALUE mid)
|
||||
{
|
||||
VALUE st;
|
||||
|
||||
st = rb_funcall(obj, rb_intern("respond_to?"), 2, mid, Qfalse);
|
||||
return RTEST(st);
|
||||
}
|
||||
|
||||
#define ripper_initialized_p(r) ((r)->parser_lex_input != 0)
|
||||
|
||||
/*
|
||||
|
@ -8982,7 +8973,7 @@ ripper_initialize(int argc, VALUE *argv, VALUE self)
|
|||
|
||||
Data_Get_Struct(self, struct parser_params, parser);
|
||||
rb_scan_args(argc, argv, "12", &src, &fname, &lineno);
|
||||
if (obj_respond_to(src, ID2SYM(ripper_id_gets))) {
|
||||
if (rb_obj_respond_to(src, ripper_id_gets, 0)) {
|
||||
parser->parser_lex_gets = ripper_lex_get_generic;
|
||||
}
|
||||
else {
|
||||
|
|
Loading…
Reference in a new issue