[前][次][番号順一覧][スレッド一覧]

ruby-changes:27397

From: zzak <ko1@a...>
Date: Sun, 24 Feb 2013 13:25:05 +0900 (JST)
Subject: [ruby-changes:27397] zzak:r39449 (trunk): * object.c: Document methods receiving string and convert to symbol

zzak	2013-02-24 13:24:52 +0900 (Sun, 24 Feb 2013)

  New Revision: 39449

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=39449

  Log:
    * object.c: Document methods receiving string and convert to symbol
      Patch by Stefan Rusterholz
    * vm_eval.c: ditto
    * vm_method.c: ditto

  Modified files:
    trunk/ChangeLog
    trunk/object.c
    trunk/vm_eval.c
    trunk/vm_method.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 39448)
+++ ChangeLog	(revision 39449)
@@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Wed Feb 20 13:23:00 2013  Zachary Scott  <zachary@z...>
+
+	* object.c: Document methods receiving string and convert to symbol
+	  Patch by Stefan Rusterholz
+	* vm_eval.c: ditto
+	* vm_method.c: ditto
+
 Wed Feb 20 07:20:56 2013  KOSAKI Motohiro  <kosaki.motohiro@g...>
 
 	* signal.c (sigsegv): suppress unused result warning. Because
Index: object.c
===================================================================
--- object.c	(revision 39448)
+++ object.c	(revision 39449)
@@ -1806,12 +1806,15 @@ rb_class_get_superclass(VALUE klass) https://github.com/ruby/ruby/blob/trunk/object.c#L1806
 
 /*
  *  call-seq:
- *     attr_reader(symbol, ...)    -> nil
- *     attr(symbol, ...)             -> nil
+ *     attr_reader(symbol, ...)  -> nil
+ *     attr(symbol, ...)         -> nil
+ *     attr_reader(string, ...)  -> nil
+ *     attr(string, ...)         -> nil
  *
  *  Creates instance variables and corresponding methods that return the
  *  value of each instance variable. Equivalent to calling
  *  ``<code>attr</code><i>:name</i>'' on each name in turn.
+ *  String arguments are converted to symbols.
  */
 
 static VALUE
