summaryrefslogtreecommitdiff
path: root/proc.c
diff options
context:
space:
mode:
author卜部昌平 <shyouhei@ruby-lang.org>2021-01-26 09:48:49 +0900
committer卜部昌平 <shyouhei@ruby-lang.org>2021-01-27 09:30:15 +0900
commitf8a117f858cdb748c400396aa5a4d46e4832f4e2 (patch)
treeb068c843d9c887da30532fd3e38d45e1a6e7ecb5 /proc.c
parent73e948afd5d465548868189d1bd0a8d35e238fb2 (diff)
downloadruby-f8a117f858cdb748c400396aa5a4d46e4832f4e2.tar.gz
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
Diffstat (limited to 'proc.c')
-rw-r--r--proc.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/proc.c b/proc.c
index d0870042f8..a4ea99598e 100644
--- a/proc.c
+++ b/proc.c
@@ -56,6 +56,23 @@ static VALUE proc_binding(VALUE self);
#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)
{