ruby-changes:62720
From: =E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3 <ko1@a...>
Date: Thu, 27 Aug 2020 15:03:50 +0900 (JST)
Subject: [ruby-changes:62720] cd1d6d9029 (master): include/ruby/backward/2/r_cast.h: deprecate
https://git.ruby-lang.org/ruby.git/commit/?id=cd1d6d9029 From cd1d6d90299d727ad4a87c42f3ba09c87df2bce3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3?= <shyouhei@r...> Date: Wed, 22 Jul 2020 14:44:25 +0900 Subject: include/ruby/backward/2/r_cast.h: deprecate Remove all usages of RCAST() so that the header file can be excluded from ruby/ruby.h's dependency. diff --git a/gc.c b/gc.c index f1232d3..102b618 100644 --- a/gc.c +++ b/gc.c @@ -536,6 +536,8 @@ struct RMoved { https://github.com/ruby/ruby/blob/trunk/gc.c#L536 } as; }; +#define RMOVED(obj) ((struct RMoved *)(obj)) + #if defined(_MSC_VER) || defined(__CYGWIN__) #pragma pack(push, 1) /* magic for reducing sizeof(RVALUE): 24 -> 20 */ #endif diff --git a/include/ruby/backward/2/r_cast.h b/include/ruby/backward/2/r_cast.h index d3f728e..4600699 100644 --- a/include/ruby/backward/2/r_cast.h +++ b/include/ruby/backward/2/r_cast.h @@ -24,4 +24,10 @@ https://github.com/ruby/ruby/blob/trunk/include/ruby/backward/2/r_cast.h#L24 */ #define R_CAST(st) (struct st*) #define RMOVED(obj) (R_CAST(RMoved)(obj)) + +#if defined(__GNUC__) +# warning R_CAST and RMOVED are deprecated +#elif defined(_MSC_VER) +# pragma message("warning: R_CAST and RMOVED are deprecated") +#endif #endif /* RUBY_BACKWARD2_R_CAST_H */ diff --git a/include/ruby/ruby.h b/include/ruby/ruby.h index 0f11d42..33d7528 100644 --- a/include/ruby/ruby.h +++ b/include/ruby/ruby.h @@ -52,7 +52,6 @@ https://github.com/ruby/ruby/blob/trunk/include/ruby/ruby.h#L52 #include "ruby/backward/2/inttypes.h" #include "ruby/backward/2/limits.h" #include "ruby/backward/2/rmodule.h" -#include "ruby/backward/2/r_cast.h" RBIMPL_SYMBOL_EXPORT_BEGIN() diff --git a/internal/bignum.h b/internal/bignum.h index c7b9b32..95c1e6e 100644 --- a/internal/bignum.h +++ b/internal/bignum.h @@ -74,7 +74,7 @@ https://github.com/ruby/ruby/blob/trunk/internal/bignum.h#L74 # define PRIXBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"X" #endif -#define RBIGNUM(obj) (R_CAST(RBignum)(obj)) +#define RBIGNUM(obj) ((struct RBignum *)(obj)) #define BIGNUM_SIGN_BIT FL_USER1 #define BIGNUM_EMBED_FLAG ((VALUE)FL_USER2) #define BIGNUM_EMBED_LEN_NUMBITS 3 diff --git a/internal/complex.h b/internal/complex.h index dc10538..6f63a9e 100644 --- a/internal/complex.h +++ b/internal/complex.h @@ -17,7 +17,7 @@ struct RComplex { https://github.com/ruby/ruby/blob/trunk/internal/complex.h#L17 VALUE imag; }; -#define RCOMPLEX(obj) (R_CAST(RComplex)(obj)) +#define RCOMPLEX(obj) ((struct RComplex *)(obj)) /* shortcut macro for internal only */ #define RCOMPLEX_SET_REAL(cmp, r) RB_OBJ_WRITE((cmp), &RCOMPLEX(cmp)->real, (r)) diff --git a/internal/hash.h b/internal/hash.h index b0c23c2..237ce58 100644 --- a/internal/hash.h +++ b/internal/hash.h @@ -54,7 +54,7 @@ struct RHash { https://github.com/ruby/ruby/blob/trunk/internal/hash.h#L54 } ar_hint; }; -#define RHASH(obj) (R_CAST(RHash)(obj)) +#define RHASH(obj) ((struct RHash *)(obj)) #ifdef RHASH_IFNONE # undef RHASH_IFNONE diff --git a/internal/imemo.h b/internal/imemo.h index 29318f1..d10f89c 100644 --- a/internal/imemo.h +++ b/internal/imemo.h @@ -117,7 +117,7 @@ struct MEMO { https://github.com/ruby/ruby/blob/trunk/internal/imemo.h#L117 /* ment is in method.h */ #define THROW_DATA_P(err) imemo_throw_data_p((VALUE)err) -#define MEMO_CAST(m) (R_CAST(MEMO)(m)) +#define MEMO_CAST(m) ((struct MEMO *)(m)) #define MEMO_NEW(a, b, c) ((struct MEMO *)rb_imemo_new(imemo_memo, (VALUE)(a), (VALUE)(b), (VALUE)(c), 0)) #define MEMO_FOR(type, value) ((type *)RARRAY_PTR(value)) #define NEW_MEMO_FOR(type, value) \ diff --git a/internal/numeric.h b/internal/numeric.h index 7045896..fa24927 100644 --- a/internal/numeric.h +++ b/internal/numeric.h @@ -41,7 +41,7 @@ struct RFloat { https://github.com/ruby/ruby/blob/trunk/internal/numeric.h#L41 double float_value; }; -#define RFLOAT(obj) (R_CAST(RFloat)(obj)) +#define RFLOAT(obj) ((struct RFloat *)(obj)) /* numeric.c */ int rb_num_to_uint(VALUE val, unsigned int *ret); diff --git a/internal/rational.h b/internal/rational.h index 99c5eec..18efd7b 100644 --- a/internal/rational.h +++ b/internal/rational.h @@ -21,7 +21,7 @@ struct RRational { https://github.com/ruby/ruby/blob/trunk/internal/rational.h#L21 VALUE den; }; -#define RRATIONAL(obj) (R_CAST(RRational)(obj)) +#define RRATIONAL(obj) ((struct RRational *)(obj)) /* rational.c */ VALUE rb_rational_canonicalize(VALUE x); diff --git a/internal/struct.h b/internal/struct.h index b00dfff..82b2738 100644 --- a/internal/struct.h +++ b/internal/struct.h @@ -31,7 +31,7 @@ struct RStruct { https://github.com/ruby/ruby/blob/trunk/internal/struct.h#L31 } as; }; -#define RSTRUCT(obj) (R_CAST(RStruct)(obj)) +#define RSTRUCT(obj) ((struct RStruct *)(obj)) #ifdef RSTRUCT_LEN # undef RSTRUCT_LEN diff --git a/node.h b/node.h index bc0dcb2..3b8b331 100644 --- a/node.h +++ b/node.h @@ -173,7 +173,7 @@ typedef struct RNode { https://github.com/ruby/ruby/blob/trunk/node.h#L173 int node_id; } NODE; -#define RNODE(obj) (R_CAST(RNode)(obj)) +#define RNODE(obj) ((struct RNode *)(obj)) /* FL : 0..4: T_TYPES, 5: KEEP_WB, 6: PROMOTED, 7: FINALIZE, 8: UNUSED, 9: UNUSED, 10: EXIVAR, 11: FREEZE */ /* NODE_FL: 0..4: T_TYPES, 5: KEEP_WB, 6: PROMOTED, 7: NODE_FL_NEWLINE, diff --git a/symbol.h b/symbol.h index dee541f..e2710ba 100644 --- a/symbol.h +++ b/symbol.h @@ -30,7 +30,7 @@ struct RSymbol { https://github.com/ruby/ruby/blob/trunk/symbol.h#L30 ID id; }; -#define RSYMBOL(obj) (R_CAST(RSymbol)(obj)) +#define RSYMBOL(obj) ((struct RSymbol *)(obj)) #define is_notop_id(id) ((id)>tLAST_OP_ID) #define is_local_id(id) (id_type(id)==ID_LOCAL) -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/