[前][次][番号順一覧][スレッド一覧]

ruby-changes:64426

From: Nobuyoshi <ko1@a...>
Date: Tue, 22 Dec 2020 02:52:08 +0900 (JST)
Subject: [ruby-changes:64426] 8918a9cf6c (master): Removed rb_cData entity

https://git.ruby-lang.org/ruby.git/commit/?id=8918a9cf6c

From 8918a9cf6c65409ae1ffcdea324a1b97c6e5bb70 Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Tue, 22 Dec 2020 01:00:43 +0900
Subject: Removed rb_cData entity

* Use the wrapper of rb_cObject instead of data access
* Replaced rest of extentions
* Updated the version guard for Data
* Added the version guard of rb_cData

diff --git a/ext/-test-/st/numhash/numhash.c b/ext/-test-/st/numhash/numhash.c
index 71eeed4..aa8015e 100644
--- a/ext/-test-/st/numhash/numhash.c
+++ b/ext/-test-/st/numhash/numhash.c
@@ -125,7 +125,7 @@ numhash_delete_safe(VALUE self, VALUE key) https://github.com/ruby/ruby/blob/trunk/ext/-test-/st/numhash/numhash.c#L125
 void
 Init_numhash(void)
 {
-    VALUE st = rb_define_class_under(rb_define_module("Bug"), "StNumHash", rb_cData);
+    VALUE st = rb_define_class_under(rb_define_module("Bug"), "StNumHash", rb_cObject);
     rb_define_alloc_func(st, numhash_alloc);
     rb_define_method(st, "initialize", numhash_init, 0);
     rb_define_method(st, "[]", numhash_aref, 1);
diff --git a/ext/-test-/typeddata/typeddata.c b/ext/-test-/typeddata/typeddata.c
index 374cbdf..2adfd56 100644
--- a/ext/-test-/typeddata/typeddata.c
+++ b/ext/-test-/typeddata/typeddata.c
@@ -37,7 +37,7 @@ void https://github.com/ruby/ruby/blob/trunk/ext/-test-/typeddata/typeddata.c#L37
 Init_typeddata(void)
 {
     VALUE mBug = rb_define_module("Bug");
-    VALUE klass = rb_define_class_under(mBug, "TypedData", rb_cData);
+    VALUE klass = rb_define_class_under(mBug, "TypedData", rb_cObject);
     rb_define_alloc_func(klass, test_alloc);
     rb_define_singleton_method(klass, "check", test_check, 1);
     rb_define_singleton_method(klass, "make", test_make, 1);
diff --git a/ext/socket/ifaddr.c b/ext/socket/ifaddr.c
index 26aa0c8..da01325 100644
--- a/ext/socket/ifaddr.c
+++ b/ext/socket/ifaddr.c
@@ -459,7 +459,7 @@ rsock_init_sockifaddr(void) https://github.com/ruby/ruby/blob/trunk/ext/socket/ifaddr.c#L459
      *
      * Socket::Ifaddr represents a result of getifaddrs() function.
      */
-    rb_cSockIfaddr = rb_define_class_under(rb_cSocket, "Ifaddr", rb_cData);
+    rb_cSockIfaddr = rb_define_class_under(rb_cSocket, "Ifaddr", rb_cObject);
     rb_define_method(rb_cSockIfaddr, "inspect", ifaddr_inspect, 0);
     rb_define_method(rb_cSockIfaddr, "name", ifaddr_name, 0);
     rb_define_method(rb_cSockIfaddr, "ifindex", ifaddr_ifindex, 0);
diff --git a/ext/socket/raddrinfo.c b/ext/socket/raddrinfo.c
index a3e7e38..d99edfe 100644
--- a/ext/socket/raddrinfo.c
+++ b/ext/socket/raddrinfo.c
@@ -2568,7 +2568,7 @@ rsock_init_addrinfo(void) https://github.com/ruby/ruby/blob/trunk/ext/socket/raddrinfo.c#L2568
      */
     id_timeout = rb_intern("timeout");
 
-    rb_cAddrinfo = rb_define_class("Addrinfo", rb_cData);
+    rb_cAddrinfo = rb_define_class("Addrinfo", rb_cObject);
     rb_define_alloc_func(rb_cAddrinfo, addrinfo_s_allocate);
     rb_define_method(rb_cAddrinfo, "initialize", addrinfo_initialize, -1);
     rb_define_method(rb_cAddrinfo, "inspect", addrinfo_inspect, 0);
diff --git a/ext/stringio/stringio.c b/ext/stringio/stringio.c
index 0cc2f78..6c86e89 100644
--- a/ext/stringio/stringio.c
+++ b/ext/stringio/stringio.c
@@ -1755,7 +1755,7 @@ Init_stringio(void) https://github.com/ruby/ruby/blob/trunk/ext/stringio/stringio.c#L1755
   rb_ext_ractor_safe(true);
 #endif
 
-    VALUE StringIO = rb_define_class("StringIO", rb_cData);
+    VALUE StringIO = rb_define_class("StringIO", rb_cObject);
 
     rb_define_const(StringIO, "VERSION", rb_str_new_cstr(STRINGIO_VERSION));
 
diff --git a/include/ruby/internal/core/rdata.h b/include/ruby/internal/core/rdata.h
index 0824bbc..ca44a93 100644
--- a/include/ruby/internal/core/rdata.h
+++ b/include/ruby/internal/core/rdata.h
@@ -74,6 +74,7 @@ struct RData { https://github.com/ruby/ruby/blob/trunk/include/ruby/internal/core/rdata.h#L74
 RBIMPL_SYMBOL_EXPORT_BEGIN()
 VALUE rb_data_object_wrap(VALUE klass, void *datap, RUBY_DATA_FUNC dmark, RUBY_DATA_FUNC dfree);
 VALUE rb_data_object_zalloc(VALUE klass, size_t size, RUBY_DATA_FUNC dmark, RUBY_DATA_FUNC dfree);
+RUBY_EXTERN VALUE rb_cObject;
 RBIMPL_SYMBOL_EXPORT_END()
 
 #define Data_Wrap_Struct(klass, mark, free, sval) \
@@ -162,6 +163,15 @@ rb_data_object_alloc(VALUE klass, void *data, RUBY_DATA_FUNC dmark, RUBY_DATA_FU https://github.com/ruby/ruby/blob/trunk/include/ruby/internal/core/rdata.h#L163
     return rb_data_object_wrap(klass, data, dmark, dfree);
 }
 
+RBIMPL_ATTR_DEPRECATED(("by: rb_cObject.  Will be removed in 3.1."))
+RBIMPL_ATTR_PURE()
+static inline VALUE
+rb_cData(void)
+{
+    return rb_cObject;
+}
+#define rb_cData rb_cData()
+
 #define rb_data_object_wrap_0 rb_data_object_wrap
 #define rb_data_object_wrap_1 rb_data_object_wrap_warning
 #define rb_data_object_wrap   RUBY_MACRO_SELECT(rb_data_object_wrap_, RUBY_UNTYPED_DATA_WARNING)
diff --git a/include/ruby/internal/globals.h b/include/ruby/internal/globals.h
index 6b4e8fd..3bfbeac 100644
--- a/include/ruby/internal/globals.h
+++ b/include/ruby/internal/globals.h
@@ -20,7 +20,6 @@ https://github.com/ruby/ruby/blob/trunk/include/ruby/internal/globals.h#L20
  *             extension libraries. They could be written in C++98.
  * @brief      Ruby-level global variables / constants, visible from C.
  */
-#include "ruby/internal/attr/deprecated.h"
 #include "ruby/internal/attr/pure.h"
 #include "ruby/internal/dllexport.h"
 #include "ruby/internal/fl_type.h"
@@ -49,8 +48,6 @@ RUBY_EXTERN VALUE rb_cArray; https://github.com/ruby/ruby/blob/trunk/include/ruby/internal/globals.h#L48
 RUBY_EXTERN VALUE rb_cBinding;
 RUBY_EXTERN VALUE rb_cClass;
 RUBY_EXTERN VALUE rb_cCont;
-RBIMPL_ATTR_DEPRECATED(("by: rb_cObject.  Will be removed in 3.1."))
-RUBY_EXTERN VALUE rb_cData;
 RUBY_EXTERN VALUE rb_cDir;
 RUBY_EXTERN VALUE rb_cEncoding;
 RUBY_EXTERN VALUE rb_cEnumerator;
diff --git a/object.c b/object.c
index bf65254..6d45e25 100644
--- a/object.c
+++ b/object.c
@@ -32,7 +32,6 @@ https://github.com/ruby/ruby/blob/trunk/object.c#L32
 #include "internal/struct.h"
 #include "internal/symbol.h"
 #include "internal/variable.h"
-#include "internal/warnings.h"
 #include "probes.h"
 #include "ruby/encoding.h"
 #include "ruby/st.h"
@@ -4331,25 +4330,6 @@ f_sprintf(int c, const VALUE *v, VALUE _) https://github.com/ruby/ruby/blob/trunk/object.c#L4330
     return rb_f_sprintf(c, v);
 }
 
-COMPILER_WARNING_PUSH
-#if defined(_MSC_VER)
-COMPILER_WARNING_IGNORED(4996)
-#elif defined(__INTEL_COMPILER)
-COMPILER_WARNING_IGNORED(1786)
-#elif __has_warning("-Wdeprecated-declarations")
-COMPILER_WARNING_IGNORED(-Wdeprecated-declarations)
-#elif defined(__GNUC__)
-COMPILER_WARNING_IGNORED(-Wdeprecated-declarations)
-#endif
-
-static inline void
-Init_rb_cData(void)
-{
-    rb_cData = rb_cObject;
-}
-
-COMPILER_WARNING_POP
-
 /*
  *  Document-class: Class
  *
@@ -4682,8 +4662,6 @@ InitVM_Object(void) https://github.com/ruby/ruby/blob/trunk/object.c#L4662
     rb_undef_method(rb_cClass, "append_features");
     rb_undef_method(rb_cClass, "prepend_features");
 
-    Init_rb_cData();
-
     rb_cTrueClass = rb_define_class("TrueClass", rb_cObject);
     rb_cTrueClass_to_s = rb_fstring_enc_lit("true", rb_usascii_encoding());
     rb_gc_register_mark_object(rb_cTrueClass_to_s);
diff --git a/spec/ruby/core/data/constants_spec.rb b/spec/ruby/core/data/constants_spec.rb
index 5027ae0..a037bf6 100644
--- a/spec/ruby/core/data/constants_spec.rb
+++ b/spec/ruby/core/data/constants_spec.rb
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/data/constants_spec.rb#L1
 require_relative '../../spec_helper'
 
-ruby_version_is ''...'2.8' do
+ruby_version_is ''...'3.0' do
   describe "Data" do
     it "is a subclass of Object" do
       suppress_warning do
diff --git a/spec/ruby/optional/capi/ext/constants_spec.c b/spec/ruby/optional/capi/ext/constants_spec.c
index 598d30a..27899ca 100644
--- a/spec/ruby/optional/capi/ext/constants_spec.c
+++ b/spec/ruby/optional/capi/ext/constants_spec.c
@@ -14,7 +14,9 @@ defconstfunc(rb_cBinding) https://github.com/ruby/ruby/blob/trunk/spec/ruby/optional/capi/ext/constants_spec.c#L14
 defconstfunc(rb_cClass)
 defconstfunc(rb_cComplex)
 defconstfunc(rb_mComparable)
+#ifndef RUBY_VERSION_IS_3_0
 defconstfunc(rb_cData)
+#endif
 defconstfunc(rb_cDir)
 defconstfunc(rb_cEncoding)
 defconstfunc(rb_mEnumerable)
@@ -97,7 +99,9 @@ void Init_constants_spec(void) { https://github.com/ruby/ruby/blob/trunk/spec/ruby/optional/capi/ext/constants_spec.c#L99
   rb_define_method(cls, "rb_cClass", constants_spec_rb_cClass, 0);
   rb_define_method(cls, "rb_cComplex", constants_spec_rb_cComplex, 0);
   rb_define_method(cls, "rb_mComparable", constants_spec_rb_mComparable, 0);
+  #ifndef RUBY_VERSION_IS_3_0
   rb_define_method(cls, "rb_cData", constants_spec_rb_cData, 0);
+  #endif
   rb_define_method(cls, "rb_cDir", constants_spec_rb_cDir, 0);
   rb_define_method(cls, "rb_cEncoding", constants_spec_rb_cEncoding, 0);
   rb_define_method(cls, "rb_mEnumerable", constants_spec_rb_mEnumerable, 0);
diff --git a/spec/ruby/optional/capi/ext/rubyspec.h b/spec/ruby/optional/capi/ext/rubyspec.h
index 8d75cfc..4f75d40 100644
--- a/spec/ruby/optional/capi/ext/rubyspec.h
+++ b/spec/ruby/optional/capi/ext/rubyspec.h
@@ -22,6 +22,10 @@ https://github.com/ruby/ruby/blob/trunk/spec/ruby/optional/capi/ext/rubyspec.h#L22
    (RUBY_VERSION_MAJOR == (major) && RUBY_VERSION_MINOR < (minor)) || \
    (RUBY_VERSION_MAJOR == (major) && RUBY_VERSION_MINOR == (minor) && RUBY_VERSION_TEENY < (teeny)))
 
+#if RUBY_VERSION_MAJOR > 3 || (RUBY_VERSION_MAJOR == 3 && RUBY_VERSION_MINOR >= 0)
+#define RUBY_VERSION_IS_3_0
+#endif
+
 #if RUBY_VERSION_MAJOR > 2 || (RUBY_VERSION_MAJOR == 2 && RUBY_VERSION_MINOR >= 7)
 #define RUBY_VERSION_IS_2_7
 #endif
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]