14 #include "internal/compar.h"
15 #include "internal/error.h"
16 #include "internal/vm.h"
43 invcmp_recursive(
VALUE x,
VALUE y,
int recursive)
45 if (recursive)
return Qnil;
53 if (NIL_OR_UNDEF_P(invcmp)) {
63 cmp_eq_recursive(
VALUE arg1,
VALUE arg2,
int recursive)
65 if (recursive)
return Qnil;
66 return rb_cmp(arg1, arg2);
82 if (x == y)
return Qtrue;
107 return RBOOL(cmpint(x, y) > 0);
121 return RBOOL(cmpint(x, y) >= 0);
135 return RBOOL(cmpint(x, y) < 0);
149 return RBOOL(cmpint(x, y) <= 0);
170 return RBOOL((cmpint(x, min) >= 0 && cmpint(x, max) <= 0));
231 rb_builtin_class_name(range));
237 if (!
NIL_P(min) && !
NIL_P(max) && cmpint(min, max) > 0) {
243 if (c == 0)
return x;
244 if (c < 0)
return min;
248 if (c > 0)
return max;
313 Init_Comparable(
void)
VALUE rb_define_module(const char *name)
Defines a top-level module.
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.
void rb_define_method(VALUE klass, const char *name, VALUE(*func)(ANYARGS), int argc)
Defines a method.
#define INT2FIX
Old name of RB_INT2FIX.
#define T_FLOAT
Old name of RUBY_T_FLOAT.
#define SPECIAL_CONST_P
Old name of RB_SPECIAL_CONST_P.
#define Qtrue
Old name of RUBY_Qtrue.
#define Qnil
Old name of RUBY_Qnil.
#define Qfalse
Old name of RUBY_Qfalse.
#define NIL_P
Old name of RB_NIL_P.
#define BUILTIN_TYPE
Old name of RB_BUILTIN_TYPE.
void rb_raise(VALUE exc, const char *fmt,...)
Exception entry point.
VALUE rb_eTypeError
TypeError exception.
VALUE rb_eArgError
ArgumentError exception.
VALUE rb_obj_class(VALUE obj)
Queries the class of an object.
VALUE rb_inspect(VALUE obj)
Generates a human-readable textual representation of the given object.
VALUE rb_mComparable
Comparable module.
VALUE rb_funcallv(VALUE recv, ID mid, int argc, const VALUE *argv)
Identical to rb_funcall(), except it takes the method arguments as a C array.
int rb_cmpint(VALUE val, VALUE a, VALUE b)
Canonicalises the passed val, which is the return value of a <=> b, into C's {-1, 0,...
void rb_cmperr(VALUE a, VALUE b)
Raises "comparison failed" error.
int rb_range_values(VALUE range, VALUE *begp, VALUE *endp, int *exclp)
Deconstructs a range into its components.
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_outer(VALUE(*f)(VALUE g, VALUE h, int r), VALUE g, VALUE p, VALUE h)
Identical to rb_exec_recursive_outer(), except it checks for the recursion on the ordered pair of { g...
uintptr_t VALUE
Type that represents a Ruby object.