summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-05-23 07:13:21 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-05-23 07:13:21 +0000
commitb0dd250dc95ea0fae89c3201967039d582fbf156 (patch)
treefb9483ca974a305e496eb87e960dcfecf7b9115f /ext
parent87c8c5edf43a7f7d33d5fe75f51ef410a03b93b1 (diff)
use RB_TYPE_P() instead of comparison of TYPE()
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35763 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r--ext/io/console/console.c2
-rw-r--r--ext/objspace/objspace.c6
-rw-r--r--ext/pathname/pathname.c4
-rw-r--r--ext/pty/pty.c2
-rw-r--r--ext/racc/cparse/cparse.c2
-rw-r--r--ext/socket/ancdata.c4
-rw-r--r--ext/socket/raddrinfo.c12
-rw-r--r--ext/stringio/stringio.c6
-rw-r--r--ext/zlib/zlib.c2
9 files changed, 20 insertions, 20 deletions
diff --git a/ext/io/console/console.c b/ext/io/console/console.c
index 7880e7a..cedc057 100644
--- a/ext/io/console/console.c
+++ b/ext/io/console/console.c
@@ -659,7 +659,7 @@ console_dev(VALUE klass)
if (klass == rb_cIO) klass = rb_cFile;
if (rb_const_defined(klass, id_console)) {
con = rb_const_get(klass, id_console);
- if (TYPE(con) == T_FILE) {
+ if (RB_TYPE_P(con, T_FILE)) {
if ((fptr = RFILE(con)->fptr) && GetReadFD(fptr) != -1)
return con;
}
diff --git a/ext/objspace/objspace.c b/ext/objspace/objspace.c
index f37499f..337dcb8 100644
--- a/ext/objspace/objspace.c
+++ b/ext/objspace/objspace.c
@@ -300,7 +300,7 @@ count_objects_size(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");
}
@@ -404,7 +404,7 @@ count_nodes(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");
}
@@ -609,7 +609,7 @@ count_tdata_objects(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/ext/pathname/pathname.c b/ext/pathname/pathname.c
index 84a2b5d..f890019 100644
--- a/ext/pathname/pathname.c
+++ b/ext/pathname/pathname.c
@@ -9,7 +9,7 @@ get_strpath(VALUE obj)
{
VALUE strpath;
strpath = rb_ivar_get(obj, id_at_path);
- if (TYPE(strpath) != T_STRING)
+ if (!RB_TYPE_P(strpath, T_STRING))
rb_raise(rb_eTypeError, "unexpected @path");
return strpath;
}
@@ -28,7 +28,7 @@ static VALUE
path_initialize(VALUE self, VALUE arg)
{
VALUE str;
- if (TYPE(arg) == T_STRING) {
+ if (RB_TYPE_P(arg, T_STRING)) {
str = arg;
}
else {
diff --git a/ext/pty/pty.c b/ext/pty/pty.c
index 126e33c..06d4075 100644
--- a/ext/pty/pty.c
+++ b/ext/pty/pty.c
@@ -461,7 +461,7 @@ pty_close_pty(VALUE assoc)
for (i = 0; i < 2; i++) {
io = rb_ary_entry(assoc, i);
- if (TYPE(io) == T_FILE && 0 <= RFILE(io)->fptr->fd)
+ if (RB_TYPE_P(io, T_FILE) && 0 <= RFILE(io)->fptr->fd)
rb_io_close(io);
}
return Qnil;
diff --git a/ext/racc/cparse/cparse.c b/ext/racc/cparse/cparse.c
index 3a2a8ae..10a9a03 100644
--- a/ext/racc/cparse/cparse.c
+++ b/ext/racc/cparse/cparse.c
@@ -416,7 +416,7 @@ extract_user_token(struct cparse_params *v, VALUE block_args,
return;
}
- if (TYPE(block_args) != T_ARRAY) {
+ if (!RB_TYPE_P(block_args, T_ARRAY)) {
rb_raise(rb_eTypeError,
"%s() %s %s (must be Array[2])",
v->lex_is_iterator ? rb_id2name(v->lexmid) : "next_token",
diff --git a/ext/socket/ancdata.c b/ext/socket/ancdata.c
index f8379cc..52f92a1 100644
--- a/ext/socket/ancdata.c
+++ b/ext/socket/ancdata.c
@@ -196,7 +196,7 @@ ancillary_s_unix_rights(int argc, VALUE *argv, VALUE klass)
for (i = 0 ; i < argc; i++) {
VALUE obj = argv[i];
- if (TYPE(obj) != T_FILE) {
+ if (!RB_TYPE_P(obj, T_FILE)) {
rb_raise(rb_eTypeError, "IO expected");
}
rb_ary_push(ary, obj);
@@ -1496,7 +1496,7 @@ bsock_recvmsg_internal(int argc, VALUE *argv, VALUE sock, int nonblock)
rb_secure(4);
vopts = Qnil;
- if (0 < argc && TYPE(argv[argc-1]) == T_HASH)
+ if (0 < argc && RB_TYPE_P(argv[argc-1], T_HASH))
vopts = argv[--argc];
rb_scan_args(argc, argv, "03", &vmaxdatlen, &vflags, &vmaxctllen);
diff --git a/ext/socket/raddrinfo.c b/ext/socket/raddrinfo.c
index 8c409f1..a7391c9 100644
--- a/ext/socket/raddrinfo.c
+++ b/ext/socket/raddrinfo.c
@@ -673,25 +673,25 @@ make_inspectname(VALUE node, VALUE service, struct addrinfo *res)
sizeof(hbuf), pbuf, sizeof(pbuf),
NI_NUMERICHOST|NI_NUMERICSERV);
if (ret == 0) {
- if (TYPE(node) == T_STRING && strcmp(hbuf, RSTRING_PTR(node)) == 0)
+ if (RB_TYPE_P(node, T_STRING) && strcmp(hbuf, RSTRING_PTR(node)) == 0)
node = Qnil;
- if (TYPE(service) == T_STRING && strcmp(pbuf, RSTRING_PTR(service)) == 0)
+ if (RB_TYPE_P(service, T_STRING) && strcmp(pbuf, RSTRING_PTR(service)) == 0)
service = Qnil;
- else if (TYPE(service) == T_FIXNUM && atoi(pbuf) == FIX2INT(service))
+ else if (RB_TYPE_P(service, T_FIXNUM) && atoi(pbuf) == FIX2INT(service))
service = Qnil;
}
}
- if (TYPE(node) == T_STRING) {
+ if (RB_TYPE_P(node, T_STRING)) {
inspectname = rb_str_dup(node);
}
- if (TYPE(service) == T_STRING) {
+ if (RB_TYPE_P(service, T_STRING)) {
if (NIL_P(inspectname))
inspectname = rb_sprintf(":%s", StringValueCStr(service));
else
rb_str_catf(inspectname, ":%s", StringValueCStr(service));
}
- else if (TYPE(service) == T_FIXNUM && FIX2INT(service) != 0)
+ else if (RB_TYPE_P(service, T_FIXNUM) && FIX2INT(service) != 0)
{
if (NIL_P(inspectname))
inspectname = rb_sprintf(":%d", FIX2INT(service));
diff --git a/ext/stringio/stringio.c b/ext/stringio/stringio.c
index 12e4a6c..2ed0943 100644
--- a/ext/stringio/stringio.c
+++ b/ext/stringio/stringio.c
@@ -506,7 +506,7 @@ static VALUE
strio_reopen(int argc, VALUE *argv, VALUE self)
{
rb_io_taint_check(self);
- if (argc == 1 && TYPE(*argv) != T_STRING) {
+ if (argc == 1 && !RB_TYPE_P(*argv, T_STRING)) {
return strio_copy(self, *argv);
}
strio_init(argc, argv, StringIO(self));
@@ -931,7 +931,7 @@ strio_getline(int argc, VALUE *argv, struct StringIO *ptr)
break;
case 1:
- if (!NIL_P(str) && TYPE(str) != T_STRING) {
+ if (!NIL_P(str) && !RB_TYPE_P(str, T_STRING)) {
VALUE tmp = rb_check_string_type(str);
if (NIL_P(tmp)) {
limit = NUM2LONG(str);
@@ -1124,7 +1124,7 @@ strio_write(VALUE self, VALUE str)
rb_encoding *enc, *enc2;
RB_GC_GUARD(str);
- if (TYPE(str) != T_STRING)
+ if (!RB_TYPE_P(str, T_STRING))
str = rb_obj_as_string(str);
enc = rb_enc_get(ptr->string);
enc2 = rb_enc_get(str);
diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c
index fee74bf..4086496 100644
--- a/ext/zlib/zlib.c
+++ b/ext/zlib/zlib.c
@@ -3369,7 +3369,7 @@ rb_gzwriter_write(VALUE obj, VALUE str)
{
struct gzfile *gz = get_gzfile(obj);
- if (TYPE(str) != T_STRING)
+ if (!RB_TYPE_P(str, T_STRING))
str = rb_obj_as_string(str);
if (gz->enc2 && gz->enc2 != rb_ascii8bit_encoding()) {
str = rb_str_conv_enc(str, rb_enc_get(str), gz->enc2);