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?= 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 --- proc.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'proc.c') 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) { -- cgit v1.2.1