summaryrefslogtreecommitdiff
path: root/lib/irb/magic-file.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/irb/magic-file.rb')
0 files changed, 0 insertions, 0 deletions
84.4%;'/> -rw-r--r--array.c8
-rw-r--r--bignum.c16
-rw-r--r--class.c20
-rw-r--r--compile.c8
-rw-r--r--complex.c10
-rw-r--r--enum.c2
-rw-r--r--enumerator.c2
-rw-r--r--error.c2
-rw-r--r--eval.c2
-rw-r--r--eval_error.c4
-rw-r--r--gc.c4
-rw-r--r--hash.c4
-rw-r--r--io.c24
-rw-r--r--marshal.c18
-rw-r--r--math.c2
-rw-r--r--numeric.c10
-rw-r--r--object.c12
-rw-r--r--pack.c6
-rw-r--r--parse.y2
-rw-r--r--proc.c6
-rw-r--r--process.c6
-rw-r--r--random.c4
-rw-r--r--range.c6
-rw-r--r--rational.c10
-rw-r--r--re.c6
-rw-r--r--ruby.c2
-rw-r--r--safe.c2
-rw-r--r--string.c26
-rw-r--r--struct.c12
-rw-r--r--thread.c14
-rw-r--r--time.c32
-rw-r--r--transcode.c8
-rw-r--r--variable.c6
-rw-r--r--vm_eval.c8
-rw-r--r--vm_insnhelper.c6
-rw-r--r--vm_method.c8
37 files changed, 164 insertions, 159 deletions
diff --git a/ChangeLog b/ChangeLog
index 1de5078382..63f60a1e32 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Thu Sep 29 20:07:36 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * use RB_TYPE_P which is optimized for constant types, instead of
+ comparison with TYPE.
+
Wed Sep 28 09:20:37 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
* configure.in (pthread_np.h): needs pthread.h to be included
diff --git a/array.c b/array.c
index 8caad66a3e..82013df69d 100644
--- a/array.c
+++ b/array.c
@@ -2016,7 +2016,7 @@ enum {
sort_optimizable_count
};
-#define STRING_P(s) (TYPE(s) == T_STRING && CLASS_OF(s) == rb_cString)
+#define STRING_P(s) (RB_TYPE_P((s), T_STRING) && CLASS_OF(s) == rb_cString)
#define SORT_OPTIMIZABLE_BIT(type) (1U << TOKEN_PASTE(sort_opt_,type))
#define SORT_OPTIMIZABLE(data, type) \
@@ -3137,7 +3137,7 @@ rb_ary_rassoc(VALUE ary, VALUE value)
for (i = 0; i < RARRAY_LEN(ary); ++i) {
v = RARRAY_PTR(ary)[i];
- if (TYPE(v) == T_ARRAY &&
+ if (RB_TYPE_P(v, T_ARRAY) &&
RARRAY_LEN(v) > 1 &&
rb_equal(RARRAY_PTR(v)[1], value))
return v;
@@ -3176,7 +3176,7 @@ static VALUE
rb_ary_equal(VALUE ary1, VALUE ary2)
{
if (ary1 == ary2) return Qtrue;
- if (TYPE(ary2) != T_ARRAY) {
+ if (!RB_TYPE_P(ary2, T_ARRAY)) {
if (!rb_respond_to(ary2, rb_intern("to_ary"))) {
return Qfalse;
}
@@ -3211,7 +3211,7 @@ static VALUE
rb_ary_eql(VALUE ary1, VALUE ary2)
{
if (ary1 == ary2) return Qtrue;
- if (TYPE(ary2) != T_ARRAY) return Qfalse;
+ if (!RB_TYPE_P(ary2, T_ARRAY)) return Qfalse;
if (RARRAY_LEN(ary1) != RARRAY_LEN(ary2)) return Qfalse;
return rb_exec_recursive_paired(recursive_eql, ary1, ary2, ary2);
}
diff --git a/bignum.c b/bignum.c
index 65e82d4e0f..a618caeb37 100644
--- a/bignum.c
+++ b/bignum.c
@@ -101,7 +101,7 @@ rb_cmpint(VALUE val, VALUE a, VALUE b)
if (l < 0) return -1;
return 0;
}
- if (TYPE(val) == T_BIGNUM) {
+ if (RB_TYPE_P(val, T_BIGNUM)) {
if (BIGZEROP(val)) return 0;
if (RBIGNUM_SIGN(val)) return 1;
return -1;
@@ -269,7 +269,7 @@ bigfixize(VALUE x)
static VALUE
bignorm(VALUE x)
{
- if (!FIXNUM_P(x) && TYPE(x) == T_BIGNUM) {
+ if (RB_TYPE_P(x, T_BIGNUM)) {
x = bigfixize(bigtrunc(x));
}
return x;
@@ -1628,7 +1628,7 @@ rb_big_eq(VALUE x, VALUE y)
static VALUE
rb_big_eql(VALUE x, VALUE y)
{
- if (TYPE(y) != T_BIGNUM) return Qfalse;
+ if (!RB_TYPE_P(y, T_BIGNUM)) return Qfalse;
if (RBIGNUM_SIGN(x) != RBIGNUM_SIGN(y)) return Qfalse;
if (RBIGNUM_LEN(x) != RBIGNUM_LEN(y)) return Qfalse;
if (MEMCMP(BDIGITS(x),BDIGITS(y),BDIGIT,RBIGNUM_LEN(y)) != 0) return Qfalse;
@@ -3107,7 +3107,7 @@ rb_big_pow(VALUE x, VALUE y)
static inline VALUE
bit_coerce(VALUE x)
{
- while (!FIXNUM_P(x) && TYPE(x) != T_BIGNUM) {
+ while (!FIXNUM_P(x) && !RB_TYPE_P(x, T_BIGNUM)) {
rb_raise(rb_eTypeError,
"can't convert %s into Integer for bitwise arithmetic",
rb_obj_classname(x));
@@ -3434,7 +3434,7 @@ rb_big_lshift(VALUE x, VALUE y)
}
break;
}
- else if (TYPE(y) == T_BIGNUM) {
+ else if (RB_TYPE_P(y, T_BIGNUM)) {
if (!RBIGNUM_SIGN(y)) {
VALUE t = check_shiftdown(y, x);
if (!NIL_P(t)) return t;
@@ -3498,7 +3498,7 @@ rb_big_rshift(VALUE x, VALUE y)
}
break;
}
- else if (TYPE(y) == T_BIGNUM) {
+ else if (RB_TYPE_P(y, T_BIGNUM)) {
if (RBIGNUM_SIGN(y)) {
VALUE t = check_shiftdown(y, x);
if (!NIL_P(t)) return t;
@@ -3586,7 +3586,7 @@ rb_big_aref(VALUE x, VALUE y)
VALUE shift;
long i, s1, s2;
- if (TYPE(y) == T_BIGNUM) {
+ if (RB_TYPE_P(y, T_BIGNUM)) {
if (!RBIGNUM_SIGN(y))
return INT2FIX(0);
bigtrunc(y);
@@ -3646,7 +3646,7 @@ rb_big_coerce(VALUE x, VALUE y)
if (FIXNUM_P(y)) {
return rb_assoc_new(rb_int2big(FIX2LONG(y)), x);
}
- else if (TYPE(y) == T_BIGNUM) {
+ else if (RB_TYPE_P(y, T_BIGNUM)) {
return rb_assoc_new(y, x);
}
else {
diff --git a/class.c b/class.c
index d427393081..e6c1f8fd11 100644
--- a/class.c
+++ b/class.c
@@ -93,7 +93,7 @@ rb_class_boot(VALUE super)
void
rb_check_inheritable(VALUE super)
{
- if (TYPE(super) != T_CLASS) {
+ if (!RB_TYPE_P(super, T_CLASS)) {
rb_raise(rb_eTypeError, "superclass must be a Class (%s given)",
rb_obj_classname(super));
}
@@ -463,7 +463,7 @@ rb_define_class(const char *name, VALUE super)
id = rb_intern(name);
if (rb_const_defined(rb_cObject, id)) {
klass = rb_const_get(rb_cObject, id);
- if (TYPE(klass) != T_CLASS) {
+ if (!RB_TYPE_P(klass, T_CLASS)) {
rb_raise(rb_eTypeError, "%s is not a class", name);
}
if (rb_class_real(RCLASS_SUPER(klass)) != super) {
@@ -530,7 +530,7 @@ rb_define_class_id_under(VALUE outer, ID id, VALUE super)
if (rb_const_defined_at(outer, id)) {
klass = rb_const_get_at(outer, id);
- if (TYPE(klass) != T_CLASS) {
+ if (!RB_TYPE_P(klass, T_CLASS)) {
rb_raise(rb_eTypeError, "%s is not a class", rb_id2name(id));
}
if (rb_class_real(RCLASS_SUPER(klass)) != super) {
@@ -581,7 +581,7 @@ rb_define_module(const char *name)
id = rb_intern(name);
if (rb_const_defined(rb_cObject, id)) {
module = rb_const_get(rb_cObject, id);
- if (TYPE(module) == T_MODULE)
+ if (RB_TYPE_P(module, T_MODULE))
return module;
rb_raise(rb_eTypeError, "%s is not a module", rb_obj_classname(module));
}
@@ -605,7 +605,7 @@ rb_define_module_id_under(VALUE outer, ID id)
if (rb_const_defined_at(outer, id)) {
module = rb_const_get_at(outer, id);
- if (TYPE(module) == T_MODULE)
+ if (RB_TYPE_P(module, T_MODULE))
return module;
rb_raise(rb_eTypeError, "%s::%s is not a module",
rb_class2name(outer), rb_obj_classname(module));
@@ -636,7 +636,7 @@ include_class_new(VALUE module, VALUE super)
RCLASS_CONST_TBL(klass) = RCLASS_CONST_TBL(module);
RCLASS_M_TBL(klass) = RCLASS_M_TBL(module);
RCLASS_SUPER(klass) = super;
- if (TYPE(module) == T_ICLASS) {
+ if (RB_TYPE_P(module, T_ICLASS)) {
RBASIC(klass)->klass = RBASIC(module)->klass;
}
else {
@@ -659,7 +659,7 @@ rb_include_module(VALUE klass, VALUE module)
rb_secure(4);
}
- if (TYPE(module) != T_MODULE) {
+ if (!RB_TYPE_P(module, T_MODULE)) {
Check_Type(module, T_MODULE);
}
@@ -791,7 +791,7 @@ rb_mix_module(VALUE klass, VALUE module, st_table *constants, st_table *methods)
rb_secure(4);
}
- if (TYPE(module) != T_MODULE) {
+ if (!RB_TYPE_P(module, T_MODULE)) {
Check_Type(module, T_MODULE);
}
@@ -1248,7 +1248,7 @@ rb_obj_singleton_methods(int argc, VALUE *argv, VALUE obj)
klass = RCLASS_SUPER(klass);
}
if (RTEST(recur)) {
- while (klass && (FL_TEST(klass, FL_SINGLETON) || TYPE(klass) == T_ICLASS)) {
+ while (klass && (FL_TEST(klass, FL_SINGLETON) || RB_TYPE_P(klass, T_ICLASS))) {
st_foreach(RCLASS_M_TBL(klass), method_entry_i, (st_data_t)list);
klass = RCLASS_SUPER(klass);
}
@@ -1435,7 +1435,7 @@ rb_singleton_class(VALUE obj)
VALUE klass = singleton_class_of(obj);
/* ensures an exposed class belongs to its own eigenclass */
- if (TYPE(obj) == T_CLASS) (void)ENSURE_EIGENCLASS(klass);
+ if (RB_TYPE_P(obj, T_CLASS)) (void)ENSURE_EIGENCLASS(klass);
return klass;
}
diff --git a/compile.c b/compile.c
index fd800a8840..81d87be47e 100644
--- a/compile.c
+++ b/compile.c
@@ -1263,7 +1263,7 @@ static st_index_t
cdhash_hash(VALUE a)
{
if (SPECIAL_CONST_P(a)) return (st_index_t)a;
- if (TYPE(a) == T_STRING) return rb_str_hash(a);
+ if (RB_TYPE_P(a, T_STRING)) return rb_str_hash(a);
{
VALUE hval = rb_hash(a);
return (st_index_t)FIX2LONG(hval);
@@ -2335,7 +2335,7 @@ case_when_optimizable_literal(NODE * node)
case NODE_LIT: {
VALUE v = node->nd_lit;
double ival;
- if (TYPE(v) == T_FLOAT &&
+ if (RB_TYPE_P(v, T_FLOAT) &&
modf(RFLOAT_VALUE(v), &ival) == 0.0) {
return FIXABLE(ival) ? LONG2FIX((long)ival) : rb_dbl2big(ival);
}
@@ -5314,7 +5314,7 @@ iseq_build_from_ary_body(rb_iseq_t *iseq, LINK_ANCHOR *anchor,
else if (FIXNUM_P(obj)) {
line_no = NUM2INT(obj);
}
- else if (TYPE(obj) == T_ARRAY) {
+ else if (RB_TYPE_P(obj, T_ARRAY)) {
VALUE *argv = 0;
int argc = RARRAY_LENINT(obj) - 1;
st_data_t insn_id;
@@ -5356,7 +5356,7 @@ iseq_build_from_ary_body(rb_iseq_t *iseq, LINK_ANCHOR *anchor,
case TS_ISEQ:
{
if (op != Qnil) {
- if (TYPE(op) == T_ARRAY) {
+ if (RB_TYPE_P(op, T_ARRAY)) {
argv[j] = rb_iseq_load(op, iseq->self, Qnil);
}
else if (CLASS_OF(op) == rb_cISeq) {
diff --git a/complex.c b/complex.c
index a701129b73..fd0088c574 100644
--- a/complex.c
+++ b/complex.c
@@ -121,7 +121,7 @@ f_mul(VALUE x, VALUE y)
if (FIXNUM_P(y)) {
long iy = FIX2LONG(y);
if (iy == 0) {
- if (FIXNUM_P(x) || TYPE(x) == T_BIGNUM)
+ if (FIXNUM_P(x) || RB_TYPE_P(x, T_BIGNUM))
return ZERO;
}
else if (iy == 1)
@@ -130,7 +130,7 @@ f_mul(VALUE x, VALUE y)
else if (FIXNUM_P(x)) {
long ix = FIX2LONG(x);
if (ix == 0) {
- if (FIXNUM_P(y) || TYPE(y) == T_BIGNUM)
+ if (FIXNUM_P(y) || RB_TYPE_P(y, T_BIGNUM))
return ZERO;
}
else if (ix == 1)
@@ -166,14 +166,14 @@ fun1(real_p)
inline static VALUE
f_to_i(VALUE x)
{
- if (TYPE(x) == T_STRING)
+ if (RB_TYPE_P(x, T_STRING))
return rb_str_to_inum(x, 10, 0);
return rb_funcall(x, id_to_i, 0);
}
inline static VALUE
f_to_f(VALUE x)
{
- if (TYPE(x) == T_STRING)
+ if (RB_TYPE_P(x, T_STRING))
return DBL2NUM(rb_str_to_dbl(x, 0));
return rb_funcall(x, id_to_f, 0);
}
@@ -944,7 +944,7 @@ nucomp_coerce(VALUE self, VALUE other)
{
if (k_numeric_p(other) && f_real_p(other))
return rb_assoc_new(f_complex_new_bang1(CLASS_OF(self), other), self);
- if (TYPE(other) == T_COMPLEX)
+ if (RB_TYPE_P(other, T_COMPLEX))
return rb_assoc_new(other, self);
rb_raise(rb_eTypeError, "%s can't be coerced into %s",
diff --git a/enum.c b/enum.c
index b9d34d8c03..77ecd2fa56 100644
--- a/enum.c
+++ b/enum.c
@@ -901,7 +901,7 @@ enum_sort_by(VALUE obj)
RETURN_ENUMERATOR(obj, 0, 0);
- if (TYPE(obj) == T_ARRAY && RARRAY_LEN(obj) <= LONG_MAX/2) {
+ if (RB_TYPE_P(obj, T_ARRAY) && RARRAY_LEN(obj) <= LONG_MAX/2) {
ary = rb_ary_new2(RARRAY_LEN(obj)*2);
}
else {
diff --git a/enumerator.c b/enumerator.c
index 8b1add254a..b7561482e5 100644
--- a/enumerator.c
+++ b/enumerator.c
@@ -590,7 +590,7 @@ enumerator_next_values(VALUE obj)
static VALUE
ary2sv(VALUE args, int dup)
{
- if (TYPE(args) != T_ARRAY)
+ if (!RB_TYPE_P(args, T_ARRAY))
return args;
switch (RARRAY_LEN(args)) {
diff --git a/error.c b/error.c
index 646fb16232..8bf33e65ad 100644
--- a/error.c
+++ b/error.c
@@ -1134,7 +1134,7 @@ syserr_initialize(int argc, VALUE *argv, VALUE self)
if (!NIL_P(error) && st_lookup(syserr_tbl, NUM2LONG(error), &data)) {
klass = (VALUE)data;
/* change class */
- if (TYPE(self) != T_OBJECT) { /* insurance to avoid type crash */
+ if (!RB_TYPE_P(self, T_OBJECT)) { /* insurance to avoid type crash */
rb_raise(rb_eTypeError, "invalid instance type");
}
RBASIC(self)->klass = klass;
diff --git a/eval.c b/eval.c
index 87f1f61ec3..ddbe31a477 100644
--- a/eval.c
+++ b/eval.c
@@ -169,7 +169,7 @@ ruby_cleanup(volatile int ex)
if (!RTEST(err)) continue;
/* th->errinfo contains a NODE while break'ing */
- if (TYPE(err) == T_NODE) continue;
+ if (RB_TYPE_P(err, T_NODE)) continue;
if (rb_obj_is_kind_of(err, rb_eSystemExit)) {
ex = sysexit_status(err);
diff --git a/eval_error.c b/eval_error.c
index e2763ad1d6..cf3961cb33 100644
--- a/eval_error.c
+++ b/eval_error.c
@@ -202,7 +202,7 @@ rb_print_undef(VALUE klass, ID id, int scope)
}
rb_name_error(id, "undefined%s method `%s' for %s `%s'", v,
rb_id2name(id),
- (TYPE(klass) == T_MODULE) ? "module" : "class",
+ (RB_TYPE_P(klass, T_MODULE)) ? "module" : "class",
rb_class2name(klass));
}
@@ -211,7 +211,7 @@ rb_print_undef_str(VALUE klass, VALUE name)
{
rb_name_error_str(name, "undefined method `%s' for %s `%s'",
RSTRING_PTR(name),
- (TYPE(klass) == T_MODULE) ? "module" : "class",
+ (RB_TYPE_P(klass, T_MODULE)) ? "module" : "class",
rb_class2name(klass));
}
diff --git a/gc.c b/gc.c
index b79dcac481..22d56ac49e 100644
--- a/gc.c
+++ b/gc.c
@@ -3265,7 +3265,7 @@ count_objects(int argc, VALUE *argv, VALUE os)
VALUE hash;
if (rb_scan_args(argc, argv, "01", &hash) == 1) {
- if (TYPE(hash) != T_HASH)
+ if (!RB_TYPE_P(hash, T_HASH))
rb_raise(rb_eTypeError, "non-hash given");
}
@@ -3384,7 +3384,7 @@ gc_stat(int argc, VALUE *argv, VALUE self)
VALUE hash;
if (rb_scan_args(argc, argv, "01", &hash) == 1) {
- if (TYPE(hash) != T_HASH)
+ if (!RB_TYPE_P(hash, T_HASH))
rb_raise(rb_eTypeError, "non-hash given");
}
diff --git a/hash.c b/hash.c
index fbd82374eb..a6096f08d4 100644
--- a/hash.c
+++ b/hash.c
@@ -44,7 +44,7 @@ rb_any_cmp(VALUE a, VALUE b)
if (FIXNUM_P(a) && FIXNUM_P(b)) {
return a != b;
}
- if (TYPE(a) == T_STRING && RBASIC(a)->klass == rb_cString &&
+ if (RB_TYPE_P(a, T_STRING) && RBASIC(a)->klass == rb_cString &&
TYPE(b) == T_STRING && RBASIC(b)->klass == rb_cString) {
return rb_str_hash_cmp(a, b);
}
@@ -1599,7 +1599,7 @@ hash_equal(VALUE hash1, VALUE hash2, int eql)
struct equal_data data;
if (hash1 == hash2) return Qtrue;
- if (TYPE(hash2) != T_HASH) {
+ if (!RB_TYPE_P(hash2, T_HASH)) {
if (!rb_respond_to(hash2, rb_intern("to_hash"))) {
return Qfalse;
}
diff --git a/io.c b/io.c
index b3bd0ce52b..6bade4547f 100644
--- a/io.c
+++ b/io.c
@@ -1053,7 +1053,7 @@ rb_io_flush(VALUE io)
{
rb_io_t *fptr;
- if (TYPE(io) != T_FILE) {
+ if (!RB_TYPE_P(io, T_FILE)) {
return rb_funcall(io, id_flush, 0);
}
@@ -2117,7 +2117,7 @@ rb_io_write_nonblock(VALUE io, VALUE str)
long n;
rb_secure(4);
- if (TYPE(str) != T_STRING)
+ if (!RB_TYPE_P(str, T_STRING))
str = rb_obj_as_string(str);
io = GetWriteIO(io);
@@ -3144,7 +3144,7 @@ rb_io_getbyte(VALUE io)
GetOpenFile(io, fptr);
rb_io_check_byte_readable(fptr);
READ_CHECK(fptr);
- if (fptr->fd == 0 && (fptr->mode & FMODE_TTY) && TYPE(rb_stdout) == T_FILE) {
+ if (fptr->fd == 0 && (fptr->mode & FMODE_TTY) && RB_TYPE_P(rb_stdout, T_FILE)) {
rb_io_t *ofp;
GetOpenFile(rb_stdout, ofp);
if (ofp->mode & FMODE_TTY) {
@@ -3243,7 +3243,7 @@ rb_io_ungetc(VALUE io, VALUE c)
if (FIXNUM_P(c)) {
c = rb_enc_uint_chr(FIX2UINT(c), io_read_encoding(fptr));
}
- else if (TYPE(c) == T_BIGNUM) {
+ else if (RB_TYPE_P(c, T_BIGNUM)) {
c = rb_enc_uint_chr(NUM2UINT(c), io_read_encoding(fptr));
}
else {
@@ -3886,7 +3886,7 @@ rb_io_syswrite(VALUE io, VALUE str)
long n;
rb_secure(4);
- if (TYPE(str) != T_STRING)
+ if (!RB_TYPE_P(str, T_STRING))
str = rb_obj_as_string(str);
io = GetWriteIO(io);
@@ -6113,7 +6113,7 @@ static VALUE
rb_io_putc(VALUE io, VALUE ch)
{
VALUE str;
- if (TYPE(ch) == T_STRING) {
+ if (RB_TYPE_P(ch, T_STRING)) {
str = rb_str_substr(ch, 0, 1);
}
else {
@@ -6254,7 +6254,7 @@ void
rb_p(VALUE obj) /* for debug print within C code */
{
VALUE str = rb_obj_as_string(rb_inspect(obj));
- if (TYPE(rb_stdout) == T_FILE &&
+ if (RB_TYPE_P(rb_stdout, T_FILE) &&
rb_method_basic_definition_p(CLASS_OF(rb_stdout), id_write)) {
io_write(rb_stdout, str, 1);
io_write(rb_stdout, rb_default_rs, 0);
@@ -6298,7 +6298,7 @@ rb_f_p(int argc, VALUE *argv, VALUE self)
else if (argc > 1) {
ret = rb_ary_new4(argc, argv);
}
- if (TYPE(rb_stdout) == T_FILE) {
+ if (RB_TYPE_P(rb_stdout, T_FILE)) {
rb_io_flush(rb_stdout);
}
return ret;
@@ -6845,7 +6845,7 @@ argf_next_argv(VALUE argf)
int stdout_binmode = 0;
int fmode;
- if (TYPE(rb_stdout) == T_FILE) {
+ if (RB_TYPE_P(rb_stdout, T_FILE)) {
GetOpenFile(rb_stdout, fptr);
if (fptr->mode & FMODE_BINMODE)
stdout_binmode = 1;
@@ -6885,7 +6885,7 @@ argf_next_argv(VALUE argf)
VALUE str;
int fw;
- if (TYPE(rb_stdout) == T_FILE && rb_stdout != orig_stdout) {
+ if (RB_TYPE_P(rb_stdout, T_FILE) && rb_stdout != orig_stdout) {
rb_io_close(rb_stdout);
}
fstat(fr, &st);
@@ -7770,7 +7770,7 @@ rb_io_ctl(VALUE io, VALUE req, VALUE arg, int io_p)
GetOpenFile(io, fptr);
retval = io_cntl(fptr->fd, cmd, narg, io_p);
if (retval < 0) rb_sys_fail_path(fptr->pathv);
- if (TYPE(arg) == T_STRING && RSTRING_PTR(arg)[len] != 17) {
+ if (RB_TYPE_P(arg, T_STRING) && RSTRING_PTR(arg)[len] != 17) {
rb_raise(rb_eArgError, "return value overflowed string");
}
@@ -9269,7 +9269,7 @@ rb_io_set_encoding(int argc, VALUE *argv, VALUE io)
rb_io_t *fptr;
VALUE v1, v2, opt;
- if (TYPE(io) != T_FILE) {
+ if (!RB_TYPE_P(io, T_FILE)) {
return rb_funcall2(io, id_set_encoding, argc, argv);
}
diff --git a/marshal.c b/marshal.c
index 9a43cdb4d1..d286aaa7c8 100644
--- a/marshal.c
+++ b/marshal.c
@@ -210,7 +210,7 @@ class2path(VALUE klass)
VALUE path = rb_class_path(klass);
const char *n;
- n = must_not_be_anonymous((TYPE(klass) == T_CLASS ? "class" : "module"), path);
+ n = must_not_be_anonymous((RB_TYPE_P(klass, T_CLASS) ? "class" : "module"), path);
if (rb_path_to_class(path) != rb_class_real(klass)) {
rb_raise(rb_eTypeError, "%s can't be referred to", n);
}
@@ -656,7 +656,7 @@ w_object(VALUE obj, struct dump_arg *arg, int limit)
v = rb_funcall(obj, s_dump, 1, INT2NUM(limit));
check_dump_arg(arg, s_dump);
- if (TYPE(v) != T_STRING) {
+ if (!RB_TYPE_P(v, T_STRING)) {
rb_raise(rb_eTypeError, "_dump() must return string");
}
hasiv = has_ivars(obj, ivtbl);
@@ -1271,7 +1271,7 @@ path2class(VALUE path)
{
VALUE v = rb_path_to_class(path);
- if (TYPE(v) != T_CLASS) {
+ if (!RB_TYPE_P(v, T_CLASS)) {
rb_raise(rb_eArgError, "%.*s does not refer to class",
(int)RSTRING_LEN(path), RSTRING_PTR(path));
}
@@ -1283,7 +1283,7 @@ path2module(VALUE path)
{
VALUE v = rb_path_to_class(path);
- if (TYPE(v) != T_MODULE) {
+ if (!RB_TYPE_P(v, T_MODULE)) {
rb_raise(rb_eArgError, "%.*s does not refer to module",
(int)RSTRING_LEN(path), RSTRING_PTR(path));
}
@@ -1364,11 +1364,11 @@ r_object0(struct load_arg *arg, int *ivp, VALUE extmod)
rb_raise(rb_eTypeError, "singleton can't be loaded");
}
v = r_object0(arg, 0, extmod);
- if (rb_special_const_p(v) || TYPE(v) == T_OBJECT || TYPE(v) == T_CLASS) {
+ if (rb_special_const_p(v) || RB_TYPE_P(v, T_OBJECT) || RB_TYPE_P(v, T_CLASS)) {
format_error:
rb_raise(rb_eArgError, "dump format error (user class)");
}
- if (TYPE(v) == T_MODULE || !RTEST(rb_class_inherited_p(c, RBASIC(v)->klass))) {
+ if (RB_TYPE_P(v, T_MODULE) || !RTEST(rb_class_inherited_p(c, RBASIC(v)->klass))) {
VALUE tmp = rb_obj_alloc(c);
if (TYPE(v) != TYPE(tmp)) goto format_error;
@@ -1554,7 +1554,7 @@ r_object0(struct load_arg *arg, int *ivp, VALUE extmod)
long len = r_long(arg);
v = rb_obj_alloc(klass);
- if (TYPE(v) != T_STRUCT) {
+ if (!RB_TYPE_P(v, T_STRUCT)) {
rb_raise(rb_eTypeError, "class %s not a struct", rb_class2name(klass));
}
mem = rb_struct_s_members(klass);
@@ -1630,7 +1630,7 @@ r_object0(struct load_arg *arg, int *ivp, VALUE extmod)
{
st_index_t idx = r_prepare(arg);
v = obj_alloc_by_path(r_unique(arg), arg);
- if (TYPE(v) != T_OBJECT) {
+ if (!RB_TYPE_P(v, T_OBJECT)) {
rb_raise(rb_eArgError, "dump format error");
}
v = r_entry0(v, idx, arg);
@@ -1654,7 +1654,7 @@ r_object0(struct load_arg *arg, int *ivp, VALUE extmod)
else {
v = rb_obj_alloc(klass);
}
- if (TYPE(v) != T_DATA) {
+ if (!RB_TYPE_P(v, T_DATA)) {
rb_raise(rb_eArgError, "dump format error");
}
v = r_entry(v, arg);
diff --git a/math.c b/math.c
index 276b2cbc49..e9e1678dc6 100644
--- a/math.c
+++ b/math.c
@@ -24,7 +24,7 @@
VALUE rb_mMath;
VALUE rb_eMathDomainError;
-#define Need_Float(x) do {if (TYPE(x) != T_FLOAT) {(x) = rb_to_float(x);}} while(0)
+#define Need_Float(x) do {if (!RB_TYPE_P(x, T_FLOAT)) {(x) = rb_to_float(x);}} while(0)
#define Need_Float2(x,y) do {\
Need_Float(x);\
Need_Float(y);\
diff --git a/numeric.c b/numeric.c
index 18f5e1cd1a..6d3c1432e8 100644
--- a/numeric.c
+++ b/numeric.c
@@ -204,7 +204,7 @@ do_coerce(VALUE *x, VALUE *y, int err)
a[0] = *x; a[1] = *y;
ary = rb_rescue(coerce_body, (VALUE)a, err?coerce_rescue:0, (VALUE)a);
- if (TYPE(ary) != T_ARRAY || RARRAY_LEN(ary) != 2) {
+ if (!RB_TYPE_P(ary, T_ARRAY) || RARRAY_LEN(ary) != 2) {
if (err) {
rb_raise(rb_eTypeError, "coerce must return [x, y]");
}
@@ -1272,7 +1272,7 @@ flo_le(VALUE x, VALUE y)
static VALUE
flo_eql(VALUE x, VALUE y)
{
- if (TYPE(y) == T_FLOAT) {
+ if (RB_TYPE_P(y, T_FLOAT)) {
double a = RFLOAT_VALUE(x);
double b = RFLOAT_VALUE(y);
#if defined(_MSC_VER) && _MSC_VER < 1300
@@ -1480,7 +1480,7 @@ int_round_0(VALUE num, int ndigits)
if (neg) x = -x;
return LONG2NUM(x);
}
- if (TYPE(f) == T_FLOAT) {
+ if (RB_TYPE_P(f, T_FLOAT)) {
/* then int_pow overflow */
return INT2FIX(0);
}
@@ -1676,7 +1676,7 @@ num_truncate(VALUE num)
int
ruby_float_step(VALUE from, VALUE to, VALUE step, int excl)
{
- if (TYPE(from) == T_FLOAT || TYPE(to) == T_FLOAT || TYPE(step) == T_FLOAT) {
+ if (RB_TYPE_P(from, T_FLOAT) || RB_TYPE_P(to, T_FLOAT) || RB_TYPE_P(step, T_FLOAT)) {
const double epsilon = DBL_EPSILON;
double beg = NUM2DBL(from);
double end = NUM2DBL(to);
@@ -2960,7 +2960,7 @@ fix_rev(VALUE num)
static VALUE
bit_coerce(VALUE x)
{
- while (!FIXNUM_P(x) && TYPE(x) != T_BIGNUM) {
+ while (!FIXNUM_P(x) && !RB_TYPE_P(x, T_BIGNUM)) {
rb_raise(rb_eTypeError,
"can't convert %s into Integer for bitwise arithmetic",
rb_obj_classname(x));
diff --git a/object.c b/object.c
index 3a7265b31d..23c18edb33 100644
--- a/object.c
+++ b/object.c
@@ -432,7 +432,7 @@ inspect_obj(VALUE obj, VALUE str, int recur)
static VALUE
rb_obj_inspect(VALUE obj)
{
- if (TYPE(obj) == T_OBJECT && rb_obj_basic_to_s_p(obj)) {
+ if (RB_TYPE_P(obj, T_OBJECT) && rb_obj_basic_to_s_p(obj)) {
int has_ivar = 0;
VALUE *ptr = ROBJECT_IVPTR(obj);
long len = ROBJECT_NUMIV(obj);
@@ -1661,7 +1661,7 @@ rb_class_superclass(VALUE klass)
if (klass == rb_cBasicObject) return Qnil;
rb_raise(rb_eTypeError, "uninitialized class");
}
- while (TYPE(super) == T_ICLASS) {
+ while (RB_TYPE_P(super, T_ICLASS)) {
super = RCLASS_SUPER(super);
}
if (!super) {
@@ -2157,7 +2157,7 @@ rb_to_integer(VALUE val, const char *method)
VALUE v;
if (FIXNUM_P(val)) return val;
- if (TYPE(val) == T_BIGNUM) return val;
+ if (RB_TYPE_P(val, T_BIGNUM)) return val;
v = convert_type(val, "Integer", method, TRUE);
if (!rb_obj_is_kind_of(v, rb_cInteger)) {
const char *cname = rb_obj_classname(val);
@@ -2173,7 +2173,7 @@ rb_check_to_integer(VALUE val, const char *method)
VALUE v;
if (FIXNUM_P(val)) return val;
- if (TYPE(val) == T_BIGNUM) return val;
+ if (RB_TYPE_P(val, T_BIGNUM)) return val;
v = convert_type(val, "Integer", method, FALSE);
if (!rb_obj_is_kind_of(v, rb_cInteger)) {
return Qnil;
@@ -2437,7 +2437,7 @@ rb_f_float(VALUE obj, VALUE arg)
VALUE
rb_to_float(VALUE val)
{
- if (TYPE(val) == T_FLOAT) return val;
+ if (RB_TYPE_P(val, T_FLOAT)) return val;
if (!rb_obj_is_kind_of(val, rb_cNumeric)) {
rb_raise(rb_eTypeError, "can't convert %s into Float",
NIL_P(val) ? "nil" :
@@ -2451,7 +2451,7 @@ rb_to_float(VALUE val)
VALUE
rb_check_to_float(VALUE val)
{
- if (TYPE(val) == T_FLOAT) return val;
+ if (RB_TYPE_P(val, T_FLOAT)) return val;
if (!rb_obj_is_kind_of(val, rb_cNumeric)) {
return Qnil;
}
diff --git a/pack.c b/pack.c
index 1616a8a638..d22a80a9be 100644
--- a/pack.c
+++ b/pack.c
@@ -243,7 +243,7 @@ num2i32(VALUE x)
x = rb_to_int(x); /* is nil OK? (should not) */
if (FIXNUM_P(x)) return FIX2LONG(x);
- if (TYPE(x) == T_BIGNUM) {
+ if (RB_TYPE_P(x, T_BIGNUM)) {
return rb_big2ulong_pack(x);
}
rb_raise(rb_eTypeError, "can't convert %s to `integer'", rb_obj_classname(x));
@@ -995,9 +995,9 @@ pack_pack(VALUE ary, VALUE fmt)
char c, *bufs, *bufe;
from = NEXTFROM;
- if (TYPE(from) == T_BIGNUM) {
+ if (RB_TYPE_P(from, T_BIGNUM)) {
VALUE big128 = rb_uint2big(128);
- while (TYPE(from) == T_BIGNUM) {
+ while (RB_TYPE_P(from, T_BIGNUM)) {
from = rb_big_divmod(from, big128);
c = NUM2INT(RARRAY_PTR(from)[1]) | 0x80; /* mod */
rb_str_buf_cat(buf, &c, sizeof(char));
diff --git a/parse.y b/parse.y
index ab17534b36..437f534f1d 100644
--- a/parse.y
+++ b/parse.y
@@ -5152,7 +5152,7 @@ debug_lines(const char *f)
CONST_ID(script_lines, "SCRIPT_LINES__");
if (rb_const_defined_at(rb_cObject, script_lines)) {
VALUE hash = rb_const_get_at(rb_cObject, script_lines);
- if (TYPE(hash) == T_HASH) {
+ if (RB_TYPE_P(hash, T_HASH)) {
VALUE fname = rb_str_new2(f);
VALUE lines = rb_ary_new();
rb_hash_aset(hash, fname, lines);
diff --git a/proc.c b/proc.c
index 68ea1d4b6d..8a19a88a2c 100644
--- a/proc.c
+++ b/proc.c
@@ -951,7 +951,7 @@ mnew(VALUE klass, VALUE obj, ID id, VALUE mclass, int scope)
}
rb_name_error(id, "method `%s' for %s `%s' is %s",
rb_id2name(id),
- (TYPE(klass) == T_MODULE) ? "module" : "class",
+ (RB_TYPE_P(klass, T_MODULE)) ? "module" : "class",
rb_class2name(klass),
v);
}
@@ -965,11 +965,11 @@ mnew(VALUE klass, VALUE obj, ID id, VALUE mclass, int scope)
klass = me->klass;
while (rclass != klass &&
- (FL_TEST(rclass, FL_SINGLETON) || TYPE(rclass) == T_ICLASS)) {
+ (FL_TEST(rclass, FL_SINGLETON) || RB_TYPE_P(rclass, T_ICLASS))) {
rclass = RCLASS_SUPER(rclass);
}
- if (TYPE(klass) == T_ICLASS) {
+ if (RB_TYPE_P(klass, T_ICLASS)) {
klass = RBASIC(klass)->klass;
}
diff --git a/process.c b/process.c
index c3d42ffd4e..a2cd4c6867 100644
--- a/process.c
+++ b/process.c
@@ -1418,7 +1418,7 @@ check_exec_redirect(VALUE key, VALUE val, VALUE options)
flags = rb_ary_entry(val, 1);
if (NIL_P(flags))
flags = INT2NUM(O_RDONLY);
- else if (TYPE(flags) == T_STRING)
+ else if (RB_TYPE_P(flags, T_STRING))
flags = INT2NUM(rb_io_modestr_oflags(StringValueCStr(flags)));
else
flags = rb_to_int(flags);
@@ -1433,7 +1433,7 @@ check_exec_redirect(VALUE key, VALUE val, VALUE options)
index = EXEC_OPTION_OPEN;
path = val;
FilePathValue(path);
- if (TYPE(key) == T_FILE)
+ if (RB_TYPE_P(key, T_FILE))
key = check_exec_redirect_fd(key, 1);
if (FIXNUM_P(key) && (FIX2INT(key) == 1 || FIX2INT(key) == 2))
flags = INT2NUM(O_WRONLY|O_CREAT|O_TRUNC);
@@ -1453,7 +1453,7 @@ check_exec_redirect(VALUE key, VALUE val, VALUE options)
ary = hide_obj(rb_ary_new());
rb_ary_store(options, index, ary);
}
- if (TYPE(key) != T_ARRAY) {
+ if (!RB_TYPE_P(key, T_ARRAY)) {
VALUE fd = check_exec_redirect_fd(key, !NIL_P(param));
rb_ary_push(ary, hide_obj(rb_assoc_new(fd, param)));
}
diff --git a/random.c b/random.c
index 192110a850..ebb4a60de0 100644
--- a/random.c
+++ b/random.c
@@ -1035,7 +1035,7 @@ rand_range(struct MT* mt, VALUE range)
if ((v = vmax = range_values(range, &beg, &end, &excl)) == Qfalse)
return Qfalse;
- if (TYPE(vmax) != T_FLOAT && (v = rb_check_to_integer(vmax, "to_int"), !NIL_P(v))) {
+ if (!RB_TYPE_P(vmax, T_FLOAT) && (v = rb_check_to_integer(vmax, "to_int"), !NIL_P(v))) {
long max;
vmax = v;
v = Qnil;
@@ -1149,7 +1149,7 @@ random_rand(int argc, VALUE *argv, VALUE obj)
if (NIL_P(vmax)) {
v = Qnil;
}
- else if (TYPE(vmax) != T_FLOAT && (v = rb_check_to_integer(vmax, "to_int"), !NIL_P(v))) {
+ else if (!RB_TYPE_P(vmax, T_FLOAT) && (v = rb_check_to_integer(vmax, "to_int"), !NIL_P(v))) {
v = rand_int(&rnd->mt, v, 1);
}
else if (v = rb_check_to_float(vmax), !NIL_P(v)) {
diff --git a/range.c b/range.c
index b7ae19118e..fb9ecd05b2 100644
--- a/range.c
+++ b/range.c
@@ -865,10 +865,10 @@ range_include(VALUE range, VALUE val)
}
return Qfalse;
}
- else if (TYPE(beg) == T_STRING && TYPE(end) == T_STRING &&
+ else if (RB_TYPE_P(beg, T_STRING) && RB_TYPE_P(end, T_STRING) &&
RSTRING_LEN(beg) == 1 && RSTRING_LEN(end) == 1) {
if (NIL_P(val)) return Qfalse;
- if (TYPE(val) == T_STRING) {
+ if (RB_TYPE_P(val, T_STRING)) {
if (RSTRING_LEN(val) == 0 || RSTRING_LEN(val) > 1)
return Qfalse;
else {
@@ -939,7 +939,7 @@ range_dumper(VALUE range)
static VALUE
range_loader(VALUE range, VALUE obj)
{
- if (TYPE(obj) != T_OBJECT || RBASIC(obj)->klass != rb_cObject) {
+ if (!RB_TYPE_P(obj, T_OBJECT) || RBASIC(obj)->klass != rb_cObject) {
rb_raise(rb_eTypeError, "not a dumped range object");
}
diff --git a/rational.c b/rational.c
index 40b480df6e..3af98c76c5 100644
--- a/rational.c
+++ b/rational.c
@@ -106,7 +106,7 @@ f_mul(VALUE x, VALUE y)
if (FIXNUM_P(y)) {
long iy = FIX2LONG(y);
if (iy == 0) {
- if (FIXNUM_P(x) || TYPE(x) == T_BIGNUM)
+ if (FIXNUM_P(x) || RB_TYPE_P(x, T_BIGNUM))
return ZERO;
}
else if (iy == 1)
@@ -115,7 +115,7 @@ f_mul(VALUE x, VALUE y)
else if (FIXNUM_P(x)) {
long ix = FIX2LONG(x);
if (ix == 0) {
- if (FIXNUM_P(y) || TYPE(y) == T_BIGNUM)
+ if (FIXNUM_P(y) || RB_TYPE_P(y, T_BIGNUM))
return ZERO;
}
else if (ix == 1)
@@ -141,14 +141,14 @@ fun1(negate)
inline static VALUE
f_to_i(VALUE x)
{
- if (TYPE(x) == T_STRING)
+ if (RB_TYPE_P(x, T_STRING))
return rb_str_to_inum(x, 10, 0);
return rb_funcall(x, id_to_i, 0);
}
inline static VALUE
f_to_f(VALUE x)
{
- if (TYPE(x) == T_STRING)
+ if (RB_TYPE_P(x, T_STRING))
return DBL2NUM(rb_str_to_dbl(x, 0));
return rb_funcall(x, id_to_f, 0);
}
@@ -2161,7 +2161,7 @@ string_to_r(VALUE self)
a1 = RARRAY_PTR(a)[0];
if (!NIL_P(a1)) {
- if (TYPE(a1) == T_FLOAT)
+ if (RB_TYPE_P(a1, T_FLOAT))
rb_raise(rb_eFloatDomainError, "Infinity");
return a1;
}
diff --git a/re.c b/re.c
index 9fdbf547aa..6484baa664 100644
--- a/re.c
+++ b/re.c
@@ -2587,7 +2587,7 @@ static VALUE
rb_reg_equal(VALUE re1, VALUE re2)
{
if (re1 == re2) return Qtrue;
- if (TYPE(re2) != T_REGEXP) return Qfalse;
+ if (!RB_TYPE_P(re2, T_REGEXP)) return Qfalse;
rb_reg_check(re1); rb_reg_check(re2);
if (FL_TEST(re1, KCODE_FIXED) != FL_TEST(re2, KCODE_FIXED)) return Qfalse;
if (RREGEXP(re1)->ptr->options != RREGEXP(re2)->ptr->options) return Qfalse;
@@ -2635,7 +2635,7 @@ match_equal(VALUE match1, VALUE match2)
{
const struct re_registers *regs1, *regs2;
if (match1 == match2) return Qtrue;
- if (TYPE(match2) != T_MATCH) return Qfalse;
+ if (!RB_TYPE_P(match2, T_MATCH)) return Qfalse;
if (!rb_str_equal(RMATCH(match1)->str, RMATCH(match2)->str)) return Qfalse;
if (!rb_reg_equal(RMATCH(match1)->regexp, RMATCH(match2)->regexp)) return Qfalse;
regs1 = RMATCH_REGS(match1);
@@ -2795,7 +2795,7 @@ rb_reg_match2(VALUE re)
long start;
VALUE line = rb_lastline_get();
- if (TYPE(line) != T_STRING) {
+ if (!RB_TYPE_P(line, T_STRING)) {
rb_backref_set(Qnil);
return Qnil;
}
diff --git a/ruby.c b/ruby.c
index b53784feb1..2e6751f0f2 100644
--- a/ruby.c
+++ b/ruby.c
@@ -1137,7 +1137,7 @@ uscore_get(void)
VALUE line;
line = rb_lastline_get();
- if (TYPE(line) != T_STRING) {
+ if (!RB_TYPE_P(line, T_STRING)) {
rb_raise(rb_eTypeError, "$_ value need to be String (%s given)",
NIL_P(line) ? "nil" : rb_obj_classname(line));
}
diff --git a/safe.c b/safe.c
index e2ed5979d2..05c1aa395b 100644
--- a/safe.c
+++ b/safe.c
@@ -122,7 +122,7 @@ void
rb_check_safe_str(VALUE x)
{
rb_check_safe_obj(x);
- if (TYPE(x) != T_STRING) {
+ if (!RB_TYPE_P(x, T_STRING)) {
rb_raise(rb_eTypeError, "wrong argument type %s (expected String)",
rb_obj_classname(x));
}
diff --git a/string.c b/string.c
index 711918b4e6..1cc41fea27 100644
--- a/string.c
+++ b/string.c
@@ -854,11 +854,11 @@ rb_obj_as_string(VALUE obj)
{
VALUE str;
- if (TYPE(obj) == T_STRING) {
+ if (RB_TYPE_P(obj, T_STRING)) {
return obj;
}
str = rb_funcall(obj, id_to_s, 0);
- if (TYPE(str) != T_STRING)
+ if (!RB_TYPE_P(str, T_STRING))
return rb_any_to_s(obj);
if (OBJ_TAINTED(obj)) OBJ_TAINT(str);
return str;
@@ -1404,7 +1404,7 @@ VALUE
rb_string_value(volatile VALUE *ptr)
{
VALUE s = *ptr;
- if (TYPE(s) != T_STRING) {
+ if (!RB_TYPE_P(s, T_STRING)) {
s = rb_str_to_str(s);
*ptr = s;
}
@@ -2075,7 +2075,7 @@ rb_str_concat(VALUE str1, VALUE str2)
{
unsigned int lc;
- if (FIXNUM_P(str2) || TYPE(str2) == T_BIGNUM) {
+ if (FIXNUM_P(str2) || RB_TYPE_P(str2, T_BIGNUM)) {
if (rb_num_to_uint(str2, &lc) == 0) {
}
else if (FIXNUM_P(str2)) {
@@ -2250,7 +2250,7 @@ VALUE
rb_str_equal(VALUE str1, VALUE str2)
{
if (str1 == str2) return Qtrue;
- if (TYPE(str2) != T_STRING) {
+ if (!RB_TYPE_P(str2, T_STRING)) {
if (!rb_respond_to(str2, rb_intern("to_str"))) {
return Qfalse;
}
@@ -2270,7 +2270,7 @@ static VALUE
rb_str_eql(VALUE str1, VALUE str2)
{
if (str1 == str2) return Qtrue;
- if (TYPE(str2) != T_STRING) return Qfalse;
+ if (!RB_TYPE_P(str2, T_STRING)) return Qfalse;
return str_eql(str1, str2);
}
@@ -2302,7 +2302,7 @@ rb_str_cmp_m(VALUE str1, VALUE str2)
{
long result;
- if (TYPE(str2) != T_STRING) {
+ if (!RB_TYPE_P(str2, T_STRING)) {
if (!rb_respond_to(str2, rb_intern("to_str"))) {
return Qnil;
}
@@ -2472,7 +2472,7 @@ rb_str_index_m(int argc, VALUE *argv, VALUE str)
if (pos < 0) {
pos += str_strlen(str, STR_ENC_GET(str));
if (pos < 0) {
- if (TYPE(sub) == T_REGEXP) {
+ if (RB_TYPE_P(sub, T_REGEXP)) {
rb_backref_set(Qnil);
}
return Qnil;
@@ -2581,7 +2581,7 @@ rb_str_rindex_m(int argc, VALUE *argv, VALUE str)
if (pos < 0) {
pos += len;
if (pos < 0) {
- if (TYPE(sub) == T_REGEXP) {
+ if (RB_TYPE_P(sub, T_REGEXP)) {
rb_backref_set(Qnil);
}
return Qnil;
@@ -5751,7 +5751,7 @@ rb_str_split_m(int argc, VALUE *argv, VALUE str)
}
else {
fs_set:
- if (TYPE(spat) == T_STRING) {
+ if (RB_TYPE_P(spat, T_STRING)) {
rb_encoding *enc2 = STR_ENC_GET(spat);
split_type = string;
@@ -7064,7 +7064,7 @@ rb_str_partition(VALUE str, VALUE sep)
long pos;
int regex = FALSE;
- if (TYPE(sep) == T_REGEXP) {
+ if (RB_TYPE_P(sep, T_REGEXP)) {
pos = rb_reg_search(sep, str, 0, 0);
regex = TRUE;
}
@@ -7114,7 +7114,7 @@ rb_str_rpartition(VALUE str, VALUE sep)
long pos = RSTRING_LEN(str);
int regex = FALSE;
- if (TYPE(sep) == T_REGEXP) {
+ if (RB_TYPE_P(sep, T_REGEXP)) {
pos = rb_reg_search(sep, str, pos, 1);
regex = TRUE;
}
@@ -7206,7 +7206,7 @@ rb_str_end_with(int argc, VALUE *argv, VALUE str)
void
rb_str_setter(VALUE val, ID id, VALUE *var)
{
- if (!NIL_P(val) && TYPE(val) != T_STRING) {
+ if (!NIL_P(val) && !RB_TYPE_P(val, T_STRING)) {
rb_raise(rb_eTypeError, "value of %s must be String", rb_id2name(id));
}
*var = val;
diff --git a/struct.c b/struct.c