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))
52 v = rb_funcall(beg, id_cmp, 1, end);
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;
105 rb_scan_args(argc, argv,
"21", &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));
201 VALUE r = rb_funcall(a, id_cmp, 1, b);
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;
320 iter[0] = rb_funcall(iter[0],
'-', 1,
INT2FIX(1));
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);
445 step = (!rb_check_arity(argc, 0, 1) ?
INT2FIX(1) : argv[0]);
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;
512 while (
NIL_P(e) ||
RTEST(rb_funcall(v, op, 1, e))) {
515 v = rb_funcall(b,
'+', 1, rb_funcall(
INT2NUM(i),
'*', 1, step));
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)", \
652 if (excl) high = rb_funcall(high,
'-', 1,
INT2FIX(1));
655 while (rb_cmpint(rb_funcall(low, id_cmp, 1, high), low, high) < 0) {
656 mid = rb_funcall(rb_funcall(high,
'+', 1, low), id_div, 1,
INT2FIX(2));
662 low = rb_funcall(mid,
'+', 1,
INT2FIX(1));
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)
736 else if (RB_FLOAT_TYPE_P(beg) || RB_FLOAT_TYPE_P(end)) {
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)) {
751 VALUE mid = rb_funcall(beg,
'+', 1, diff);
754 return bsearch_integer_range(beg, mid, 0);
756 diff = rb_funcall(diff,
'*', 1,
LONG2FIX(2));
759 else if (
NIL_P(beg) && is_integer_p(end)) {
763 VALUE mid = rb_funcall(end,
'+', 1, diff);
766 return bsearch_integer_range(mid, end, 0);
768 diff = rb_funcall(diff,
'*', 1,
LONG2FIX(2));
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);
925 if (RBIGNUM_NEGATIVE_P(beg)) {
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);
1086 rb_scan_args(argc, argv,
"1", &n);
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);
1124 rb_scan_args(argc, argv,
"1", &nv);
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;
1425 return rb_funcall(e,
'-', 1,
INT2FIX(1));
1478range_minmax(
VALUE range)
1483 return rb_assoc_new(
1484 rb_funcall(range, id_min, 0),
1485 rb_funcall(range, id_max, 0)
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;
1772range_string_cover_internal(
VALUE range,
VALUE val)
1774 VALUE beg = RANGE_BEG(range);
1775 VALUE end = RANGE_END(range);
1777 linear_object_p(beg) || linear_object_p(end);
1782 return r_cover_p(range, beg, end, val);
1786 return r_cover_p(range, beg, end, val);
1789 VALUE r = rb_funcall(val, id_cmp, 1, end);
1791 if (RANGE_EXCL(range)) {
1792 return RBOOL(rb_cmpint(r, val, end) < 0);
1794 return RBOOL(rb_cmpint(r, val, end) <= 0);
1796 else if (
NIL_P(end)) {
1797 VALUE r = rb_funcall(beg, id_cmp, 1, val);
1799 return RBOOL(rb_cmpint(r, beg, val) <= 0);
1811range_include_internal(
VALUE range,
VALUE val)
1813 VALUE beg = RANGE_BEG(range);
1814 VALUE end = RANGE_END(range);
1816 linear_object_p(beg) || linear_object_p(end);
1821 return r_cover_p(range, beg, end, val);
1824 return rb_str_include_range_p(beg, end, val, RANGE_EXCL(range));
1968 beg = RANGE_BEG(range);
1969 end = RANGE_END(range);
1972 return RBOOL(r_cover_range_p(range, beg, end, val));
1974 return r_cover_p(range, beg, end, val);
1980 return rb_funcallv(r, rb_intern(
"max"), 0, 0);
1986 VALUE val_beg, val_end, val_max;
1989 val_beg = RANGE_BEG(val);
1990 val_end = RANGE_END(val);
1992 if (!
NIL_P(end) &&
NIL_P(val_end))
return FALSE;
1993 if (!
NIL_P(beg) &&
NIL_P(val_beg))
return FALSE;
1994 if (!
NIL_P(val_beg) && !
NIL_P(val_end) && r_less(val_beg, val_end) > (EXCL(val) ? -1 : 0)) return FALSE;
1995 if (!
NIL_P(val_beg) && !r_cover_p(range, beg, end, val_beg))
return FALSE;
1999 VALUE r_cmp_end = rb_funcall(end, id_cmp, 1, val_end);
2000 if (
NIL_P(r_cmp_end))
return FALSE;
2001 cmp_end = rb_cmpint(r_cmp_end, end, val_end);
2004 cmp_end = r_less(end, val_end);
2008 if (EXCL(range) == EXCL(val)) {
2009 return cmp_end >= 0;
2011 else if (EXCL(range)) {
2014 else if (cmp_end >= 0) {
2019 if (
NIL_P(val_max))
return FALSE;
2021 return r_less(end, val_max) >= 0;
2027 if (
NIL_P(beg) || r_less(beg, val) <= 0) {
2028 int excl = EXCL(range);
2029 if (
NIL_P(end) || r_less(val, end) <= -excl)
2036range_dumper(
VALUE range)
2049 VALUE beg, end, excl;
2051 if (!RB_TYPE_P(obj,
T_OBJECT) ||
RBASIC(obj)->klass != rb_cObject) {
2055 range_modify(range);
2060 range_init(range, beg, end, RBOOL(
RTEST(excl)));
2066range_alloc(
VALUE klass)
2105range_count(
int argc,
VALUE *argv,
VALUE range)
2117 else if (
NIL_P(RANGE_END(range))) {
2121 else if (
NIL_P(RANGE_BEG(range))) {
2357 id_beg = rb_intern_const(
"begin");
2358 id_end = rb_intern_const(
"end");
2359 id_excl = rb_intern_const(
"excl");
2362 "Range", rb_cObject, range_alloc,
2363 "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_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.
VALUE rb_rescue2(VALUE(*b_proc)(VALUE), VALUE data1, VALUE(*r_proc)(VALUE, VALUE), VALUE data2,...)
An equivalent of rescue clause.
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_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.
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.
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.
#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.
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 VALUE
Type that represents a Ruby object.
uintptr_t ID
Type that represents a Ruby identifier such as a variable name.