зеркало из https://github.com/github/ruby.git
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
This commit is contained in:
Родитель
c30f03d328
Коммит
8918a9cf6c
|
@ -125,7 +125,7 @@ numhash_delete_safe(VALUE self, VALUE key)
|
|||
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);
|
||||
|
|
|
@ -37,7 +37,7 @@ void
|
|||
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);
|
||||
|
|
|
@ -459,7 +459,7 @@ rsock_init_sockifaddr(void)
|
|||
*
|
||||
* 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);
|
||||
|
|
|
@ -2568,7 +2568,7 @@ rsock_init_addrinfo(void)
|
|||
*/
|
||||
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);
|
||||
|
|
|
@ -1755,7 +1755,7 @@ Init_stringio(void)
|
|||
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));
|
||||
|
||||
|
|
|
@ -74,6 +74,7 @@ struct RData {
|
|||
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
|
|||
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)
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
* 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;
|
|||
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;
|
||||
|
|
22
object.c
22
object.c
|
@ -32,7 +32,6 @@
|
|||
#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 _)
|
|||
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)
|
|||
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);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
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
|
||||
|
|
|
@ -14,7 +14,9 @@ defconstfunc(rb_cBinding)
|
|||
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) {
|
|||
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);
|
||||
|
|
|
@ -22,6 +22,10 @@
|
|||
(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
|
||||
|
|
Загрузка…
Ссылка в новой задаче