diff --git a/binding-mri/binding-mri.cpp b/binding-mri/binding-mri.cpp index c7f3229..af2fe6b 100644 --- a/binding-mri/binding-mri.cpp +++ b/binding-mri/binding-mri.cpp @@ -236,7 +236,7 @@ RB_METHOD(_kernelCaller) VALUE trace = rb_funcall2(rb_mKernel, rb_intern("_mkxp_kernel_caller_alias"), 0, 0); - if (rb_type(trace) != RUBY_T_ARRAY) + if (!RB_TYPE_P(trace, RUBY_T_ARRAY)) return trace; long len = RARRAY_LEN(trace); @@ -320,7 +320,7 @@ static void runRMXPScripts() VALUE scriptArray = kernelLoadDataInt(scriptPack.c_str()); - if (rb_type(scriptArray) != RUBY_T_ARRAY) + if (!RB_TYPE_P(scriptArray, RUBY_T_ARRAY)) { showMsg("Failed to read script data"); return; @@ -337,7 +337,7 @@ static void runRMXPScripts() { VALUE script = rb_ary_entry(scriptArray, i); - if (rb_type(script) != RUBY_T_ARRAY) + if (!RB_TYPE_P(script, RUBY_T_ARRAY)) continue; VALUE scriptName = rb_ary_entry(script, 1); diff --git a/binding-mri/binding-util.cpp b/binding-mri/binding-util.cpp index d70a039..6312406 100644 --- a/binding-mri/binding-util.cpp +++ b/binding-mri/binding-util.cpp @@ -148,7 +148,7 @@ rb_get_args(int argc, VALUE *argv, const char *format, ...) VALUE *str = va_arg(ap, VALUE*); VALUE tmp = *arg; - if (!(rb_type(tmp) == RUBY_T_STRING)) + if (!RB_TYPE_P(tmp, RUBY_T_STRING)) rb_raise(rb_eTypeError, "Argument %d: Expected string", argI); *str = tmp; @@ -167,7 +167,7 @@ rb_get_args(int argc, VALUE *argv, const char *format, ...) VALUE tmp = *arg; - if (!(rb_type(tmp) == RUBY_T_STRING)) + if (!RB_TYPE_P(tmp, RUBY_T_STRING)) rb_raise(rb_eTypeError, "Argument %d: Expected string", argI); *s = RSTRING_PTR(tmp); @@ -186,7 +186,7 @@ rb_get_args(int argc, VALUE *argv, const char *format, ...) VALUE tmp = *arg++; - if (!(rb_type(tmp) == RUBY_T_STRING)) + if (!RB_TYPE_P(tmp, RUBY_T_STRING)) rb_raise(rb_eTypeError, "Argument %d: Expected string", argI); *s = RSTRING_PTR(tmp); diff --git a/binding-mri/bitmap-binding.cpp b/binding-mri/bitmap-binding.cpp index e7ef5d4..1461e74 100644 --- a/binding-mri/bitmap-binding.cpp +++ b/binding-mri/bitmap-binding.cpp @@ -258,7 +258,7 @@ RB_METHOD(bitmapDrawText) VALUE strObj; rb_get_args(argc, argv, "oo|i", &rectObj, &strObj, &align RB_ARG_END); - if (rb_type(strObj) != RUBY_T_STRING) + if (!RB_TYPE_P(strObj, RUBY_T_STRING)) strObj = rb_funcallv(strObj, rb_intern("to_s"), 0, 0); str = RSTRING_PTR(strObj); @@ -281,7 +281,7 @@ RB_METHOD(bitmapDrawText) VALUE strObj; rb_get_args(argc, argv, "iiiio|i", &x, &y, &width, &height, &strObj, &align RB_ARG_END); - if (rb_type(strObj) != RUBY_T_STRING) + if (!RB_TYPE_P(strObj, RUBY_T_STRING)) strObj = rb_funcallv(strObj, rb_intern("to_s"), 0, 0); str = RSTRING_PTR(strObj); @@ -308,7 +308,7 @@ RB_METHOD(bitmapTextSize) VALUE strObj; rb_get_args(argc, argv, "o", &strObj RB_ARG_END); - if (rb_type(strObj) != RUBY_T_STRING) + if (!RB_TYPE_P(strObj, RUBY_T_STRING)) strObj = rb_funcallv(strObj, rb_intern("to_s"), 0, 0); str = RSTRING_PTR(strObj); diff --git a/binding-mri/filesystem-binding.cpp b/binding-mri/filesystem-binding.cpp index 42bcec3..8ff531e 100644 --- a/binding-mri/filesystem-binding.cpp +++ b/binding-mri/filesystem-binding.cpp @@ -159,7 +159,7 @@ RB_METHOD(kernelSaveData) static VALUE stringForceUTF8(VALUE arg) { - if (rb_type(arg) == RUBY_T_STRING && ENCODING_IS_ASCII8BIT(arg)) + if (RB_TYPE_P(arg, RUBY_T_STRING) && ENCODING_IS_ASCII8BIT(arg)) rb_enc_associate_index(arg, rb_utf8_encindex()); return arg; diff --git a/binding-mri/font-binding.cpp b/binding-mri/font-binding.cpp index c33e138..8849197 100644 --- a/binding-mri/font-binding.cpp +++ b/binding-mri/font-binding.cpp @@ -38,7 +38,7 @@ RB_METHOD(fontDoesExist) rb_get_args(argc, argv, "o", &nameObj RB_ARG_END); - if (rb_type(nameObj) == RUBY_T_STRING) + if (RB_TYPE_P(nameObj, RUBY_T_STRING)) name = rb_string_value_cstr(&nameObj); return rb_bool_new(Font::doesExist(name)); @@ -116,24 +116,23 @@ fontSetNameHelper(VALUE self, int argc, VALUE *argv, rb_check_argc(argc, 1); VALUE arg = argv[0]; - int type = rb_type(arg); // Fixme: in RGSS3, specifying "" (and only that) as font name results in // no text being drawn (everything else is substituted with Arial I think) strncpy(outBuf, "", outLen); - if (type == RUBY_T_STRING) + if (RB_TYPE_P(arg, RUBY_T_STRING)) { strncpy(outBuf, RSTRING_PTR(arg), outLen); } - else if (type == RUBY_T_ARRAY) + else if (RB_TYPE_P(arg, RUBY_T_ARRAY)) { for (long i = 0; i < RARRAY_LEN(arg); ++i) { VALUE str = rb_ary_entry(arg, i); /* Non-string objects are tolerated (ignored) */ - if (rb_type(str) != RUBY_T_STRING) + if (!RB_TYPE_P(str, RUBY_T_STRING)) continue; const char *family = RSTRING_PTR(str);