summaryrefslogtreecommitdiff
path: root/class.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-06-25 07:12:10 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-06-25 07:12:10 +0000
commitdff438fba3e5d4da6f2aad0b0dafe28a2fc61619 (patch)
tree669237cdddd63543c8cb78db52a99d8e05cb522c /class.c
parent9a47a0460792a1c7447cff0dfe1059877da87be2 (diff)
* class.c (rb_generic_class_instance_methods): merge argument
check (and warning) into one function; following DRY principle. [ruby-core:01193] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4002 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'class.c')
-rw-r--r--class.c56
1 files changed, 18 insertions, 38 deletions
diff --git a/class.c b/class.c
index a3d038da94..579cc83c7e 100644
--- a/class.c
+++ b/class.c
@@ -549,42 +549,42 @@ method_list(mod, recur, func)
return ary;
}
-VALUE
-rb_class_instance_methods(argc, argv, mod)
+static VALUE
+class_instance_method_list(argc, argv, mod, func)
int argc;
VALUE *argv;
VALUE mod;
+ void (*func)();
{
VALUE recur;
rb_scan_args(argc, argv, "01", &recur);
if (argc == 0) {
#if RUBY_VERSION_CODE < 181
- rb_warn("instance_methods parameter will default to 'true' after 1.8.1");
+ rb_warn("%s: parameter will default to 'true' as of 1.8.1", rb_id2name(rb_frame_last_func()));
#else
recur = Qtrue;
#endif
}
- return method_list(mod, RTEST(recur), ins_methods_i);
+ return method_list(mod, RTEST(recur), func);
}
VALUE
-rb_class_protected_instance_methods(argc, argv, mod)
+rb_class_instance_methods(argc, argv, mod)
int argc;
VALUE *argv;
VALUE mod;
{
- VALUE recur;
+ return class_instance_method_list(argc, argv, mod, ins_methods_i);
+}
- rb_scan_args(argc, argv, "01", &recur);
- if (argc == 0) {
-#if RUBY_VERSION_CODE < 181
- rb_warn("protected_instance_methods parameter will default to 'true' after 1.8.1");
-#else
- recur = Qtrue;
-#endif
- }
- return method_list(mod, RTEST(recur), ins_methods_prot_i);
+VALUE
+rb_class_protected_instance_methods(argc, argv, mod)
+ int argc;
+ VALUE *argv;
+ VALUE mod;
+{
+ return class_instance_method_list(argc, argv, mod, ins_methods_prot_i);
}
VALUE
@@ -593,17 +593,7 @@ rb_class_private_instance_methods(argc, argv, mod)
VALUE *argv;
VALUE mod;
{
- VALUE recur;
-
- rb_scan_args(argc, argv, "01", &recur);
- if (argc == 0) {
-#if RUBY_VERSION_CODE < 181
- rb_warn("private_instance_methods parameter will default to 'true' after 1.8.1");
-#else
- recur = Qtrue;
-#endif
- }
- return method_list(mod, RTEST(recur), ins_methods_priv_i);
+ return class_instance_method_list(argc, argv, mod, ins_methods_priv_i);
}
VALUE
@@ -612,17 +602,7 @@ rb_class_public_instance_methods(argc, argv, mod)
VALUE *argv;
VALUE mod;
{
- VALUE recur;
-
- rb_scan_args(argc, argv, "01", &recur);
- if (argc == 0) {
-#if RUBY_VERSION_CODE < 181
- rb_warn("public_instance_methods parameter will default to 'true' after 1.8.1");
-#else
- recur = Qtrue;
-#endif
- }
- return method_list(mod, RTEST(recur), ins_methods_pub_i);
+ return class_instance_method_list(argc, argv, mod, ins_methods_pub_i);
}
VALUE
@@ -637,7 +617,7 @@ rb_obj_singleton_methods(argc, argv, obj)
rb_scan_args(argc, argv, "01", &recur);
if (argc == 0) {
#if RUBY_VERSION_CODE < 181
- rb_warn("singleton_methods parameter will default to 'true' after 1.8.1");
+ rb_warn("singleton_methods: parameter will default to 'true' as of 1.8.1");
#else
recur = Qtrue;
#endif