From 7ec4533c93adc4838ce53f5119c2702b10c9043f Mon Sep 17 00:00:00 2001 From: nobu Date: Wed, 18 May 2016 01:17:43 +0000 Subject: 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 --- include/ruby/ruby.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'include') 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)) -- cgit v1.2.3