summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-08-03 01:56:01 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-08-03 01:56:01 +0000
commit1d670ab0f090c0232e2a7a619b70ebb559453331 (patch)
tree8b603d1279d3e5f4e53e4d5407074c46a0639920
parentfdfb939d72e8b66540df42821e3facfcda5aaf15 (diff)
ext: prefer RB_TYPE_P over comparison TYPE with constants
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47042 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ext/date/date_core.c6
-rw-r--r--ext/date/date_parse.c6
-rw-r--r--ext/openssl/ossl_bio.c2
-rw-r--r--ext/openssl/ossl_digest.c2
-rw-r--r--ext/openssl/ossl_pkcs7.c2
-rw-r--r--ext/openssl/ossl_ssl.c8
-rw-r--r--ext/tk/tcltklib.c8
-rw-r--r--ext/tk/tkutil/tkutil.c40
-rw-r--r--ext/win32ole/win32ole.c76
9 files changed, 75 insertions, 75 deletions
diff --git a/ext/date/date_core.c b/ext/date/date_core.c
index 0775fecbf2..7ed21db5fc 100644
--- a/ext/date/date_core.c
+++ b/ext/date/date_core.c
@@ -304,7 +304,7 @@ union DateData {
inline static VALUE
canon(VALUE x)
{
- if (TYPE(x) == T_RATIONAL) {
+ if (RB_TYPE_P(x, T_RATIONAL)) {
VALUE den = rb_rational_den(x);
if (FIXNUM_P(den) && FIX2LONG(den) == 1)
return rb_rational_num(x);
@@ -5843,7 +5843,7 @@ minus_dd(VALUE self, VALUE other)
if (f_nonzero_p(sf))
r = f_add(r, ns_to_day(sf));
- if (TYPE(r) == T_RATIONAL)
+ if (RB_TYPE_P(r, T_RATIONAL))
return r;
return rb_rational_new1(r);
}
@@ -7048,7 +7048,7 @@ d_lite_marshal_load(VALUE self, VALUE a)
rb_check_frozen(self);
rb_check_trusted(self);
- if (TYPE(a) != T_ARRAY)
+ if (!RB_TYPE_P(a, T_ARRAY))
rb_raise(rb_eTypeError, "expected an array");
switch (RARRAY_LEN(a)) {
diff --git a/ext/date/date_parse.c b/ext/date/date_parse.c
index 3003b45239..239e2643b0 100644
--- a/ext/date/date_parse.c
+++ b/ext/date/date_parse.c
@@ -70,7 +70,7 @@ s3e(VALUE hash, VALUE y, VALUE m, VALUE d, int bc)
{
VALUE c = Qnil;
- if (TYPE(m) != T_STRING)
+ if (!RB_TYPE_P(m, T_STRING))
m = f_to_s(m);
if (!NIL_P(y) && !NIL_P(m) && NIL_P(d)) {
@@ -585,12 +585,12 @@ date_zone_to_diff(VALUE str)
if (NIL_P(hour))
offset = INT2FIX(0);
else {
- if (TYPE(hour) == T_STRING)
+ if (RB_TYPE_P(hour, T_STRING))
hour = str2num(hour);
offset = f_mul(hour, INT2FIX(3600));
}
if (!NIL_P(min)) {
- if (TYPE(min) == T_STRING)
+ if (RB_TYPE_P(min, T_STRING))
min = str2num(min);
offset = f_add(offset, f_mul(min, INT2FIX(60)));
}
diff --git a/ext/openssl/ossl_bio.c b/ext/openssl/ossl_bio.c
index a11c08c1a3..e150de0ad9 100644
--- a/ext/openssl/ossl_bio.c
+++ b/ext/openssl/ossl_bio.c
@@ -18,7 +18,7 @@ ossl_obj2bio(VALUE obj)
{
BIO *bio;
- if (TYPE(obj) == T_FILE) {
+ if (RB_TYPE_P(obj, T_FILE)) {
rb_io_t *fptr;
FILE *fp;
int fd;
diff --git a/ext/openssl/ossl_digest.c b/ext/openssl/ossl_digest.c
index fdf13e98e5..7e5e7ff1ab 100644
--- a/ext/openssl/ossl_digest.c
+++ b/ext/openssl/ossl_digest.c
@@ -38,7 +38,7 @@ GetDigestPtr(VALUE obj)
const EVP_MD *md;
ASN1_OBJECT *oid = NULL;
- if (TYPE(obj) == T_STRING) {
+ if (RB_TYPE_P(obj, T_STRING)) {
const char *name = StringValueCStr(obj);
md = EVP_get_digestbyname(name);
diff --git a/ext/openssl/ossl_pkcs7.c b/ext/openssl/ossl_pkcs7.c
index 553a580923..66c20538d8 100644
--- a/ext/openssl/ossl_pkcs7.c
+++ b/ext/openssl/ossl_pkcs7.c
@@ -376,7 +376,7 @@ ossl_pkcs7_sym2typeid(VALUE sym)
{ NULL, 0 },
};
- if(TYPE(sym) == T_SYMBOL) s = rb_id2name(SYM2ID(sym));
+ if (RB_TYPE_P(sym, T_SYMBOL)) s = rb_id2name(SYM2ID(sym));
else s = StringValuePtr(sym);
for(i = 0; i < numberof(p7_type_tab); i++){
if(p7_type_tab[i].name == NULL)
diff --git a/ext/openssl/ossl_ssl.c b/ext/openssl/ossl_ssl.c
index f314a7ac25..a13255f90e 100644
--- a/ext/openssl/ossl_ssl.c
+++ b/ext/openssl/ossl_ssl.c
@@ -190,7 +190,7 @@ ossl_sslctx_set_ssl_version(VALUE self, VALUE ssl_method)
int i;
SSL_CTX *ctx;
- if(TYPE(ssl_method) == T_SYMBOL)
+ if (RB_TYPE_P(ssl_method, T_SYMBOL))
s = rb_id2name(SYM2ID(ssl_method));
else
s = StringValuePtr(ssl_method);
@@ -716,7 +716,7 @@ ossl_sslctx_setup(VALUE self)
val = ossl_sslctx_get_client_ca(self);
if(!NIL_P(val)){
- if(TYPE(val) == T_ARRAY){
+ if (RB_TYPE_P(val, T_ARRAY)) {
for(i = 0; i < RARRAY_LEN(val); i++){
client_ca = GetX509CertPtr(RARRAY_PTR(val)[i]);
if (!SSL_CTX_add_client_CA(ctx, client_ca)){
@@ -882,11 +882,11 @@ ossl_sslctx_set_ciphers(VALUE self, VALUE v)
rb_check_frozen(self);
if (NIL_P(v))
return v;
- else if (TYPE(v) == T_ARRAY) {
+ else if (RB_TYPE_P(v, T_ARRAY)) {
str = rb_str_new(0, 0);
for (i = 0; i < RARRAY_LEN(v); i++) {
elem = rb_ary_entry(v, i);
- if (TYPE(elem) == T_ARRAY) elem = rb_ary_entry(elem, 0);
+ if (RB_TYPE_P(elem, T_ARRAY)) elem = rb_ary_entry(elem, 0);
elem = rb_String(elem);
rb_str_append(str, elem);
if (i < RARRAY_LEN(v)-1) rb_str_cat2(str, ":");
diff --git a/ext/tk/tcltklib.c b/ext/tk/tcltklib.c
index 27771bff29..c67b0207c5 100644
--- a/ext/tk/tcltklib.c
+++ b/ext/tk/tcltklib.c
@@ -3110,7 +3110,7 @@ ip_set_exc_message(interp, exc)
}
if (NIL_P(enc)) {
encoding = (Tcl_Encoding)NULL;
- } else if (TYPE(enc) == T_STRING) {
+ } else if (RB_TYPE_P(enc, T_STRING)) {
/* encoding = Tcl_GetEncoding(interp, RSTRING_PTR(enc)); */
encoding = Tcl_GetEncoding((Tcl_Interp*)NULL, RSTRING_PTR(enc));
} else {
@@ -3320,7 +3320,7 @@ tcl_protect_core(interp, proc, data) /* should not raise exception */
if (rb_obj_is_kind_of(exc, eLocalJumpError)) {
VALUE reason = rb_ivar_get(exc, ID_at_reason);
- if (TYPE(reason) == T_SYMBOL) {
+ if (RB_TYPE_P(reason, T_SYMBOL)) {
if (SYM2ID(reason) == ID_return)
return TCL_RETURN;
@@ -7949,7 +7949,7 @@ lib_toUTF8_core(ip_obj, src, encodename)
rb_thread_critical = Qtrue;
if (NIL_P(encodename)) {
- if (TYPE(str) == T_STRING) {
+ if (RB_TYPE_P(str, T_STRING)) {
volatile VALUE enc;
#ifdef HAVE_RUBY_ENCODING_H
@@ -8127,7 +8127,7 @@ lib_fromUTF8_core(ip_obj, src, encodename)
if (NIL_P(encodename)) {
volatile VALUE enc;
- if (TYPE(str) == T_STRING) {
+ if (RB_TYPE_P(str, T_STRING)) {
enc = rb_attr_get(str, ID_at_enc);
if (!NIL_P(enc)) {
StringValue(enc);
diff --git a/ext/tk/tkutil/tkutil.c b/ext/tk/tkutil/tkutil.c
index fd8972645a..2cde2265e0 100644
--- a/ext/tk/tkutil/tkutil.c
+++ b/ext/tk/tkutil/tkutil.c
@@ -312,7 +312,7 @@ ary2list(ary, enc_flag, self)
if (NIL_P(enc_flag)) {
dst_enc = sys_enc;
req_chk_flag = 1;
- } else if (TYPE(enc_flag) == T_TRUE || TYPE(enc_flag) == T_FALSE) {
+ } else if (enc_flag == Qtrue || enc_flag == Qfalse) {
dst_enc = enc_flag;
req_chk_flag = 0;
} else {
@@ -323,7 +323,7 @@ ary2list(ary, enc_flag, self)
/* size = RARRAY_LEN(ary); */
size = 0;
for(idx = 0; idx < RARRAY_LEN(ary); idx++) {
- if (TYPE(RARRAY_PTR(ary)[idx]) == T_HASH) {
+ if (RB_TYPE_P(RARRAY_PTR(ary)[idx], T_HASH)) {
size += 2 * RHASH_SIZE(RARRAY_PTR(ary)[idx]);
} else {
size++;
@@ -433,7 +433,7 @@ ary2list(ary, enc_flag, self)
RARRAY_PTR(dst)[idx] = str_val;
}
val = rb_apply(cTclTkLib, ID_merge_tklist, dst);
- if (TYPE(dst_enc) == T_STRING) {
+ if (RB_TYPE_P(dst_enc, T_STRING)) {
val = rb_funcall(cTclTkLib, ID_fromUTF8, 2, val, dst_enc);
rb_ivar_set(val, ID_at_enc, dst_enc);
} else {
@@ -466,7 +466,7 @@ ary2list2(ary, enc_flag, self)
if (NIL_P(enc_flag)) {
dst_enc = sys_enc;
req_chk_flag = 1;
- } else if (TYPE(enc_flag) == T_TRUE || TYPE(enc_flag) == T_FALSE) {
+ } else if (enc_flag == Qtrue || enc_flag == Qfalse) {
dst_enc = enc_flag;
req_chk_flag = 0;
} else {
@@ -527,7 +527,7 @@ ary2list2(ary, enc_flag, self)
RARRAY_PTR(dst)[idx] = str_val;
}
val = rb_apply(cTclTkLib, ID_merge_tklist, dst);
- if (TYPE(dst_enc) == T_STRING) {
+ if (RB_TYPE_P(dst_enc, T_STRING)) {
val = rb_funcall(cTclTkLib, ID_fromUTF8, 2, val, dst_enc);
rb_ivar_set(val, ID_at_enc, dst_enc);
} else {
@@ -561,7 +561,7 @@ assoc2kv(assoc, ary, self)
for(i = 0; i < len; i++) {
pair = RARRAY_PTR(assoc)[i];
- if (TYPE(pair) != T_ARRAY) {
+ if (!RB_TYPE_P(pair, T_ARRAY)) {
rb_ary_push(dst, key2keyname(pair));
continue;
}
@@ -609,7 +609,7 @@ assoc2kv_enc(assoc, ary, self)
for(i = 0; i < len; i++) {
pair = RARRAY_PTR(assoc)[i];
- if (TYPE(pair) != T_ARRAY) {
+ if (!RB_TYPE_P(pair, T_ARRAY)) {
rb_ary_push(dst, key2keyname(pair));
continue;
}
@@ -950,7 +950,7 @@ tk_conv_args(argc, argv, self)
old_gc = rb_gc_disable();
for(size = 0, idx = 2; idx < argc; idx++) {
- if (TYPE(argv[idx]) == T_HASH) {
+ if (RB_TYPE_P(argv[idx], T_HASH)) {
size += 2 * RHASH_SIZE(argv[idx]);
} else {
size++;
@@ -959,7 +959,7 @@ tk_conv_args(argc, argv, self)
/* dst = rb_ary_new2(argc - 2); */
dst = rb_ary_new2(size);
for(idx = 2; idx < argc; idx++) {
- if (TYPE(argv[idx]) == T_HASH) {
+ if (RB_TYPE_P(argv[idx], T_HASH)) {
if (RTEST(argv[1])) {
hash2kv_enc(argv[idx], dst, self);
} else {
@@ -984,7 +984,7 @@ tcl2rb_bool(self, value)
VALUE self;
VALUE value;
{
- if (TYPE(value) == T_FIXNUM) {
+ if (RB_TYPE_P(value, T_FIXNUM)) {
if (NUM2INT(value) == 0) {
return Qfalse;
} else {
@@ -992,7 +992,7 @@ tcl2rb_bool(self, value)
}
}
- if (TYPE(value) == T_TRUE || TYPE(value) == T_FALSE) {
+ if (value == Qtrue || value == Qfalse) {
return value;
}
@@ -1281,7 +1281,7 @@ cbsubst_def_attr_aliases(self, tbl)
{
struct cbsubst_info *inf;
- if (TYPE(tbl) != T_HASH) {
+ if (!RB_TYPE_P(tbl, T_HASH)) {
rb_raise(rb_eArgError, "expected a Hash");
}
@@ -1306,7 +1306,7 @@ cbsubst_sym_to_subst(self, sym)
ID id;
volatile VALUE ret;
- if (TYPE(sym) != T_SYMBOL) return sym;
+ if (!RB_TYPE_P(sym, T_SYMBOL)) return sym;
Data_Get_Struct(rb_const_get(self, ID_SUBST_INFO),
struct cbsubst_info, inf);
@@ -1556,14 +1556,14 @@ cbsubst_table_setup(argc, argv, self)
len = RARRAY_LEN(key_inf);
for(idx = 0; idx < len; idx++) {
inf = RARRAY_PTR(key_inf)[idx];
- if (TYPE(inf) != T_ARRAY) continue;
+ if (!RB_TYPE_P(inf, T_ARRAY)) continue;
- if (TYPE(RARRAY_PTR(inf)[0]) == T_STRING) {
+ if (RB_TYPE_P(RARRAY_PTR(inf)[0], T_STRING)) {
chr = *(RSTRING_PTR(RARRAY_PTR(inf)[0]));
} else {
chr = NUM2CHR(RARRAY_PTR(inf)[0]);
}
- if (TYPE(RARRAY_PTR(inf)[1]) == T_STRING) {
+ if (RB_TYPE_P(RARRAY_PTR(inf)[1], T_STRING)) {
subst_inf->type[chr] = *(RSTRING_PTR(RARRAY_PTR(inf)[1]));
} else {
subst_inf->type[chr] = NUM2CHR(RARRAY_PTR(inf)[1]);
@@ -1587,7 +1587,7 @@ cbsubst_table_setup(argc, argv, self)
len = RARRAY_LEN(longkey_inf);
for(idx = 0; idx < len; idx++) {
inf = RARRAY_PTR(longkey_inf)[idx];
- if (TYPE(inf) != T_ARRAY) continue;
+ if (!RB_TYPE_P(inf, T_ARRAY)) continue;
chr = (unsigned char)(0x80 + idx);
subst_inf->keylen[chr] = RSTRING_LEN(RARRAY_PTR(inf)[0]);
@@ -1602,7 +1602,7 @@ cbsubst_table_setup(argc, argv, self)
subst_inf->key[chr][RSTRING_LEN(RARRAY_PTR(inf)[0])] = '\0';
}
#endif
- if (TYPE(RARRAY_PTR(inf)[1]) == T_STRING) {
+ if (RB_TYPE_P(RARRAY_PTR(inf)[1], T_STRING)) {
subst_inf->type[chr] = *(RSTRING_PTR(RARRAY_PTR(inf)[1]));
} else {
subst_inf->type[chr] = NUM2CHR(RARRAY_PTR(inf)[1]);
@@ -1624,9 +1624,9 @@ cbsubst_table_setup(argc, argv, self)
len = RARRAY_LEN(proc_inf);
for(idx = 0; idx < len; idx++) {
inf = RARRAY_PTR(proc_inf)[idx];
- if (TYPE(inf) != T_ARRAY) continue;
+ if (!RB_TYPE_P(inf, T_ARRAY)) continue;
rb_hash_aset(subst_inf->proc,
- ((TYPE(RARRAY_PTR(inf)[0]) == T_STRING)?
+ (RB_TYPE_P(RARRAY_PTR(inf)[0], T_STRING)?
INT2FIX(*(RSTRING_PTR(RARRAY_PTR(inf)[0]))) :
RARRAY_PTR(inf)[0]),
RARRAY_PTR(inf)[1]);
diff --git a/ext/win32ole/win32ole.c b/ext/win32ole/win32ole.c
index 219e173d76..22d6626b5a 100644
--- a/ext/win32ole/win32ole.c
+++ b/ext/win32ole/win32ole.c
@@ -1363,7 +1363,7 @@ ole_ary_m_entry(VALUE val, LONG *pid)
VALUE obj = Qnil;
int i = 0;
obj = val;
- while(TYPE(obj) == T_ARRAY) {
+ while(RB_TYPE_P(obj, T_ARRAY)) {
obj = rb_ary_entry(obj, pid[i]);
i++;
}
@@ -1489,7 +1489,7 @@ dimension(VALUE val) {
long dim1 = 0;
long len = 0;
long i = 0;
- if (TYPE(val) == T_ARRAY) {
+ if (RB_TYPE_P(val, T_ARRAY)) {
len = RARRAY_LEN(val);
for (i = 0; i < len; i++) {
dim1 = dimension(rb_ary_entry(val, i));
@@ -1510,11 +1510,11 @@ ary_len_of_dim(VALUE ary, long dim) {
long i = 0;
VALUE val;
if (dim == 0) {
- if (TYPE(ary) == T_ARRAY) {
+ if (RB_TYPE_P(ary, T_ARRAY)) {
ary_len = RARRAY_LEN(ary);
}
} else {
- if (TYPE(ary) == T_ARRAY) {
+ if (RB_TYPE_P(ary, T_ARRAY)) {
len = RARRAY_LEN(ary);
for (i = 0; i < len; i++) {
val = rb_ary_entry(ary, i);
@@ -1915,7 +1915,7 @@ ole_val2olevariantdata(VALUE val, VARTYPE vt, struct olevariantdata *pvar)
{
HRESULT hr = S_OK;
- if (((vt & ~VT_BYREF) == (VT_ARRAY | VT_UI1)) && TYPE(val) == T_STRING) {
+ if (((vt & ~VT_BYREF) == (VT_ARRAY | VT_UI1)) && RB_TYPE_P(val, T_STRING)) {
long len = RSTRING_LEN(val);
void *pdest = NULL;
SAFEARRAY *p = NULL;
@@ -2859,9 +2859,9 @@ fole_s_const_load(int argc, VALUE *argv, VALUE self)
LCID lcid = cWIN32OLE_lcid;
rb_scan_args(argc, argv, "11", &ole, &klass);
- if (TYPE(klass) != T_CLASS &&
- TYPE(klass) != T_MODULE &&
- TYPE(klass) != T_NIL) {
+ if (!RB_TYPE_P(klass, T_CLASS) &&
+ !RB_TYPE_P(klass, T_MODULE) &&
+ !RB_TYPE_P(klass, T_NIL)) {
rb_raise(rb_eTypeError, "2nd parameter must be Class or Module");
}
if (rb_obj_is_kind_of(ole, cWIN32OLE)) {
@@ -2877,7 +2877,7 @@ fole_s_const_load(int argc, VALUE *argv, VALUE self)
ole_raise(hr, rb_eRuntimeError, "failed to GetContainingTypeLib");
}
OLE_RELEASE(pTypeInfo);
- if(TYPE(klass) != T_NIL) {
+ if(!RB_TYPE_P(klass, T_NIL)) {
ole_const_load(pTypeLib, klass, self);
}
else {
@@ -2885,7 +2885,7 @@ fole_s_const_load(int argc, VALUE *argv, VALUE self)
}
OLE_RELEASE(pTypeLib);
}
- else if(TYPE(ole) == T_STRING) {
+ else if(RB_TYPE_P(ole, T_STRING)) {
file = typelib_file(ole);
if (file == Qnil) {
file = ole;
@@ -2895,7 +2895,7 @@ fole_s_const_load(int argc, VALUE *argv, VALUE self)
SysFreeString(pBuf);
if (FAILED(hr))
ole_raise(hr, eWIN32OLERuntimeError, "failed to LoadTypeLibEx");
- if(TYPE(klass) != T_NIL) {
+ if(!RB_TYPE_P(klass, T_NIL)) {
ole_const_load(pTypeLib, klass, self);
}
else {
@@ -3043,7 +3043,7 @@ fole_s_show_help(int argc, VALUE *argv, VALUE self)
} else {
helpfile = target;
}
- if (TYPE(helpfile) != T_STRING) {
+ if (!RB_TYPE_P(helpfile, T_STRING)) {
rb_raise(rb_eTypeError, "1st parameter must be (String|WIN32OLE_TYPE|WIN32OLE_METHOD)");
}
hwnd = ole_show_help(helpfile, helpcontext);
@@ -3346,7 +3346,7 @@ hash2named_arg(RB_BLOCK_CALL_FUNC_ARGLIST(pair, op))
the data-type of key must be String or Symbol
-----------------------------------------------*/
key = rb_ary_entry(pair, 0);
- if(TYPE(key) != T_STRING && TYPE(key) != T_SYMBOL) {
+ if(!RB_TYPE_P(key, T_STRING) && !RB_TYPE_P(key, T_SYMBOL)) {
/* clear name of dispatch parameters */
for(i = 1; i < index + 1; i++) {
SysFreeString(pOp->pNamedArgs[i]);
@@ -3358,7 +3358,7 @@ hash2named_arg(RB_BLOCK_CALL_FUNC_ARGLIST(pair, op))
/* raise an exception */
rb_raise(rb_eTypeError, "wrong argument type (expected String or Symbol)");
}
- if (TYPE(key) == T_SYMBOL) {
+ if (RB_TYPE_P(key, T_SYMBOL)) {
key = rb_sym_to_s(key);
}
@@ -3424,10 +3424,10 @@ ole_invoke(int argc, VALUE *argv, VALUE self, USHORT wFlags, BOOL is_bracket)
op.dp.cArgs = 0;
rb_scan_args(argc, argv, "1*", &cmd, &paramS);
- if(TYPE(cmd) != T_STRING && TYPE(cmd) != T_SYMBOL && !is_bracket) {
+ if(!RB_TYPE_P(cmd, T_STRING) && !RB_TYPE_P(cmd, T_SYMBOL) && !is_bracket) {
rb_raise(rb_eTypeError, "method is wrong type (expected String or Symbol)");
}
- if (TYPE(cmd) == T_SYMBOL) {
+ if (RB_TYPE_P(cmd, T_SYMBOL)) {
cmd = rb_sym_to_s(cmd);
}
OLEData_Get_Struct(self, pole);
@@ -3456,7 +3456,7 @@ ole_invoke(int argc, VALUE *argv, VALUE self, USHORT wFlags, BOOL is_bracket)
op.dp.cNamedArgs = 0;
/* if last arg is hash object */
- if(TYPE(param) == T_HASH) {
+ if(RB_TYPE_P(param, T_HASH)) {
/*------------------------------------------
hash object ==> named dispatch parameters
--------------------------------------------*/
@@ -4591,10 +4591,10 @@ fole_respond_to(VALUE self, VALUE method)
BSTR wcmdname;
DISPID DispID;
HRESULT hr;
- if(TYPE(method) != T_STRING && TYPE(method) != T_SYMBOL) {
+ if(!RB_TYPE_P(method, T_STRING) && !RB_TYPE_P(method, T_SYMBOL)) {
rb_raise(rb_eTypeError, "wrong argument type (expected String or Symbol)");
}
- if (TYPE(method) == T_SYMBOL) {
+ if (RB_TYPE_P(method, T_SYMBOL)) {
method = rb_sym_to_s(method);
}
OLEData_Get_Struct(self, pole);
@@ -7750,8 +7750,8 @@ ole_search_event_at(VALUE ary, VALUE ev)
ret = i;
break;
}
- else if (TYPE(ev) == T_STRING &&
- TYPE(event_name) == T_STRING &&
+ else if (RB_TYPE_P(ev, T_STRING) &&
+ RB_TYPE_P(event_name, T_STRING) &&
rb_str_cmp(ev, event_name) == 0) {
ret = i;
break;
@@ -7926,7 +7926,7 @@ STDMETHODIMP EVENTSINK_Invoke(
}
ary = rb_ivar_get(obj, id_events);
- if (NIL_P(ary) || TYPE(ary) != T_ARRAY) {
+ if (NIL_P(ary) || !RB_TYPE_P(ary, T_ARRAY)) {
return NOERROR;
}
hr = pTypeInfo->lpVtbl->GetNames(pTypeInfo, dispid,
@@ -7936,7 +7936,7 @@ STDMETHODIMP EVENTSINK_Invoke(
}
ev = WC2VSTR(bstr);
event = ole_search_event(ary, ev, &is_default_handler);
- if (TYPE(event) == T_ARRAY) {
+ if (RB_TYPE_P(event, T_ARRAY)) {
handler = rb_ary_entry(event, 0);
mid = rb_intern("call");
is_outarg = rb_ary_entry(event, 3);
@@ -7981,10 +7981,10 @@ STDMETHODIMP EVENTSINK_Invoke(
if (state != 0) {
rescue_callback(Qnil);
}
- if(TYPE(result) == T_HASH) {
+ if(RB_TYPE_P(result, T_HASH)) {
hash2ptr_dispparams(result, pTypeInfo, dispid, pdispparams);
result = hash2result(result);
- }else if (is_outarg == Qtrue && TYPE(outargv) == T_ARRAY) {
+ }else if (is_outarg == Qtrue && RB_TYPE_P(outargv, T_ARRAY)) {
ary2ptr_dispparams(outargv, pdispparams);
}
@@ -8384,7 +8384,7 @@ ev_advise(int argc, VALUE *argv, VALUE self)
rb_raise(rb_eTypeError, "1st parameter must be WIN32OLE object");
}
- if(TYPE(itf) != T_NIL) {
+ if(!RB_TYPE_P(itf, T_NIL)) {
if (rb_safe_level() > 0 && OBJ_TAINTED(itf)) {
rb_raise(rb_eSecurityError, "Insecure Event Creation - %s",
StringValuePtr(itf));
@@ -8478,7 +8478,7 @@ static void
add_event_call_back(VALUE obj, VALUE event, VALUE data)
{
VALUE events = rb_ivar_get(obj, id_events);
- if (NIL_P(events) || TYPE(events) != T_ARRAY) {
+ if (NIL_P(events) || !RB_TYPE_P(events, T_ARRAY)) {
events = rb_ary_new();
rb_ivar_set(obj, id_events, events);
}
@@ -8497,10 +8497,10 @@ ev_on_event(int argc, VALUE *argv, VALUE self, VALUE is_ary_arg)
}
rb_scan_args(argc, argv, "01*", &event, &args);
if(!NIL_P(event)) {
- if(TYPE(event) != T_STRING && TYPE(event) != T_SYMBOL) {
+ if(!RB_TYPE_P(event, T_STRING) && !RB_TYPE_P(event, T_SYMBOL)) {
rb_raise(rb_eTypeError, "wrong argument type (expected String or Symbol)");
}
- if (TYPE(event) == T_SYMBOL) {
+ if (RB_TYPE_P(event, T_SYMBOL)) {
event = rb_sym_to_s(event);
}
}
@@ -8587,10 +8587,10 @@ fev_off_event(int argc, VALUE *argv, VALUE self)
rb_scan_args(argc, argv, "01", &event);
if(!NIL_P(event)) {
- if(TYPE(event) != T_STRING && TYPE(event) != T_SYMBOL) {
+ if(!RB_TYPE_P(event, T_STRING) && !RB_TYPE_P(event, T_SYMBOL)) {
rb_raise(rb_eTypeError, "wrong argument type (expected String or Symbol)");
}
- if (TYPE(event) == T_SYMBOL) {
+ if (RB_TYPE_P(event, T_SYMBOL)) {
event = rb_sym_to_s(event);
}
}
@@ -9152,7 +9152,7 @@ folevariant_set_value(VALUE self, VALUE val)
VARTYPE vt;
Data_Get_Struct(self, struct olevariantdata, pvar);
vt = V_VT(&(pvar->var));
- if (V_ISARRAY(&(pvar->var)) && ((vt & ~VT_BYREF) != (VT_UI1|VT_ARRAY) || TYPE(val) != T_STRING)) {
+ if (V_ISARRAY(&(pvar->var)) && ((vt & ~VT_BYREF) != (VT_UI1|VT_ARRAY) || !RB_TYPE_P(val, T_STRING))) {
rb_raise(eWIN32OLERuntimeError,
"`value=' is not available for this variant type object");
}
@@ -9348,10 +9348,10 @@ folerecord_initialize(VALUE self, VALUE typename, VALUE oleobj) {
ITypeLib *pTypeLib = NULL;
IRecordInfo *pri = NULL;
- if (TYPE(typename) != T_STRING && TYPE(typename) != T_SYMBOL) {
+ if (!RB_TYPE_P(typename, T_STRING) && !RB_TYPE_P(typename, T_SYMBOL)) {
rb_raise(rb_eArgError, "1st argument should be String or Symbol");
}
- if (TYPE(typename) == T_SYMBOL) {
+ if (RB_TYPE_P(typename, T_SYMBOL)) {
typename = rb_sym_to_s(typename);
}
@@ -9559,11 +9559,11 @@ static VALUE
folerecord_ole_instance_variable_get(VALUE self, VALUE name)
{
VALUE sname;
- if(TYPE(name) != T_STRING && TYPE(name) != T_SYMBOL) {
+ if(!RB_TYPE_P(name, T_STRING) && !RB_TYPE_P(name, T_SYMBOL)) {
rb_raise(rb_eTypeError, "wrong argument type (expected String or Symbol)");
}
sname = name;
- if (TYPE(name) == T_SYMBOL) {
+ if (RB_TYPE_P(name, T_SYMBOL)) {
sname = rb_sym_to_s(name);
}
return olerecord_ivar_get(self, sname);
@@ -9598,11 +9598,11 @@ static VALUE
folerecord_ole_instance_variable_set(VALUE self, VALUE name, VALUE val)
{
VALUE sname;
- if(TYPE(name) != T_STRING && TYPE(name) != T_SYMBOL) {
+ if(!RB_TYPE_P(name, T_STRING) && !RB_TYPE_P(name, T_SYMBOL)) {
rb_raise(rb_eTypeError, "wrong argument type (expected String or Symbol)");
}
sname = name;
- if (TYPE(name) == T_SYMBOL) {
+ if (RB_TYPE_P(name, T_SYMBOL)) {
sname = rb_sym_to_s(name);
}
return olerecord_ivar_set(self, sname, val);