summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-10-11 12:42:50 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-10-11 12:42:50 +0000
commitedecc478900c699d04b15ce8710a174e42227b5b (patch)
treed2ce2d25ef5a598089cc85cf26bf98151f35aa1c
parent6d374635c83c86e8cf0578e5dde77cd872952d17 (diff)
* 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/branches/ruby_1_8@9376 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog7
-rw-r--r--eval.c29
-rw-r--r--intern.h1
3 files changed, 28 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index 74c9474604..715dcb4ed9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Tue Oct 11 21:41:58 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]
+
+ * eval.c (rb_respond_to): conform to Object#respond_to?. [ruby-dev:27411]
+
Sat Oct 8 20:04:40 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* eval.c (Init_Binding): add Binding#dup method. [yarv-dev:666]
diff --git a/eval.c b/eval.c
index 0f21a3636f..cba6428762 100644
--- a/eval.c
+++ b/eval.c
@@ -4100,21 +4100,32 @@ module_setup(module, n)
static NODE *basic_respond_to = 0;
int
-rb_respond_to(obj, id)
+rb_obj_respond_to(obj, id, priv)
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(obj, id)
+ VALUE obj;
+ ID id;
+{
+ return rb_obj_respond_to(obj, id, Qfalse);
+}
/*
* call-seq:
@@ -4126,7 +4137,7 @@ rb_respond_to(obj, id)
*/
static VALUE
-rb_obj_respond_to(argc, argv, obj)
+obj_respond_to(argc, argv, obj)
int argc;
VALUE *argv;
VALUE obj;
@@ -7760,7 +7771,7 @@ Init_eval()
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);
diff --git a/intern.h b/intern.h
index 8042ba492b..8ab5cd3d96 100644
--- a/intern.h
+++ b/intern.h
@@ -164,6 +164,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));