From dff438fba3e5d4da6f2aad0b0dafe28a2fc61619 Mon Sep 17 00:00:00 2001 From: matz Date: Wed, 25 Jun 2003 07:12:10 +0000 Subject: * 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 --- ChangeLog | 6 ++++++ class.c | 56 ++++++++++++++++++-------------------------------------- 2 files changed, 24 insertions(+), 38 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6333546a91..2168909719 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Wed Jun 25 12:52:58 2003 Matthew Dempsky + + * class.c (rb_generic_class_instance_methods): merge argument + check (and warning) into one function; following DRY principle. + [ruby-core:01193] + Wed Jun 25 00:14:30 2003 Yukihiro Matsumoto * variable.c (autoload_delete): should delete Qundef from iv_tbl. 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 -- cgit v1.2.3