From 4c26b23dbb944cc4848b8b9a5cab00815a635b44 Mon Sep 17 00:00:00 2001 From: matz Date: Fri, 2 May 2003 16:11:48 +0000 Subject: * class.c (rb_class_protected_instance_methods): now gives warnings to show migration path. * lib/delegate.rb (Delegator::initialize): instance_methods etc. now recurse by default. need to specify false. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3749 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 8 ++++++++ class.c | 22 ++++++++++++++++++++-- lib/delegate.rb | 8 ++++---- 3 files changed, 32 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9b59200c2d..0bed7c17d6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Sat May 3 00:58:53 2003 Yukihiro Matsumoto + + * class.c (rb_class_protected_instance_methods): now gives + warnings to show migration path. + + * lib/delegate.rb (Delegator::initialize): instance_methods + etc. now recurse by default. need to specify false. + Sat May 3 00:22:00 2003 Minero Aoki * lib/net/protocol.rb: reintroduce Protocol.protocol_param. diff --git a/class.c b/class.c index 833f96c4b4..be2be7e5ae 100644 --- a/class.c +++ b/class.c @@ -563,7 +563,10 @@ rb_class_instance_methods(argc, argv, mod) VALUE recur; rb_scan_args(argc, argv, "01", &recur); - if (argc == 0) recur = Qtrue; + if (argc == 0) { + rb_warn("instance_methods() default to true; specify false explicitly"); + recur = Qtrue; + } return method_list(mod, RTEST(recur), ins_methods_i); } @@ -576,6 +579,10 @@ rb_class_protected_instance_methods(argc, argv, mod) VALUE recur; rb_scan_args(argc, argv, "01", &recur); + if (argc == 0) { + rb_warn("protected_instance_methods() default to true; specify false explicitly"); + recur = Qtrue; + } if (argc == 0) recur = Qtrue; return method_list(mod, RTEST(recur), ins_methods_prot_i); } @@ -589,6 +596,10 @@ rb_class_private_instance_methods(argc, argv, mod) VALUE recur; rb_scan_args(argc, argv, "01", &recur); + if (argc == 0) { + rb_warn("private_instance_methods() default to true; specify false explicitly"); + recur = Qtrue; + } if (argc == 0) recur = Qtrue; return method_list(mod, RTEST(recur), ins_methods_priv_i); } @@ -602,6 +613,10 @@ rb_class_public_instance_methods(argc, argv, mod) VALUE recur; rb_scan_args(argc, argv, "01", &recur); + if (argc == 0) { + rb_warn("public_instance_methods() default to true; specify false explicitly"); + recur = Qtrue; + } if (argc == 0) recur = Qtrue; return method_list(mod, RTEST(recur), ins_methods_pub_i); } @@ -616,7 +631,10 @@ rb_obj_singleton_methods(argc, argv, obj) st_table *list; rb_scan_args(argc, argv, "01", &all); - if (argc == 0) all = Qtrue; + if (argc == 0) { + rb_warn("singleton_methods() default to true; specify false explicitly"); + all = Qtrue; + } klass = CLASS_OF(obj); list = st_init_numtable(); while (klass && FL_TEST(klass, FL_SINGLETON)) { diff --git a/lib/delegate.rb b/lib/delegate.rb index 08f730a532..88d2256a2f 100644 --- a/lib/delegate.rb +++ b/lib/delegate.rb @@ -19,12 +19,12 @@ class Delegator def initialize(obj) - preserved = ::Kernel.public_instance_methods + preserved = ::Kernel.public_instance_methods(false) preserved -= ["to_s","to_a","inspect","==","=~","==="] for t in self.class.ancestors - preserved |= t.public_instance_methods - preserved |= t.private_instance_methods - preserved |= t.protected_instance_methods + preserved |= t.public_instance_methods(false) + preserved |= t.private_instance_methods(false) + preserved |= t.protected_instance_methods(false) break if t == Delegator end for method in obj.methods -- cgit v1.2.3