1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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.
This commit is contained in:
卜部昌平 2020-07-22 14:44:25 +09:00
parent 442525527e
commit cd1d6d9029
Notes: git 2020-08-27 15:04:00 +09:00
12 changed files with 17 additions and 10 deletions

2
gc.c
View file

@ -536,6 +536,8 @@ struct RMoved {
} as; } as;
}; };
#define RMOVED(obj) ((struct RMoved *)(obj))
#if defined(_MSC_VER) || defined(__CYGWIN__) #if defined(_MSC_VER) || defined(__CYGWIN__)
#pragma pack(push, 1) /* magic for reducing sizeof(RVALUE): 24 -> 20 */ #pragma pack(push, 1) /* magic for reducing sizeof(RVALUE): 24 -> 20 */
#endif #endif

View file

@ -24,4 +24,10 @@
*/ */
#define R_CAST(st) (struct st*) #define R_CAST(st) (struct st*)
#define RMOVED(obj) (R_CAST(RMoved)(obj)) #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 */ #endif /* RUBY_BACKWARD2_R_CAST_H */

View file

@ -52,7 +52,6 @@
#include "ruby/backward/2/inttypes.h" #include "ruby/backward/2/inttypes.h"
#include "ruby/backward/2/limits.h" #include "ruby/backward/2/limits.h"
#include "ruby/backward/2/rmodule.h" #include "ruby/backward/2/rmodule.h"
#include "ruby/backward/2/r_cast.h"
RBIMPL_SYMBOL_EXPORT_BEGIN() RBIMPL_SYMBOL_EXPORT_BEGIN()

View file

@ -74,7 +74,7 @@
# define PRIXBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"X" # define PRIXBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"X"
#endif #endif
#define RBIGNUM(obj) (R_CAST(RBignum)(obj)) #define RBIGNUM(obj) ((struct RBignum *)(obj))
#define BIGNUM_SIGN_BIT FL_USER1 #define BIGNUM_SIGN_BIT FL_USER1
#define BIGNUM_EMBED_FLAG ((VALUE)FL_USER2) #define BIGNUM_EMBED_FLAG ((VALUE)FL_USER2)
#define BIGNUM_EMBED_LEN_NUMBITS 3 #define BIGNUM_EMBED_LEN_NUMBITS 3

View file

@ -17,7 +17,7 @@ struct RComplex {
VALUE imag; VALUE imag;
}; };
#define RCOMPLEX(obj) (R_CAST(RComplex)(obj)) #define RCOMPLEX(obj) ((struct RComplex *)(obj))
/* shortcut macro for internal only */ /* shortcut macro for internal only */
#define RCOMPLEX_SET_REAL(cmp, r) RB_OBJ_WRITE((cmp), &RCOMPLEX(cmp)->real, (r)) #define RCOMPLEX_SET_REAL(cmp, r) RB_OBJ_WRITE((cmp), &RCOMPLEX(cmp)->real, (r))

View file

@ -54,7 +54,7 @@ struct RHash {
} ar_hint; } ar_hint;
}; };
#define RHASH(obj) (R_CAST(RHash)(obj)) #define RHASH(obj) ((struct RHash *)(obj))
#ifdef RHASH_IFNONE #ifdef RHASH_IFNONE
# undef RHASH_IFNONE # undef RHASH_IFNONE

View file

@ -117,7 +117,7 @@ struct MEMO {
/* ment is in method.h */ /* ment is in method.h */
#define THROW_DATA_P(err) imemo_throw_data_p((VALUE)err) #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_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 MEMO_FOR(type, value) ((type *)RARRAY_PTR(value))
#define NEW_MEMO_FOR(type, value) \ #define NEW_MEMO_FOR(type, value) \

View file

@ -41,7 +41,7 @@ struct RFloat {
double float_value; double float_value;
}; };
#define RFLOAT(obj) (R_CAST(RFloat)(obj)) #define RFLOAT(obj) ((struct RFloat *)(obj))
/* numeric.c */ /* numeric.c */
int rb_num_to_uint(VALUE val, unsigned int *ret); int rb_num_to_uint(VALUE val, unsigned int *ret);

View file

@ -21,7 +21,7 @@ struct RRational {
VALUE den; VALUE den;
}; };
#define RRATIONAL(obj) (R_CAST(RRational)(obj)) #define RRATIONAL(obj) ((struct RRational *)(obj))
/* rational.c */ /* rational.c */
VALUE rb_rational_canonicalize(VALUE x); VALUE rb_rational_canonicalize(VALUE x);

View file

@ -31,7 +31,7 @@ struct RStruct {
} as; } as;
}; };
#define RSTRUCT(obj) (R_CAST(RStruct)(obj)) #define RSTRUCT(obj) ((struct RStruct *)(obj))
#ifdef RSTRUCT_LEN #ifdef RSTRUCT_LEN
# undef RSTRUCT_LEN # undef RSTRUCT_LEN

2
node.h
View file

@ -173,7 +173,7 @@ typedef struct RNode {
int node_id; int node_id;
} NODE; } 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 */ /* 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, /* NODE_FL: 0..4: T_TYPES, 5: KEEP_WB, 6: PROMOTED, 7: NODE_FL_NEWLINE,

View file

@ -30,7 +30,7 @@ struct RSymbol {
ID id; 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_notop_id(id) ((id)>tLAST_OP_ID)
#define is_local_id(id) (id_type(id)==ID_LOCAL) #define is_local_id(id) (id_type(id)==ID_LOCAL)