summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author卜部昌平 <shyouhei@ruby-lang.org>2020-07-22 14:44:25 +0900
committer卜部昌平 <shyouhei@ruby-lang.org>2020-08-27 15:03:36 +0900
commitcd1d6d90299d727ad4a87c42f3ba09c87df2bce3 (patch)
treef0d1c0cd85db7296a28824f1758bf7344e8881af
parent442525527e2fa052e6d8752adffeaa0855b75ff7 (diff)
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.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3346
-rw-r--r--gc.c2
-rw-r--r--include/ruby/backward/2/r_cast.h6
-rw-r--r--include/ruby/ruby.h1
-rw-r--r--internal/bignum.h2
-rw-r--r--internal/complex.h2
-rw-r--r--internal/hash.h2
-rw-r--r--internal/imemo.h2
-rw-r--r--internal/numeric.h2
-rw-r--r--internal/rational.h2
-rw-r--r--internal/struct.h2
-rw-r--r--node.h2
-rw-r--r--symbol.h2
12 files changed, 17 insertions, 10 deletions
diff --git a/gc.c b/gc.c
index f1232d3aeca..102b618180f 100644
--- a/gc.c
+++ b/gc.c
@@ -536,6 +536,8 @@ struct RMoved {
} 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 d3f728eb5cc..4600699a9e3 100644
--- a/include/ruby/backward/2/r_cast.h
+++ b/include/ruby/backward/2/r_cast.h
@@ -24,4 +24,10 @@
*/
#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 0f11d423f20..33d75281187 100644
--- a/include/ruby/ruby.h
+++ b/include/ruby/ruby.h
@@ -52,7 +52,6 @@
#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 c7b9b324d7f..95c1e6eacd3 100644
--- a/internal/bignum.h
+++ b/internal/bignum.h
@@ -74,7 +74,7 @@
# 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 dc1053823d1..6f63a9ebeb7 100644
--- a/internal/complex.h
+++ b/internal/complex.h
@@ -17,7 +17,7 @@ struct RComplex {
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 b0c23c2b2e8..237ce586034 100644
--- a/internal/hash.h
+++ b/internal/hash.h
@@ -54,7 +54,7 @@ struct RHash {
} 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 29318f10cd4..d10f89cb869 100644
--- a/internal/imemo.h
+++ b/internal/imemo.h
@@ -117,7 +117,7 @@ struct MEMO {
/* 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 7045896c616..fa24927551b 100644
--- a/internal/numeric.h
+++ b/internal/numeric.h
@@ -41,7 +41,7 @@ struct RFloat {
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 99c5eec8cb8..18efd7bd5e7 100644
--- a/internal/rational.h
+++ b/internal/rational.h
@@ -21,7 +21,7 @@ struct RRational {
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 b00dfffd345..82b2738b69e 100644
--- a/internal/struct.h
+++ b/internal/struct.h
@@ -31,7 +31,7 @@ struct RStruct {
} 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 bc0dcb26c53..3b8b3313f25 100644
--- a/node.h
+++ b/node.h
@@ -173,7 +173,7 @@ typedef struct RNode {
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 dee541f3478..e2710ba61b5 100644
--- a/symbol.h
+++ b/symbol.h
@@ -30,7 +30,7 @@ struct RSymbol {
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)