mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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
This commit is contained in:
parent
73e948afd5
commit
f8a117f858
3 changed files with 35 additions and 14 deletions
|
@ -227,7 +227,19 @@ ruby_fl_type {
|
|||
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);
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
* 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);
|
|||
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 */
|
||||
|
|
17
proc.c
17
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)
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue