diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-05-18 01:17:43 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-05-18 01:17:43 +0000 |
commit | 4a9705d6e3384342a3ee649bfdbd93062140b5fd (patch) | |
tree | adf65284cfe148dee36c8d8def3739543dcdf37a /include | |
parent | abe32a00b1096c0be8196385cccb983ca2b5e497 (diff) | |
download | ruby-4a9705d6e3384342a3ee649bfdbd93062140b5fd.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.h | 9 |
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)) |