[#23884] Ruby 1.8.2 preview1にむけて — matz@... (Yukihiro Matsumoto)

まつもと ゆきひろです

34 messages 2004/07/13
[#23917] Re: Ruby 1.8.2 preview1にむけて — "H.Yamamoto" <ocean@...2.ccsnet.ne.jp> 2004/07/16

山本です。

[#23920] Re: Ruby 1.8.2 preview1にむけて — "NAKAMURA, Hiroshi" <nakahiro@...> 2004/07/16

なひです。

[#23922] ruby 1.8.2 preview1 — matz@... (Yukihiro Matsumoto)

まつもと ゆきひろです

27 messages 2004/07/16

[#23995] String#each -> String#each_char — Shugo Maeda <shugo@...>

前田です。

27 messages 2004/07/30
[#23996] Re: String#each -> String#each_char — matz@... (Yukihiro Matsumoto) 2004/07/30

まつもと ゆきひろです

[#23997] Re: String#each -> String#each_char — "U.Nakamura" <usa@...> 2004/07/30

こんにちは、なかむら(う)です。

[#23999] Re: String#each -> String#each_char — matz@... (Yukihiro Matsumoto) 2004/07/30

まつもと ゆきひろです

[#24000] Re: String#each -> String#each_char — "U.Nakamura" <usa@...> 2004/07/30

こんにちは、なかむら(う)です。

[#24005] Re: String#each -> String#each_char — Minero Aoki <aamine@...> 2004/07/31

青木です。

[#24012] Re: String#each -> String#each_char — Shugo Maeda <shugo@...> 2004/08/01

前田です。

[#24014] Re: String#each -> String#each_char — Minero Aoki <aamine@...> 2004/08/02

青木です。

[ruby-dev:23902] Re: Ruby 1.8.2 preview1にむけて

From: "H.Yamamoto" <ocean@...2.ccsnet.ne.jp>
Date: 2004-07-14 12:32:43 UTC
List: ruby-dev #23902
山本です。

nobu.nakada@nifty.ne.jp wrote:
(2004/07/14 19:43)

>これでバックポートできるはずです。
>
>cvs dif -kk -D2004-01-19\ {09,10}:00+00 -ISystemStackError \
>class.c error.c eval.c intern.h object.c variable.c

これを元に手パッチしました。どなたか確認してくださると幸いです。
test/ruby が通ることは確認しました。

class.c に、一部 rdoc の修正が入っています。

Index: class.c
===================================================================
RCS file: /var/cvs/src/ruby/class.c,v
retrieving revision 1.80.2.3
diff -u -w -b -p -r1.80.2.3 class.c
--- class.c	12 May 2004 02:51:54 -0000	1.80.2.3
+++ class.c	14 Jul 2004 12:22:34 -0000
@@ -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, m
 
 /*
  *  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, m
  *     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, mo
 
 /*
  *  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
 
 /*
  *  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, 
 
 /*
  *  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, a
 
 /*
  *  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, a
  *     a = Single.new
  *     
  *     def a.one()
+ *     end
  *     
  *     class << a
- *     end
  *       include Other
  *       def two()
  *     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

Index: error.c
===================================================================
RCS file: /var/cvs/src/ruby/error.c,v
retrieving revision 1.85.2.5
diff -u -w -b -p -r1.85.2.5 error.c
--- error.c	23 Apr 2004 14:26:20 -0000	1.85.2.5
+++ error.c	14 Jul 2004 10:14:20 -0000
@@ -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);

Index: eval.c
===================================================================
RCS file: /var/cvs/src/ruby/eval.c,v
retrieving revision 1.616.2.34
diff -u -w -b -p -r1.616.2.34 eval.c
--- eval.c	9 Jul 2004 05:29:45 -0000	1.616.2.34
+++ eval.c	14 Jul 2004 12:03:09 -0000
@@ -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);

Index: intern.h
===================================================================
RCS file: /var/cvs/src/ruby/intern.h,v
retrieving revision 1.139.2.3
diff -u -w -b -p -r1.139.2.3 intern.h
--- intern.h	29 Jun 2004 01:31:37 -0000	1.139.2.3
+++ intern.h	14 Jul 2004 12:04:48 -0000
@@ -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));

Index: object.c
===================================================================
RCS file: /var/cvs/src/ruby/object.c,v
retrieving revision 1.134.2.11
diff -u -w -b -p -r1.134.2.11 object.c
--- object.c	24 Jun 2004 23:31:28 -0000	1.134.2.11
+++ object.c	14 Jul 2004 12:05:30 -0000
@@ -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));
 }
 
 /*

Index: variable.c
===================================================================
RCS file: /var/cvs/src/ruby/variable.c,v
retrieving revision 1.108.2.2
diff -u -w -b -p -r1.108.2.2 variable.c
--- variable.c	29 Dec 2003 03:56:01 -0000	1.108.2.2
+++ variable.c	14 Jul 2004 12:09:11 -0000
@@ -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));


In This Thread