aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-05-18 01:17:43 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-05-18 01:17:43 +0000
commit7ec4533c93adc4838ce53f5119c2702b10c9043f (patch)
treeadf65284cfe148dee36c8d8def3739543dcdf37a /include
parent3736ef5b0f89887a0b47edf5b23c33698c5f1645 (diff)
downloadruby-7ec4533c93adc4838ce53f5119c2702b10c9043f.tar.gz
ruby.h: RB_INTEGER_TYPE_P
* include/ruby/ruby.h (RB_INTEGER_TYPE_P): new macro and underlying inline function to check if the object is an Integer (Fixnum or Bignum). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55044 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'include')
-rw-r--r--include/ruby/ruby.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/include/ruby/ruby.h b/include/ruby/ruby.h
index 6f7ce0f217..e09d4a739b 100644
--- a/include/ruby/ruby.h
+++ b/include/ruby/ruby.h
@@ -1504,6 +1504,15 @@ rb_obj_write(VALUE a, VALUE *slot, VALUE b, RB_UNUSED_VAR(const char *filename),
return a;
}
+#define RB_INTEGER_TYPE_P(obj) rb_integer_type_p(obj)
+static inline int
+rb_integer_type_p(VALUE obj)
+{
+ return (RB_FIXNUM_P(obj) ||
+ (!RB_SPECIAL_CONST_P(obj) &&
+ RB_BUILTIN_TYPE(obj) == RUBY_T_BIGNUM));
+}
+
#if SIZEOF_INT < SIZEOF_LONG
# define RB_INT2NUM(v) INT2FIX((int)(v))
# define RB_UINT2NUM(v) LONG2FIX((unsigned int)(v))