diff options
author | 卜部昌平 <[email protected]> | 2021-01-26 09:48:49 +0900 |
---|---|---|
committer | 卜部昌平 <[email protected]> | 2021-01-27 09:30:15 +0900 |
commit | f8a117f858cdb748c400396aa5a4d46e4832f4e2 (patch) | |
tree | b068c843d9c887da30532fd3e38d45e1a6e7ecb5 /proc.c | |
parent | 73e948afd5d465548868189d1bd0a8d35e238fb2 (diff) |
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.c | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -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) { |