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

ruby-changes:34946

From: nobu <ko1@a...>
Date: Sat, 2 Aug 2014 10:27:11 +0900 (JST)
Subject: [ruby-changes:34946] nobu:r47028 (trunk): object.c: Object#itsef

nobu	2014-08-02 10:26:58 +0900 (Sat, 02 Aug 2014)

  New Revision: 47028

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

  Log:
    object.c: Object#itsef
    
    * object.c (rb_obj_itself): new method Object#itsef.  based on the
      patch by Rafael Fran?\195?\167a in [ruby-core:64156].
      [EXPERIMENTAL] this method may be renamed due to compatibilities.
      [ruby-core:44704] [Feature #6373]

  Modified files:
    trunk/ChangeLog
    trunk/NEWS
    trunk/object.c
    trunk/test/ruby/test_object.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 47027)
+++ ChangeLog	(revision 47028)
@@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sat Aug  2 10:26:57 2014  Nobuyoshi Nakada  <nobu@r...>
+
+	* object.c (rb_obj_itself): new method Object#itsef.  based on the
+	  patch by Rafael Franca in [ruby-core:64156].
+	  [EXPERIMENTAL] this method may be renamed due to compatibilities.
+	  [ruby-core:44704] [Feature #6373]
+
 Fri Aug  1 22:30:40 2014  Masaki Suketa <masaki.suketa@n...>
 
 	* ext/win32ole/win32ole.c (folerecord_inititalize): accept
Index: object.c
===================================================================
--- object.c	(revision 47027)
+++ object.c	(revision 47028)
@@ -402,6 +402,23 @@ rb_obj_dup(VALUE obj) https://github.com/ruby/ruby/blob/trunk/object.c#L402
     return dup;
 }
 
+/*
+ *  call-seq:
+ *     obj.itself -> an_object
+ *
+ *  Returns <i>obj</i>.
+ *
+ *	string = 'my string' #=> "my string"
+ *	string.itself.object_id == string.object_id #=> true
+ *
+ */
+
+static VALUE
+rb_obj_itself(VALUE obj)
+{
+    return obj;
+}
+
 /* :nodoc: */
 VALUE
 rb_obj_init_copy(VALUE obj, VALUE orig)
@@ -3302,6 +3319,7 @@ Init_Object(void) https://github.com/ruby/ruby/blob/trunk/object.c#L3319
     rb_define_method(rb_mKernel, "singleton_class", rb_obj_singleton_class, 0);
     rb_define_method(rb_mKernel, "clone", rb_obj_clone, 0);
     rb_define_method(rb_mKernel, "dup", rb_obj_dup, 0);
+    rb_define_method(rb_mKernel, "itself", rb_obj_itself, 0);
     rb_define_method(rb_mKernel, "initialize_copy", rb_obj_init_copy, 1);
     rb_define_method(rb_mKernel, "initialize_dup", rb_obj_init_dup_clone, 1);
     rb_define_method(rb_mKernel, "initialize_clone", rb_obj_init_dup_clone, 1);
Index: NEWS
===================================================================
--- NEWS	(revision 47027)
+++ NEWS	(revision 47028)
@@ -41,6 +41,10 @@ with all sufficient information, see the https://github.com/ruby/ruby/blob/trunk/NEWS#L41
   * New methods:
     * File::Stat#birthtime
 
+* Kernel
+  * New methods:
+    * Kernel#itself
+
 * Process
   * Extended method:
     * Process execution methods such as Process.spawn opens the file in write
Index: test/ruby/test_object.rb
===================================================================
--- test/ruby/test_object.rb	(revision 47027)
+++ test/ruby/test_object.rb	(revision 47028)
@@ -12,6 +12,12 @@ class TestObject < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_object.rb#L12
     $VERBOSE = @verbose
   end
 
+  def test_itself
+    feature6373 = '[ruby-core:44704] [Feature #6373]'
+    object = Object.new
+    assert_same(object, object.itself, feature6373)
+  end
+
   def test_dup
     assert_raise(TypeError) { 1.dup }
     assert_raise(TypeError) { true.dup }

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

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