12#include "ruby/internal/config.h"
23#include "internal/array.h"
24#include "internal/compar.h"
25#include "internal/enum.h"
26#include "internal/enumerator.h"
27#include "internal/error.h"
28#include "internal/numeric.h"
29#include "internal/range.h"
32static ID id_beg, id_end, id_excl;
40#define RANGE_SET_BEG(r, v) (RSTRUCT_SET(r, 0, v))
41#define RANGE_SET_END(r, v) (RSTRUCT_SET(r, 1, v))
42#define RANGE_SET_EXCL(r, v) (RSTRUCT_SET(r, 2, v))
44#define EXCL(r) RTEST(RANGE_EXCL(r))
57 RANGE_SET_EXCL(range, exclude_end);
58 RANGE_SET_BEG(range, beg);
59 RANGE_SET_END(range, end);
71 range_init(range, beg, end, RBOOL(exclude_end));
76range_modify(
VALUE range)
80 if (RANGE_EXCL(range) !=
Qnil) {
81 rb_name_err_raise(
"`initialize' called twice", range,
ID2SYM(idInitialize));
101range_initialize(
int argc,
VALUE *argv,
VALUE range)
103 VALUE beg, end, flags;
107 range_init(range, beg, end, RBOOL(
RTEST(flags)));
116 rb_struct_init_copy(range, orig);
133range_exclude_end_p(
VALUE range)
135 return RBOOL(EXCL(range));
139recursive_equal(
VALUE range,
VALUE obj,
int recur)
141 if (recur)
return Qtrue;
142 if (!
rb_equal(RANGE_BEG(range), RANGE_BEG(obj)))
144 if (!
rb_equal(RANGE_END(range), RANGE_END(obj)))
147 return RBOOL(EXCL(range) == EXCL(obj));
205 return rb_cmpint(r, a, b);
209recursive_eql(
VALUE range,
VALUE obj,
int recur)
211 if (recur)
return Qtrue;
212 if (!
rb_eql(RANGE_BEG(range), RANGE_BEG(obj)))
214 if (!
rb_eql(RANGE_END(range), RANGE_END(obj)))
217 return RBOOL(EXCL(range) == EXCL(obj));
272range_hash(
VALUE range)
274 st_index_t hash = EXCL(range);
278 v = rb_hash(RANGE_BEG(range));
280 v = rb_hash(RANGE_END(range));
292 VALUE b = RANGE_BEG(range);
293 VALUE e = RANGE_END(range);
297 while (r_less(v, e) < 0) {
298 if ((*func)(v, arg))
break;
299 v = rb_funcallv(v, id_succ, 0, 0);
303 while ((c = r_less(v, e)) <= 0) {
304 if ((*func)(v, arg))
break;
306 v = rb_funcallv(v, id_succ, 0, 0);
312step_i_iter(
VALUE arg)
317 iter[0] -=
INT2FIX(1) & ~FIXNUM_FLAG;
322 if (iter[0] !=
INT2FIX(0))
return false;
330 if (step_i_iter(arg)) {
339 if (step_i_iter(arg)) {
346discrete_object_p(
VALUE obj)
352linear_object_p(
VALUE obj)
369check_step_domain(
VALUE step)
376 cmp = rb_cmpint(rb_funcallv(step, idCmp, 1, &zero), step, zero);
389 VALUE b = RANGE_BEG(range), e = RANGE_END(range);
396 return ruby_num_interval_step_size(b, e, step, EXCL(range));
441 VALUE b, e, step, tmp;
443 b = RANGE_BEG(range);
444 e = RANGE_END(range);
457 if ((b_num_p && (
NIL_P(e) || e_num_p)) || (
NIL_P(b) && e_num_p)) {
458 return rb_arith_seq_new(range,
ID2SYM(rb_frame_this_func()), argc, argv,
459 range_step_size, b, e, step, EXCL(range));
465 step = check_step_domain(step);
476 for (;; b = rb_big_plus(b, step))
488 if (i + unit < i)
break;
496 rb_str_upto_endless_each(b, sym_step_i, (
VALUE)iter);
499 rb_str_upto_each(b,
rb_sym2str(e), EXCL(range), sym_step_i, (
VALUE)iter);
502 else if (ruby_float_step(b, e, step, EXCL(range), TRUE)) {
508 ID op = EXCL(range) ?
'<' : idLE;
524 rb_str_upto_endless_each(b, step_i, (
VALUE)iter);
527 rb_str_upto_each(b, e, EXCL(range), step_i, (
VALUE)iter);
531 if (!discrete_object_p(b)) {
535 range_each_func(range, step_i, (
VALUE)iter);
571 return range_step(1, &step, range);
574#if SIZEOF_DOUBLE == 8 && defined(HAVE_INT64_T)
581int64_as_double_to_num(int64_t i)
583 union int64_double convert;
595double_as_int64(
double d)
597 union int64_double convert;
599 return d < 0 ? -convert.i : convert.i;
610 return RTEST(is_int) && !UNDEF_P(is_int);
614bsearch_integer_range(
VALUE beg,
VALUE end,
int excl)
619#define BSEARCH_CHECK(expr) \
621 VALUE val = (expr); \
622 VALUE v = rb_yield(val); \
624 if (v == INT2FIX(0)) return val; \
625 smaller = (SIGNED_VALUE)v < 0; \
627 else if (v == Qtrue) { \
631 else if (!RTEST(v)) { \
634 else if (rb_obj_is_kind_of(v, rb_cNumeric)) { \
635 int cmp = rb_cmpint(rb_funcall(v, id_cmp, 1, INT2FIX(0)), v, INT2FIX(0)); \
636 if (!cmp) return val; \
640 rb_raise(rb_eTypeError, "wrong argument type %"PRIsVALUE \
641 " (must be numeric, true, false or nil)", \
655 while (rb_cmpint(
rb_funcall(low, id_cmp, 1, high), low, high) < 0) {
667 if (!smaller)
return Qnil;
683range_bsearch(
VALUE range)
702#define BSEARCH(conv) \
704 RETURN_ENUMERATOR(range, 0, 0); \
705 if (EXCL(range)) high--; \
707 while (low < high) { \
708 mid = ((high < 0) == (low < 0)) ? low + ((high - low) / 2) \
709 : (low < -high) ? -((-1 - low - high)/2 + 1) : (low + high) / 2; \
710 BSEARCH_CHECK(conv(mid)); \
718 if (low == org_high) { \
719 BSEARCH_CHECK(conv(low)); \
720 if (!smaller) return Qnil; \
726 beg = RANGE_BEG(range);
727 end = RANGE_END(range);
735#if SIZEOF_DOUBLE == 8 && defined(HAVE_INT64_T)
739 int64_t mid, org_high;
740 BSEARCH(int64_as_double_to_num);
743 else if (is_integer_p(beg) && is_integer_p(end)) {
745 return bsearch_integer_range(beg, end, EXCL(range));
747 else if (is_integer_p(beg) &&
NIL_P(end)) {
754 return bsearch_integer_range(beg, mid, 0);
759 else if (
NIL_P(beg) && is_integer_p(end)) {
766 return bsearch_integer_range(mid, end, 0);
807range_size(
VALUE range)
809 VALUE b = RANGE_BEG(range), e = RANGE_END(range);
812 return ruby_num_interval_step_size(b, e,
INT2FIX(1), EXCL(range));
842range_to_a(
VALUE range)
844 if (
NIL_P(RANGE_END(range))) {
853 return range_size(range);
858range_each_bignum_endless(
VALUE beg)
860 for (;; beg = rb_big_plus(beg,
INT2FIX(1))) {
868range_each_fixnum_endless(
VALUE beg)
881 long lim =
FIX2LONG(end) + !EXCL(range);
882 for (
long i =
FIX2LONG(beg); i < lim; i++) {
906range_each(
VALUE range)
913 beg = RANGE_BEG(range);
914 end = RANGE_END(range);
917 range_each_fixnum_endless(beg);
920 return range_each_fixnum_loop(beg, end, range);
929 if (
NIL_P(end)) range_each_fixnum_endless(beg);
930 if (
FIXNUM_P(end))
return range_each_fixnum_loop(beg, end, range);
933 if (
NIL_P(end)) range_each_bignum_endless(beg);
949 while (rb_big_cmp(beg, end) ==
INT2FIX(-1)) {
951 beg = rb_big_plus(beg,
INT2FIX(1));
956 while ((c = rb_big_cmp(beg, end)) !=
INT2FIX(1)) {
959 beg = rb_big_plus(beg,
INT2FIX(1));
967 rb_str_upto_endless_each(beg, sym_each_i, 0);
970 rb_str_upto_each(beg,
rb_sym2str(end), EXCL(range), sym_each_i, 0);
978 rb_str_upto_each(tmp, end, EXCL(range), each_i, 0);
981 rb_str_upto_endless_each(tmp, each_i, 0);
985 if (!discrete_object_p(beg)) {
990 range_each_func(range, each_i, 0);
992 for (;; beg = rb_funcallv(beg, id_succ, 0, 0))
1012range_begin(
VALUE range)
1014 return RANGE_BEG(range);
1033range_end(
VALUE range)
1035 return RANGE_END(range);
1048 rb_ary_push(ary[1], i);
1077range_first(
int argc,
VALUE *argv,
VALUE range)
1081 if (
NIL_P(RANGE_BEG(range))) {
1084 if (argc == 0)
return RANGE_BEG(range);
1095rb_int_range_last(
int argc,
VALUE *argv,
VALUE range)
1099 VALUE b, e, len_1, len, nv, ary;
1105 b = RANGE_BEG(range);
1106 e = RANGE_END(range);
1111 len_1 = rb_int_minus(e, b);
1113 e = rb_int_minus(e, ONE);
1117 len = rb_int_plus(len_1, ONE);
1120 if (FIXNUM_ZERO_P(len) || rb_num_negative_p(len)) {
1121 return rb_ary_new_capa(0);
1131 if (
RTEST(rb_int_gt(nv, len))) {
1136 ary = rb_ary_new_capa(n);
1137 b = rb_int_minus(e, nv);
1139 b = rb_int_plus(b, ONE);
1140 rb_ary_push(ary, b);
1183range_last(
int argc,
VALUE *argv,
VALUE range)
1187 if (
NIL_P(RANGE_END(range))) {
1190 if (argc == 0)
return RANGE_END(range);
1192 b = RANGE_BEG(range);
1193 e = RANGE_END(range);
1195 RB_LIKELY(rb_method_basic_definition_p(
rb_cRange, idEach))) {
1196 return rb_int_range_last(argc, argv, range);
1198 return rb_ary_last(argc, argv,
rb_Array(range));
1286 if (
NIL_P(RANGE_BEG(range))) {
1291 if (
NIL_P(RANGE_END(range))) {
1296 else if (argc != 0) {
1297 return range_first(argc, argv, range);
1300 VALUE b = RANGE_BEG(range);
1301 VALUE e = RANGE_END(range);
1302 int c =
NIL_P(e) ? -1 : OPTIMIZED_CMP(b, e);
1304 if (c > 0 || (c == 0 && EXCL(range)))
1394 VALUE e = RANGE_END(range);
1397 if (
NIL_P(RANGE_END(range))) {
1401 VALUE b = RANGE_BEG(range);
1410 int c =
NIL_P(b) ? -1 : OPTIMIZED_CMP(b, e);
1418 if (c == 0)
return Qnil;
1478range_minmax(
VALUE range)
1483 return rb_assoc_new(
1496 b = RANGE_BEG(range);
1497 e = RANGE_END(range);
1506 if (UNDEF_P(b))
return (
int)
Qfalse;
1508 if (UNDEF_P(e))
return (
int)
Qfalse;
1510 if (UNDEF_P(x))
return (
int)
Qfalse;
1542rb_range_component_beg_len(
VALUE b,
VALUE e,
int excl,
1543 long *begp,
long *lenp,
long len,
int err)
1549 if (
NIL_P(e)) excl = 0;
1559 if (err == 0 || err == 2) {
1586 VALUE res = rb_range_component_beg_len(b, e, excl, begp, lenp, len, err);
1587 if (
NIL_P(res) && err) {
1616range_to_s(
VALUE range)
1630inspect_range(
VALUE range,
VALUE dummy,
int recur)
1635 return rb_str_new2(EXCL(range) ?
"(... ... ...)" :
"(... .. ...)");
1637 if (!
NIL_P(RANGE_BEG(range)) ||
NIL_P(RANGE_END(range))) {
1644 if (
NIL_P(RANGE_BEG(range)) || !
NIL_P(RANGE_END(range))) {
1675range_inspect(
VALUE range)
1726 VALUE ret = range_string_cover_internal(range, val);
1727 if (!UNDEF_P(ret))
return ret;
1728 return r_cover_p(range, RANGE_BEG(range), RANGE_END(range), val);
1766 VALUE ret = range_include_internal(range, val);
1767 if (!UNDEF_P(ret))
return ret;
1794 if (linear_object_p(val))
return Qtrue;
1805range_string_cover_internal(
VALUE range,
VALUE val)
1807 VALUE beg = RANGE_BEG(range);
1808 VALUE end = RANGE_END(range);
1810 linear_object_p(beg) || linear_object_p(end);
1812 if (nv || range_integer_edge_p(beg, end)) {
1813 return r_cover_p(range, beg, end, val);
1815 else if (range_string_edge_p(beg, end)) {
1816 if (range_string_range_p(beg, end)) {
1817 return r_cover_p(range, beg, end, val);
1823 if (RANGE_EXCL(range)) {
1824 return RBOOL(rb_cmpint(r, val, end) < 0);
1826 return RBOOL(rb_cmpint(r, val, end) <= 0);
1828 else if (
NIL_P(end)) {
1832 return RBOOL(rb_cmpint(r, beg, val) <= 0);
1840 goto unbounded_begin;
1843 return range_include_fallback(beg, end, val);
1847range_include_internal(
VALUE range,
VALUE val)
1849 VALUE beg = RANGE_BEG(range);
1850 VALUE end = RANGE_END(range);
1852 linear_object_p(beg) || linear_object_p(end);
1854 if (nv || range_integer_edge_p(beg, end)) {
1855 return r_cover_p(range, beg, end, val);
1857 else if (range_string_range_p(beg, end)) {
1858 return rb_str_include_range_p(beg, end, val, RANGE_EXCL(range));
1861 return range_include_fallback(beg, end, val);
1998 beg = RANGE_BEG(range);
1999 end = RANGE_END(range);
2002 return RBOOL(r_cover_range_p(range, beg, end, val));
2004 return r_cover_p(range, beg, end, val);
2010 return rb_funcallv(r,
rb_intern(
"max"), 0, 0);
2016 VALUE val_beg, val_end, val_max;
2019 val_beg = RANGE_BEG(val);
2020 val_end = RANGE_END(val);
2022 if (!
NIL_P(end) &&
NIL_P(val_end))
return FALSE;
2023 if (!
NIL_P(beg) &&
NIL_P(val_beg))
return FALSE;
2024 if (!
NIL_P(val_beg) && !
NIL_P(val_end) && r_less(val_beg, val_end) > (EXCL(val) ? -1 : 0)) return FALSE;
2025 if (!
NIL_P(val_beg) && !r_cover_p(range, beg, end, val_beg))
return FALSE;
2030 if (
NIL_P(r_cmp_end))
return FALSE;
2031 cmp_end = rb_cmpint(r_cmp_end, end, val_end);
2034 cmp_end = r_less(end, val_end);
2038 if (EXCL(range) == EXCL(val)) {
2039 return cmp_end >= 0;
2041 else if (EXCL(range)) {
2044 else if (cmp_end >= 0) {
2049 if (
NIL_P(val_max))
return FALSE;
2051 return r_less(end, val_max) >= 0;
2057 if (
NIL_P(beg) || r_less(beg, val) <= 0) {
2058 int excl = EXCL(range);
2059 if (
NIL_P(end) || r_less(val, end) <= -excl)
2066range_dumper(
VALUE range)
2079 VALUE beg, end, excl;
2085 range_modify(range);
2090 range_init(range, beg, end, RBOOL(
RTEST(excl)));
2096range_alloc(
VALUE klass)
2135range_count(
int argc,
VALUE *argv,
VALUE range)
2147 else if (
NIL_P(RANGE_END(range))) {
2151 else if (
NIL_P(RANGE_BEG(range))) {
2392 "Range", rb_cObject, range_alloc,
2393 "begin",
"end",
"excl", NULL);
#define rb_define_method(klass, mid, func, arity)
Defines klass#mid.
void rb_include_module(VALUE klass, VALUE module)
Includes a module to a class.
int rb_scan_args(int argc, const VALUE *argv, const char *fmt,...)
Retrieves argument from argc and argv to given VALUE references according to the format string.
int rb_block_given_p(void)
Determines if the current method is given a block.
#define rb_str_new2
Old name of rb_str_new_cstr.
#define RB_INTEGER_TYPE_P
Old name of rb_integer_type_p.
#define RFLOAT_VALUE
Old name of rb_float_value.
#define T_STRING
Old name of RUBY_T_STRING.
#define Qundef
Old name of RUBY_Qundef.
#define INT2FIX
Old name of RB_INT2FIX.
#define UNREACHABLE
Old name of RBIMPL_UNREACHABLE.
#define T_FLOAT
Old name of RUBY_T_FLOAT.
#define ID2SYM
Old name of RB_ID2SYM.
#define T_BIGNUM
Old name of RUBY_T_BIGNUM.
#define SPECIAL_CONST_P
Old name of RB_SPECIAL_CONST_P.
#define CLASS_OF
Old name of rb_class_of.
#define FIXABLE
Old name of RB_FIXABLE.
#define LONG2FIX
Old name of RB_INT2FIX.
#define ASSUME
Old name of RBIMPL_ASSUME.
#define LONG2NUM
Old name of RB_LONG2NUM.
#define FLONUM_P
Old name of RB_FLONUM_P.
#define Qtrue
Old name of RUBY_Qtrue.
#define ST2FIX
Old name of RB_ST2FIX.
#define INT2NUM
Old name of RB_INT2NUM.
#define Qnil
Old name of RUBY_Qnil.
#define Qfalse
Old name of RUBY_Qfalse.
#define FIX2LONG
Old name of RB_FIX2LONG.
#define T_OBJECT
Old name of RUBY_T_OBJECT.
#define NIL_P
Old name of RB_NIL_P.
#define POSFIXABLE
Old name of RB_POSFIXABLE.
#define DBL2NUM
Old name of rb_float_new.
#define BUILTIN_TYPE
Old name of RB_BUILTIN_TYPE.
#define NUM2LONG
Old name of RB_NUM2LONG.
#define FIXNUM_P
Old name of RB_FIXNUM_P.
#define CONST_ID
Old name of RUBY_CONST_ID.
#define rb_ary_new2
Old name of rb_ary_new_capa.
#define SYMBOL_P
Old name of RB_SYMBOL_P.
void rb_raise(VALUE exc, const char *fmt,...)
Exception entry point.
void rb_iter_break(void)
Breaks from a block.
VALUE rb_eRangeError
RangeError exception.
VALUE rb_eTypeError
TypeError exception.
VALUE rb_eArgError
ArgumentError exception.
VALUE rb_cTime
Time class.
VALUE rb_Float(VALUE val)
This is the logic behind Kernel#Float.
VALUE rb_obj_alloc(VALUE klass)
Allocates an instance of the given class.
VALUE rb_mEnumerable
Enumerable module.
int rb_eql(VALUE lhs, VALUE rhs)
Checks for equality of the passed objects, in terms of Object#eql?.
VALUE rb_cNumeric
Numeric class.
VALUE rb_Array(VALUE val)
This is the logic behind Kernel#Array.
VALUE rb_inspect(VALUE obj)
Generates a human-readable textual representation of the given object.
VALUE rb_cRange
Range class.
VALUE rb_equal(VALUE lhs, VALUE rhs)
This function is an optimised version of calling #==.
VALUE rb_obj_is_kind_of(VALUE obj, VALUE klass)
Queries if the given object is an instance (of possibly descendants) of the given class.
VALUE rb_obj_freeze(VALUE obj)
Just calls rb_obj_freeze_inline() inside.
VALUE rb_check_to_integer(VALUE val, const char *mid)
Identical to rb_check_convert_type(), except the return value type is fixed to rb_cInteger.
VALUE rb_to_int(VALUE val)
Identical to rb_check_to_int(), except it raises in case of conversion mismatch.
#define RUBY_FIXNUM_MAX
Maximum possible value that a fixnum can represent.
VALUE rb_funcall(VALUE recv, ID mid, int n,...)
Calls a method.
VALUE rb_call_super(int argc, const VALUE *argv)
This resembles ruby's super.
#define RETURN_SIZED_ENUMERATOR(obj, argc, argv, size_fn)
This roughly resembles return enum_for(__callee__) unless block_given?.
#define RETURN_ENUMERATOR(obj, argc, argv)
Identical to RETURN_SIZED_ENUMERATOR(), except its size is unknown.
#define rb_check_frozen
Just another name of rb_check_frozen.
static int rb_check_arity(int argc, int min, int max)
Ensures that the passed integer is in the passed range.
int rb_range_values(VALUE range, VALUE *begp, VALUE *endp, int *exclp)
Deconstructs a range into its components.
VALUE rb_range_new(VALUE beg, VALUE end, int excl)
Creates a new Range.
VALUE rb_range_beg_len(VALUE range, long *begp, long *lenp, long len, int err)
Deconstructs a numerical range.
#define rb_hash_uint(h, i)
Just another name of st_hash_uint.
#define rb_hash_end(h)
Just another name of st_hash_end.
VALUE rb_str_append(VALUE dst, VALUE src)
Identical to rb_str_buf_append(), except it converts the right hand side before concatenating.
#define rb_str_new(str, len)
Allocates an instance of rb_cString.
VALUE rb_str_dup(VALUE str)
Duplicates a string.
VALUE rb_str_cat(VALUE dst, const char *src, long srclen)
Destructively appends the passed contents to the string.
st_index_t rb_hash_start(st_index_t i)
Starts a series of hashing.
VALUE rb_check_string_type(VALUE obj)
Try converting an object to its stringised representation using its to_str method,...
VALUE rb_str_intern(VALUE str)
Identical to rb_to_symbol(), except it assumes the receiver being an instance of RString.
VALUE rb_obj_as_string(VALUE obj)
Try converting an object to its stringised representation using its to_s method, if any.
VALUE rb_struct_define_without_accessor(const char *name, VALUE super, rb_alloc_func_t func,...)
Identical to rb_struct_define(), except it does not define accessor methods.
VALUE rb_struct_alloc_noinit(VALUE klass)
Allocates an instance of the given class.
VALUE rb_exec_recursive(VALUE(*f)(VALUE g, VALUE h, int r), VALUE g, VALUE h)
"Recursion" API entry point.
VALUE rb_exec_recursive_paired(VALUE(*f)(VALUE g, VALUE h, int r), VALUE g, VALUE p, VALUE h)
Identical to rb_exec_recursive(), except it checks for the recursion on the ordered pair of { g,...
VALUE rb_ivar_set(VALUE obj, ID name, VALUE val)
Identical to rb_iv_set(), except it accepts the name as an ID instead of a C string.
VALUE rb_ivar_get(VALUE obj, ID name)
Identical to rb_iv_get(), except it accepts the name as an ID instead of a C string.
int rb_respond_to(VALUE obj, ID mid)
Queries if the object responds to the method.
VALUE rb_check_funcall(VALUE recv, ID mid, int argc, const VALUE *argv)
Identical to rb_funcallv(), except it returns RUBY_Qundef instead of raising rb_eNoMethodError.
static ID rb_intern_const(const char *str)
This is a "tiny optimisation" over rb_intern().
ID rb_intern(const char *name)
Finds or creates a symbol of the given name.
VALUE rb_sym2str(VALUE id)
Identical to rb_id2str(), except it takes an instance of rb_cSymbol rather than an ID.
#define RB_BLOCK_CALL_FUNC_ARGLIST(yielded_arg, callback_arg)
Shim for block function parameters.
VALUE rb_yield(VALUE val)
Yields the block.
void rb_marshal_define_compat(VALUE newclass, VALUE oldclass, VALUE(*dumper)(VALUE), VALUE(*loader)(VALUE, VALUE))
Marshal format compatibility layer.
VALUE rb_block_call(VALUE q, ID w, int e, const VALUE *r, type *t, VALUE y)
Call a method with a block.
VALUE rb_rescue2(type *q, VALUE w, type *e, VALUE r,...)
An equivalent of rescue clause.
#define RBIMPL_ATTR_NORETURN()
Wraps (or simulates) [[noreturn]]
#define RARRAY_AREF(a, i)
#define RBASIC(obj)
Convenient casting macro.
#define RBIGNUM_SIGN
Just another name of rb_big_sign.
static bool RBIGNUM_NEGATIVE_P(VALUE b)
Checks if the bignum is negative.
static bool RBIGNUM_POSITIVE_P(VALUE b)
Checks if the bignum is positive.
const char * rb_obj_classname(VALUE obj)
Queries the name of the class of the passed object.
#define RTEST
This is an old name of RB_TEST.
uintptr_t ID
Type that represents a Ruby identifier such as a variable name.
uintptr_t VALUE
Type that represents a Ruby object.
static bool RB_FLOAT_TYPE_P(VALUE obj)
Queries if the object is an instance of rb_cFloat.
static bool RB_TYPE_P(VALUE obj, enum ruby_value_type t)
Queries if the given object is of given type.