diff options
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | class.c | 24 | ||||
-rw-r--r-- | error.c | 8 | ||||
-rw-r--r-- | eval.c | 2 | ||||
-rw-r--r-- | intern.h | 1 | ||||
-rw-r--r-- | object.c | 2 | ||||
-rw-r--r-- | variable.c | 12 |
7 files changed, 37 insertions, 21 deletions
@@ -1,3 +1,12 @@ +Thu Jul 15 20:29:15 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp> + + * class.c, error.c, eval.c, intern.h, object.c, variable.c: + do not set path if it is a singleton class. [ruby-dev:22588] + (backport from 1.9) + +variable.c (rb_set_class_path): do not set path if it is a singleton +> class. [ruby-dev:22588] + Thu Jul 15 10:15:04 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp> * ext/tk/, ext/tcltklib/: bug fix @@ -175,7 +175,6 @@ rb_define_class_id(id, super) if (!super) super = rb_cObject; klass = rb_class_new(super); - rb_name_class(klass, id); rb_make_metaclass(klass, RBASIC(super)->klass); return klass; @@ -226,6 +225,7 @@ rb_define_class(name, super) } klass = rb_define_class_id(id, super); st_add_direct(rb_class_tbl, id, klass); + rb_name_class(klass, id); rb_const_set(rb_cObject, id, klass); rb_class_inherited(super, klass); @@ -630,7 +630,7 @@ class_instance_method_list(argc, argv, mod, func) /* * call-seq: - * mod.instance_methods(include_super=false) => array + * mod.instance_methods(include_super=true) => array * * Returns an array containing the names of public instance methods in * the receiver. For a module, these are the public methods; for a @@ -650,8 +650,8 @@ class_instance_method_list(argc, argv, mod, func) * end * * A.instance_methods #=> ["method1"] - * B.instance_methods #=> ["method2"] - * C.instance_methods #=> ["method3"] + * B.instance_methods(false) #=> ["method2"] + * C.instance_methods(false) #=> ["method3"] * C.instance_methods(true).length #=> 43 */ @@ -666,7 +666,7 @@ rb_class_instance_methods(argc, argv, mod) /* * call-seq: - * mod.protected_instance_methods(include_super=false) => array + * mod.protected_instance_methods(include_super=true) => array * * Returns a list of the protected instance methods defined in * <i>mod</i>. If the optional parameter is not <code>false</code>, the @@ -684,7 +684,7 @@ rb_class_protected_instance_methods(argc, argv, mod) /* * call-seq: - * mod.private_instance_methods(include_super=false) => array + * mod.private_instance_methods(include_super=true) => array * * Returns a list of the private instance methods defined in * <i>mod</i>. If the optional parameter is not <code>false</code>, the @@ -710,7 +710,7 @@ rb_class_private_instance_methods(argc, argv, mod) /* * call-seq: - * mod.public_instance_methods(include_super=false) => array + * mod.public_instance_methods(include_super=true) => array * * Returns a list of the public instance methods defined in <i>mod</i>. * If the optional parameter is not <code>false</code>, the methods of @@ -728,7 +728,7 @@ rb_class_public_instance_methods(argc, argv, mod) /* * call-seq: - * obj.singleton_methods(all=false) => array + * obj.singleton_methods(all=true) => array * * Returns an array of the names of singleton methods for <i>obj</i>. * If the optional <i>all</i> parameter is true, the list will include @@ -745,17 +745,17 @@ rb_class_public_instance_methods(argc, argv, mod) * a = Single.new * * def a.one() + * end * * class << a - * end * include Other * def two() + * end * end * - * end * Single.singleton_methods #=> ["four"] - * a.singleton_methods #=> ["two", "one"] - * a.singleton_methods(true) #=> ["two", "one", "three"] + * a.singleton_methods(false) #=> ["two", "one"] + * a.singleton_methods #=> ["two", "one", "three"] */ VALUE @@ -400,7 +400,7 @@ exc_to_s(exc) { VALUE mesg = rb_attr_get(exc, rb_intern("mesg")); - if (NIL_P(mesg)) return rb_class_path(CLASS_OF(exc)); + if (NIL_P(mesg)) return rb_class_name(CLASS_OF(exc)); if (OBJ_TAINTED(exc)) OBJ_TAINT(mesg); return mesg; } @@ -439,11 +439,11 @@ exc_inspect(exc) klass = CLASS_OF(exc); exc = rb_obj_as_string(exc); if (RSTRING(exc)->len == 0) { - return rb_str_dup(rb_class_path(klass)); + return rb_str_dup(rb_class_name(klass)); } str = rb_str_buf_new2("#<"); - klass = rb_class_path(klass); + klass = rb_class_name(klass); rb_str_buf_append(str, klass); rb_str_buf_cat(str, ": ", 2); rb_str_buf_append(str, exc); @@ -645,7 +645,7 @@ name_err_to_s(exc) { VALUE mesg = rb_attr_get(exc, rb_intern("mesg")), str = mesg; - if (NIL_P(mesg)) return rb_class_path(CLASS_OF(exc)); + if (NIL_P(mesg)) return rb_class_name(CLASS_OF(exc)); StringValue(str); if (str != mesg) { rb_iv_set(exc, "mesg", mesg = str); @@ -1142,7 +1142,7 @@ error_print() else { VALUE epath; - epath = rb_class_path(eclass); + epath = rb_class_name(eclass); if (elen == 0) { warn_print(": "); warn_print2(RSTRING(epath)->ptr, RSTRING(epath)->len); @@ -437,6 +437,7 @@ VALUE rb_class_path _((VALUE)); void rb_set_class_path _((VALUE, VALUE, const char*)); VALUE rb_path2class _((const char*)); void rb_name_class _((VALUE, ID)); +VALUE rb_class_name _((VALUE)); void rb_autoload _((VALUE, ID, const char*)); void rb_autoload_load _((VALUE, ID)); VALUE rb_autoload_p _((VALUE, ID)); @@ -1236,7 +1236,7 @@ rb_mod_to_s(klass) return s; } - return rb_str_dup(rb_class_path(klass)); + return rb_str_dup(rb_class_name(klass)); } /* diff --git a/variable.c b/variable.c index 17832df8e6..e97eef0f7a 100644 --- a/variable.c +++ b/variable.c @@ -146,7 +146,6 @@ classname(klass) { VALUE path = Qnil; - klass = rb_class_real(klass); if (!klass) klass = rb_cObject; if (ROBJECT(klass)->iv_tbl) { if (!st_lookup(ROBJECT(klass)->iv_tbl, classpath, &path)) { @@ -281,11 +280,18 @@ rb_name_class(klass, id) rb_iv_set(klass, "__classid__", ID2SYM(id)); } +VALUE +rb_class_name(klass) + VALUE klass; +{ + return rb_class_path(rb_class_real(klass)); +} + char * rb_class2name(klass) VALUE klass; { - return RSTRING(rb_class_path(klass))->ptr; + return RSTRING(rb_class_name(klass))->ptr; } char * @@ -1193,7 +1199,7 @@ uninitialized_constant(klass, id) { if (klass && klass != rb_cObject) rb_name_error(id, "uninitialized constant %s::%s", - RSTRING(rb_class_path(klass))->ptr, + rb_class2name(klass), rb_id2name(id)); else { rb_name_error(id, "uninitialized constant %s", rb_id2name(id)); |