diff options
-rw-r--r-- | include/ruby/internal/fl_type.h | 14 | ||||
-rw-r--r-- | include/ruby/internal/newobj.h | 18 | ||||
-rw-r--r-- | 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 29cc6baf6c..4bfae26817 100644 --- a/include/ruby/internal/fl_type.h +++ b/include/ruby/internal/fl_type.h @@ -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); diff --git a/include/ruby/internal/newobj.h b/include/ruby/internal/newobj.h index 684226e54b..1bb4f0efa3 100644 --- a/include/ruby/internal/newobj.h +++ b/include/ruby/internal/newobj.h @@ -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 */ @@ -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) { |