@@ -1839,9 +1842,11 @@ rb_mod_attr(int argc, VALUE *argv, VALUE https://github.com/ruby/ruby/blob/trunk/object.c#L1842
 /*
  *  call-seq:
  *      attr_writer(symbol, ...)    -> nil
+ *      attr_writer(string, ...)    -> nil
  *
  *  Creates an accessor method to allow assignment to the attribute
  *  <i>symbol</i><code>.id2name</code>.
+ *  String arguments are converted to symbols.
  */
 
 static VALUE
@@ -1858,11 +1863,13 @@ rb_mod_attr_writer(int argc, VALUE *argv https://github.com/ruby/ruby/blob/trunk/object.c#L1863
 /*
  *  call-seq:
  *     attr_accessor(symbol, ...)    -> nil
+ *     attr_accessor(string, ...)    -> nil
  *
  *  Defines a named attribute for this module, where the name is
  *  <i>symbol.</i><code>id2name</code>, creating an instance variable
  *  (<code>@name</code>) and a corresponding access method to read it.
  *  Also creates a method called <code>name=</code> to set the attribute.
+ *  String arguments are converted to symbols.
  *
  *     module Mod
  *       attr_accessor(:one, :two)
@@ -2084,12 +2091,14 @@ rb_mod_const_defined(int argc, VALUE *ar https://github.com/ruby/ruby/blob/trunk/object.c#L2091
 /*
  *  call-seq:
  *     obj.instance_variable_get(symbol)    -> obj
+ *     obj.instance_variable_get(string)    -> obj
  *
  *  Returns the value of the given instance variable, or nil if the
  *  instance variable is not set. The <code>@</code> part of the
  *  variable name should be included for regular instance
  *  variables. Throws a <code>NameError</code> exception if the
  *  supplied symbol is not valid as an instance variable name.
+ *  String arguments are converted to symbols.
  *
  *     class Fred
  *       def initialize(p1, p2)
@@ -2125,11 +2134,14 @@ rb_obj_ivar_get(VALUE obj, VALUE iv) https://github.com/ruby/ruby/blob/trunk/object.c#L2134
 /*
  *  call-seq:
  *     obj.instance_variable_set(symbol, obj)    -> obj
+ *     obj.instance_variable_set(string, obj)    -> obj
  *
  *  Sets the instance variable names by <i>symbol</i> to
  *  <i>object</i>, thereby frustrating the efforts of the class's
  *  author to attempt to provide proper encapsulation. The variable
  *  did not have to exist prior to this call.
+ *  If the instance variable name is passed as a string, that string
+ *  is converted to a symbol.
  *
  *     class Fred
  *       def initialize(p1, p2)
@@ -2157,9 +2169,11 @@ rb_obj_ivar_set(VALUE obj, VALUE iv, VAL https://github.com/ruby/ruby/blob/trunk/object.c#L2169
 /*
  *  call-seq:
  *     obj.instance_variable_defined?(symbol)    -> true or false
+ *     obj.instance_variable_defined?(string)    -> true or false
  *
  *  Returns <code>true</code> if the given instance variable is
  *  defined in <i>obj</i>.
+ *  String arguments are converted to symbols.
  *
  *     class Fred
  *       def initialize(p1, p2)
@@ -2196,10 +2210,12 @@ rb_obj_ivar_defined(VALUE obj, VALUE iv) https://github.com/ruby/ruby/blob/trunk/object.c#L2210
 /*
  *  call-seq:
  *     mod.class_variable_get(symbol)    -> obj
+ *     mod.class_variable_get(string)    -> obj
  *
  *  Returns the value of the given class variable (or throws a
  *  <code>NameError</code> exception). The <code>@@</code> part of the
  *  variable name should be included for regular class variables
+ *  String arguments are converted to symbols.
  *
  *     class Fred
  *       @@foo = 99
@@ -2232,9 +2248,12 @@ rb_mod_cvar_get(VALUE obj, VALUE iv) https://github.com/ruby/ruby/blob/trunk/object.c#L2248
 /*
  *  call-seq:
  *     obj.class_variable_set(symbol, obj)    -> obj
+ *     obj.class_variable_set(string, obj)    -> obj
  *
  *  Sets the class variable names by <i>symbol</i> to
  *  <i>object</i>.
+ *  If the class variable name is passed as a string, that string
+ *  is converted to a symbol.
  *
  *     class Fred
  *       @@foo = 99
@@ -2262,9 +2281,11 @@ rb_mod_cvar_set(VALUE obj, VALUE iv, VAL https://github.com/ruby/ruby/blob/trunk/object.c#L2281
 /*
  *  call-seq:
  *     obj.class_variable_defined?(symbol)    -> true or false
+ *     obj.class_variable_defined?(string)    -> true or false
  *
  *  Returns <code>true</code> if the given class variable is defined
  *  in <i>obj</i>.
+ *  String arguments are converted to symbols.
  *
  *     class Fred
  *       @@foo = 99
Index: vm_eval.c
===================================================================
--- vm_eval.c	(revision 39448)
+++ vm_eval.c	(revision 39449)
@@ -862,13 +862,17 @@ send_internal(int argc, const VALUE *arg https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L862
 }
 
 /*
- *  call-seq:
- *     foo.send(symbol [, args...])        -> obj
- *     foo.__send__(symbol [, args...])      -> obj
+ * call-seq:
+ *    foo.send(symbol [, args...])       -> obj
+ *    foo.__send__(symbol [, args...])   -> obj
+ *    foo.send(string [, args...])       -> obj
+ *    foo.__send__(string [, args...])   -> obj
  *
  *  Invokes the method identified by _symbol_, passing it any
  *  arguments specified. You can use <code>__send__</code> if the name
  *  +send+ clashes with an existing method in _obj_.
+ *  When the method is identified by a string, the string is converted
+ *  to a symbol.
  *
  *     class Klass
  *       def hello(*args)
@@ -888,10 +892,13 @@ rb_f_send(int argc, VALUE *argv, VALUE r https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L892
 /*
  *  call-seq:
  *     obj.public_send(symbol [, args...])  -> obj
+ *     obj.public_send(string [, args...])  -> obj
  *
  *  Invokes the method identified by _symbol_, passing it any
  *  arguments specified. Unlike send, public_send calls public
  *  methods only.
+ *  When the method is identified by a string, the string is converted
+ *  to a symbol.
  *
  *     1.public_send(:puts, "hello")  # causes NoMethodError
  */
Index: vm_method.c
===================================================================
--- vm_method.c	(revision 39448)
+++ vm_method.c	(revision 39449)
@@ -693,9 +693,11 @@ rb_remove_method(VALUE klass, const char https://github.com/ruby/ruby/blob/trunk/vm_method.c#L693
 /*
  *  call-seq:
  *     remove_method(symbol)   -> self
+ *     remove_method(string)   -> self
  *
  *  Removes the method identified by _symbol_ from the current
  *  class. For an example, see <code>Module.undef_method</code>.
+ *  String arguments are converted to symbols.
  */
 
 static VALUE
@@ -878,11 +880,13 @@ rb_undef(VALUE klass, ID id) https://github.com/ruby/ruby/blob/trunk/vm_method.c#L880
 /*
  *  call-seq:
  *     undef_method(symbol)    -> self
+ *     undef_method(string)    -> self
  *
  *  Prevents the current class from responding to calls to the named
  *  method. Contrast this with <code>remove_method</code>, which deletes
  *  the method from the particular class; Ruby will still search
  *  superclasses and mixed-in modules for a possible receiver.
+ *  String arguments are converted to symbols.
  *
  *     class Parent
  *       def hello
@@ -936,10 +940,12 @@ rb_mod_undef_method(int argc, VALUE *arg https://github.com/ruby/ruby/blob/trunk/vm_method.c#L940
 /*
  *  call-seq:
  *     mod.method_defined?(symbol)    -> true or false
+ *     mod.method_defined?(string)    -> true or false
  *
  *  Returns +true+ if the named method is defined by
  *  _mod_ (or its included modules and, if _mod_ is a class,
  *  its ancestors). Public and protected methods are matched.
+ *  String arguments are converted to symbols.
  *
  *     module A
  *       def method1()  end
@@ -989,10 +995,12 @@ check_definition(VALUE mod, VALUE mid, r https://github.com/ruby/ruby/blob/trunk/vm_method.c#L995
 /*
  *  call-seq:
  *     mod.public_method_defined?(symbol)   -> true or false
+ *     mod.public_method_defined?(string)   -> true or false
  *
  *  Returns +true+ if the named public method is defined by
  *  _mod_ (or its included modules and, if _mod_ is a class,
  *  its ancestors).
+ *  String arguments are converted to symbols.
  *
  *     module A
  *       def method1()  end
@@ -1021,10 +1029,12 @@ rb_mod_public_method_defined(VALUE mod, https://github.com/ruby/ruby/blob/trunk/vm_method.c#L1029
 /*
  *  call-seq:
  *     mod.private_method_defined?(symbol)    -> true or false
+ *     mod.private_method_defined?(string)    -> true or false
  *
  *  Returns +true+ if the named private method is defined by
  *  _ mod_ (or its included modules and, if _mod_ is a class,
  *  its ancestors).
+ *  String arguments are converted to symbols.
  *
  *     module A
  *       def method1()  end
@@ -1053,10 +1063,12 @@ rb_mod_private_method_defined(VALUE mod, https://github.com/ruby/ruby/blob/trunk/vm_method.c#L1063
 /*
  *  call-seq:
  *     mod.protected_method_defined?(symbol)   -> true or false
+ *     mod.protected_method_defined?(string)   -> true or false
  *
  *  Returns +true+ if the named protected method is defined
  *  by _mod_ (or its included modules and, if _mod_ is a
  *  class, its ancestors).
+ *  String arguments are converted to symbols.
  *
  *     module A
  *       def method1()  end
@@ -1274,10 +1286,12 @@ set_method_visibility(VALUE self, int ar https://github.com/ruby/ruby/blob/trunk/vm_method.c#L1286
  *  call-seq:
  *     public                 -> self
  *     public(symbol, ...)    -> self
+ *     public(string, ...)    -> self
  *
  *  With no arguments, sets the default visibility for subsequently
  *  defined methods to public. With arguments, sets the named methods to
  *  have public visibility.
+ *  String arguments are converted to symbols.
  */
 
 static VALUE
@@ -1297,10 +1311,12 @@ rb_mod_public(int argc, VALUE *argv, VAL https://github.com/ruby/ruby/blob/trunk/vm_method.c#L1311
  *  call-seq:
  *     protected                -> self
  *     protected(symbol, ...)   -> self
+ *     protected(string, ...)   -> self
  *
  *  With no arguments, sets the default visibility for subsequently
  *  defined methods to protected. With arguments, sets the named methods
  *  to have protected visibility.
+ *  String arguments are converted to symbols.
  */
 
 static VALUE
@@ -1320,10 +1336,12 @@ rb_mod_protected(int argc, VALUE *argv, https://github.com/ruby/ruby/blob/trunk/vm_method.c#L1336
  *  call-seq:
  *     private                 -> self
  *     private(symbol, ...)    -> self
+ *     private(string, ...)    -> self
  *
  *  With no arguments, sets the default visibility for subsequently
  *  defined methods to private. With arguments, sets the named methods
  *  to have private visibility.
+ *  String arguments are converted to symbols.
  *
  *     module Mod
  *       def a()  end
@@ -1351,8 +1369,11 @@ rb_mod_private(int argc, VALUE *argv, VA https://github.com/ruby/ruby/blob/trunk/vm_method.c#L1369
 /*
  *  call-seq:
  *     mod.public_class_method(symbol, ...)    -> mod
+ *     mod.public_class_method(string, ...)    -> mod
  *
  *  Makes a list of existing class methods public.
+ *
+ *  String arguments are converted to symbols.
  */
 
 static VALUE
@@ -1365,10 +1386,13 @@ rb_mod_public_method(int argc, VALUE *ar https://github.com/ruby/ruby/blob/trunk/vm_method.c#L1386
 /*
  *  call-seq:
  *     mod.private_class_method(symbol, ...)   -> mod
+ *     mod.private_class_method(string, ...)   -> mod
  *
  *  Makes existing class methods private. Often used to hide the default
  *  constructor <code>new</code>.
  *
+ *  String arguments are converted to symbols.
+ *
  *     class SimpleSingleton  # Not thread safe
  *       private_class_method :new
  *       def SimpleSingleton.create(*args, &block)
@@ -1389,10 +1413,13 @@ rb_mod_private_method(int argc, VALUE *a https://github.com/ruby/ruby/blob/trunk/vm_method.c#L1413
  *  call-seq:
  *     public
  *     public(symbol, ...)
+ *     public(string, ...)
  *
  *  With no arguments, sets the default visibility for subsequently
  *  defined methods to public. With arguments, sets the named methods to
  *  have public visibility.
+ *
+ *  String arguments are converted to symbols.
  */
 
 static VALUE
@@ -1410,6 +1437,7 @@ top_private(int argc, VALUE *argv) https://github.com/ruby/ruby/blob/trunk/vm_method.c#L1437
 /*
  *  call-seq:
  *     module_function(symbol, ...)    -> self
+ *     module_function(string, ...)    -> self
  *
  *  Creates module functions for the named methods. These functions may
  *  be called with the module as a receiver, and also become available
@@ -1418,6 +1446,7 @@ top_private(int argc, VALUE *argv) https://github.com/ruby/ruby/blob/trunk/vm_method.c#L1446
  *  independently. The instance-method versions are made private. If
  *  used with no arguments, subsequently defined methods become module
  *  functions.
+ *  String arguments are converted to symbols.
  *
  *     module Mod
  *       def one
@@ -1562,6 +1591,7 @@ rb_respond_to(VALUE obj, ID id) https://github.com/ruby/ruby/blob/trunk/vm_method.c#L1591
 /*
  *  call-seq:
  *     obj.respond_to?(symbol, include_all=false) -> true or false
+ *     obj.respond_to?(string, include_all=false) -> true or false
  *
  *  Returns +true+ if _obj_ responds to the given method.  Private and
  *  protected methods are included in the search only if the optional
@@ -1573,6 +1603,9 @@ rb_respond_to(VALUE obj, ID id) https://github.com/ruby/ruby/blob/trunk/vm_method.c#L1603
  *
  *  If the method is not defined, <code>respond_to_missing?</code>
  *  method is called and the result is returned.
+ *
+ *  When the method name parameter is given as a string, the string is
+ *  converted to a symbol.
  */
 
 static VALUE
@@ -1599,12 +1632,16 @@ obj_respond_to(int argc, VALUE *argv, VA https://github.com/ruby/ruby/blob/trunk/vm_method.c#L1632
 /*
  *  call-seq:
  *     obj.respond_to_missing?(symbol, include_all) -> true or false
+ *     obj.respond_to_missing?(string, include_all) -> true or false
  *
  *  DO NOT USE THIS DIRECTLY.
  *
  *  Hook method to return whether the _obj_ can respond to _id_ method
  *  or not.
  *
+ *  When the method name parameter is given as a string, the string is
+ *  converted to a symbol.
+ *
  *  See #respond_to?.
  */
 static VALUE

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]