[#3006] CVS repository — "Eugene Scripnik" <hoaz@...>

Hello.

21 messages 2004/06/16
[#3008] Re: CVS repository — ts <decoux@...> 2004/06/16

>>>>> "E" == Eugene Scripnik <hoaz@gala.net> writes:

[#3009] Re: CVS repository — Michal Rokos <michal@...> 2004/06/16

Hi!

[#3057] Ruby 1.8.2 to be released. — matz@... (Yukihiro Matsumoto)

Hi,

20 messages 2004/06/23

Re: [Doc] obj.singleton_methods

From: Michal Rokos <michal@...>
Date: 2004-06-15 13:59:49 UTC
List: ruby-core #3002
OK,

On Monday 14 of June 2004 22:08, Michal Rokos wrote:
> doc or Object#singleton_methods is wrong.
>
> The default is true = all methods (not false)....
>
> Is ether ruby bug/or doc bug...
>
> Wasn't been thinking about, just sending in order not to forget it...

I had a look and it's doc problem. So here's the patch for doc.

	Michal

> PS: And small cleanup for rb_define_method() as bonus :)

Index: class.c
===================================================================
RCS file: /var/cvs/src/ruby/class.c,v
retrieving revision 1.85
diff -u -p -r1.85 class.c
--- class.c     12 May 2004 02:51:29 -0000      1.85
+++ class.c     15 Jun 2004 13:56:50 -0000
@@ -632,14 +632,14 @@ 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
- *  class, they are the instance (not singleton) methods. With no
- *  argument, or with an argument that is <code>false</code>, the
- *  instance methods in <i>mod</i> are returned, otherwise the methods
- *  in <i>mod</i> and <i>mod</i>'s superclasses are returned.
+ *  class, they are the instance (not singleton) methods. With an 
argument
+ *  that is <code>false</code>, the instance methods in <i>mod</i> are
+ *  returned, otherwise the methods in <i>mod</i> and <i>mod</i>'s
+ *  superclasses are returned.
  *
  *     module A
  *       def method1()  end
@@ -652,8 +652,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
  */

@@ -668,7 +668,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
@@ -686,7 +686,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
@@ -712,7 +712,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
@@ -730,7 +730,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
@@ -756,8 +756,8 @@ rb_class_public_instance_methods(argc, a
  *     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
@@ -769,10 +769,13 @@ rb_obj_singleton_methods(argc, argv, obj
     VALUE recur, ary, klass;
     st_table *list;

-    rb_scan_args(argc, argv, "01", &recur);
     if (argc == 0) {
        recur = Qtrue;
     }
+    else {
+       rb_scan_args(argc, argv, "01", &recur);
+    }
+
     klass = CLASS_OF(obj);
     list = st_init_numtable();
     if (klass && FL_TEST(klass, FL_SINGLETON)) {
@@ -809,11 +812,7 @@ rb_define_method(klass, name, func, argc
     VALUE (*func)();
     int argc;
 {
-    ID id = rb_intern(name);
-    int ex = NOEX_PUBLIC;
-
-
-    rb_add_method(klass, id, NEW_CFUNC(func, argc), ex);
+    rb_add_method(klass, rb_intern(name), NEW_CFUNC(func, argc), 
NOEX_PUBLIC);
 }

 void

In This Thread

Prev Next