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

ruby-changes:65060

From: =E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3 <ko1@a...>
Date: Wed, 27 Jan 2021 09:30:45 +0900 (JST)
Subject: [ruby-changes:65060] f8a117f858 (master): kill CLONESETUP and DUPSETUP

https://git.ruby-lang.org/ruby.git/commit/?id=f8a117f858

From f8a117f858cdb748c400396aa5a4d46e4832f4e2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3?=
 <shyouhei@r...>
Date: Tue, 26 Jan 2021 09:48:49 +0900
Subject: kill CLONESETUP and DUPSETUP

They are no longer how Object#clone/Object#dup are defined.  In fact
DUPSETUP is not used from anywhere.  CLONESETUP has only one usage.
Let's not expose them to extension libraries.

cf https://github.com/ruby/ruby/pull/4100#discussion_r563481718
---
 include/ruby/internal/fl_type.h | 14 +++++++++++++-
 include/ruby/internal/newobj.h  | 18 +++++-------------
 proc.c                          | 17 +++++++++++++++++
 3 files changed, 35 insertions(+), 14 deletions(-)

diff --git a/include/ruby/internal/fl_type.h b/include/ruby/internal/fl_type.h
index 29cc6ba..4bfae26 100644
--- a/include/ruby/internal/fl_type.h
+++ b/include/ruby/internal/fl_type.h
@@ -227,7 +227,19 @@ ruby_fl_type { https://github.com/ruby/ruby/blob/trunk/include/ruby/internal/fl_type.h#L227
     RUBY_FL_SINGLETON = RUBY_FL_USER0,
 };
 
-enum { RUBY_FL_DUPPED = RUBY_T_MASK | RUBY_FL_EXIVAR | RUBY_FL_SHAREABLE };
+enum {
+    RUBY_FL_DUPPED
+
+#if RBIMPL_HAS_EXTENSION(enumerator_attributes)
+    RBIMPL_ATTR_DEPRECATED(("It seems there is no actual usage of this enum."))
+#elif RBIMPL_COMPILER_SINCE(GCC, 6, 0, 0)
+    RBIMPL_ATTR_DEPRECATED(("It seems there is no actual usage of this enum."))
+#elif defined(_MSC_VER)
+# pragma deprecated(RUBY_FL_UNTRUSTED)
+#endif
+
+    = RUBY_T_MASK | RUBY_FL_EXIVAR
+};
 
 RBIMPL_SYMBOL_EXPORT_BEGIN()
 void rb_obj_infect(VALUE victim, VALUE carrier);
diff --git a/include/ruby/internal/newobj.h b/include/ruby/internal/newobj.h
index 684226e..1bb4f0e 100644
--- a/include/ruby/internal/newobj.h
+++ b/include/ruby/internal/newobj.h
@@ -20,6 +20,7 @@ https://github.com/ruby/ruby/blob/trunk/include/ruby/internal/newobj.h#L20
  *             extension libraries. They could be written in C++98.
  * @brief      Defines #NEWOBJ.
  */
+#include "ruby/internal/attr/deprecated.h"
 #include "ruby/internal/cast.h"
 #include "ruby/internal/core/rbasic.h"
 #include "ruby/internal/dllexport.h"
@@ -47,27 +48,18 @@ void rb_singleton_class_attached(VALUE,VALUE); https://github.com/ruby/ruby/blob/trunk/include/ruby/internal/newobj.h#L48
 void rb_copy_generic_ivar(VALUE,VALUE);
 RBIMPL_SYMBOL_EXPORT_END()
 
+RBIMPL_ATTR_DEPRECATED(("This is no longer how Object#clone works."))
 static inline void
 rb_clone_setup(VALUE clone, VALUE obj)
 {
-    RBIMPL_ASSERT_OR_ASSUME(! RB_SPECIAL_CONST_P(obj));
-    RBIMPL_ASSERT_OR_ASSUME(! RB_SPECIAL_CONST_P(clone));
-
-    const VALUE flags = RUBY_FL_PROMOTED0 | RUBY_FL_PROMOTED1 | RUBY_FL_FINALIZE;
-    rb_obj_setup(clone, rb_singleton_class_clone(obj),
-                 RB_FL_TEST_RAW(obj, ~flags));
-    rb_singleton_class_attached(RBASIC_CLASS(clone), clone);
-    if (RB_FL_TEST(obj, RUBY_FL_EXIVAR)) rb_copy_generic_ivar(clone, obj);
+    return;
 }
 
+RBIMPL_ATTR_DEPRECATED(("This is no longer how Object#dup works."))
 static inline void
 rb_dup_setup(VALUE dup, VALUE obj)
 {
-    RBIMPL_ASSERT_OR_ASSUME(! RB_SPECIAL_CONST_P(obj));
-    RBIMPL_ASSERT_OR_ASSUME(! RB_SPECIAL_CONST_P(dup));
-
-    rb_obj_setup(dup, rb_obj_class(obj), RB_FL_TEST_RAW(obj, RUBY_FL_DUPPED));
-    if (RB_FL_TEST(obj, RUBY_FL_EXIVAR)) rb_copy_generic_ivar(dup, obj);
+    return;
 }
 
 #endif /* RBIMPL_NEWOBJ_H */
diff --git a/proc.c b/proc.c
index d087004..a4ea995 100644
--- a/proc.c
+++ b/proc.c
@@ -56,6 +56,23 @@ static VALUE proc_binding(VALUE self); https://github.com/ruby/ruby/blob/trunk/proc.c#L56
 
 #define IS_METHOD_PROC_IFUNC(ifunc) ((ifunc)->func == bmcall)
 
+/* :FIXME: The way procs are cloned has been historically different from the
+ * way everything else are.  @shyouhei is not sure for the intention though.
+ */
+#undef CLONESETUP
+static inline void
+CLONESETUP(VALUE clone, VALUE obj)
+{
+    RBIMPL_ASSERT_OR_ASSUME(! RB_SPECIAL_CONST_P(obj));
+    RBIMPL_ASSERT_OR_ASSUME(! RB_SPECIAL_CONST_P(clone));
+
+    const VALUE flags = RUBY_FL_PROMOTED0 | RUBY_FL_PROMOTED1 | RUBY_FL_FINALIZE;
+    rb_obj_setup(clone, rb_singleton_class_clone(obj),
+                 RB_FL_TEST_RAW(obj, ~flags));
+    rb_singleton_class_attached(RBASIC_CLASS(clone), clone);
+    if (RB_FL_TEST(obj, RUBY_FL_EXIVAR)) rb_copy_generic_ivar(clone, obj);
+}
+
 static void
 block_mark(const struct rb_block *block)
 {
-- 
cgit v1.1


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

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