From: Matthew Dempsky Date: 2003-06-25T12:56:44+09:00 Subject: Re: [Patch] class.c code cleanup (rb_class_*_instance_methods) --=-c4dr27pohvgtM7/Lpxid Content-Type: text/plain Content-Transfer-Encoding: 7bit On Sun, 2003-06-22 at 07:41, nobu.nokada@softhome.net wrote: > You can get current method name by: > rb_id2name(rb_frame_last_func()) I rewrote the patch using exactly that to construct the strings. > "from 1.8.1"? I actually used "as of 1.8.1" because that seemed the clearest to me (from didn't quite fit in my mind). So, here's my second attempt at a simple patch (eventually I'll have to get one right :) -jivera --=-c4dr27pohvgtM7/Lpxid Content-Disposition: attachment; filename=class.patch Content-Type: text/plain; name=class.patch; charset= Content-Transfer-Encoding: 7bit --- class-old.c 2003-06-20 02:11:40.000000000 -0500 +++ class.c 2003-06-24 22:52:58.000000000 -0500 @@ -549,18 +549,22 @@ return ary; } -VALUE -rb_class_instance_methods(argc, argv, mod) +static VALUE +rb_generic_class_instance_methods(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"); + char buffer[BUFSIZ]; + strcpy(buffer, rb_id2name(rb_frame_last_func())); + strcat(buffer, " parameter will default to 'true' as of 1.8.1"); + rb_warn(buffer); #else recur = Qtrue; #endif @@ -569,22 +573,21 @@ } 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 rb_generic_class_instance_methods(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 rb_generic_class_instance_methods(argc, argv, mod, ins_methods_prot_i); } VALUE @@ -593,17 +596,7 @@ 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 rb_generic_class_instance_methods(argc, argv, mod, ins_methods_priv_i); } VALUE @@ -612,17 +605,7 @@ 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 rb_generic_class_instance_methods(argc, argv, mod, ins_methods_pub_i); } VALUE --=-c4dr27pohvgtM7/Lpxid--