本文整理汇总了C++中rb_cmpint函数的典型用法代码示例。如果您正苦于以下问题:C++ rb_cmpint函数的具体用法?C++ rb_cmpint怎么用?C++ rb_cmpint使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rb_cmpint函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: range_max
static VALUE
range_max(int argc, VALUE *argv, VALUE range)
{
VALUE e = RANGE_END(range);
int nm = FIXNUM_P(e) || rb_obj_is_kind_of(e, rb_cNumeric);
if (rb_block_given_p() || (EXCL(range) && !nm) || argc) {
return rb_call_super(argc, argv);
}
else {
VALUE b = RANGE_BEG(range);
int c = rb_cmpint(rb_funcall(b, id_cmp, 1, e), b, e);
if (c > 0)
return Qnil;
if (EXCL(range)) {
if (!FIXNUM_P(e) && !rb_obj_is_kind_of(e, rb_cInteger)) {
rb_raise(rb_eTypeError, "cannot exclude non Integer end value");
}
if (c == 0) return Qnil;
if (!FIXNUM_P(b) && !rb_obj_is_kind_of(b,rb_cInteger)) {
rb_raise(rb_eTypeError, "cannot exclude end value with non Integer begin value");
}
if (FIXNUM_P(e)) {
return LONG2NUM(FIX2LONG(e) - 1);
}
return rb_funcall(e, '-', 1, INT2FIX(1));
}
return e;
}
}
示例2: range_max
static VALUE
range_max(VALUE range, SEL sel)
{
VALUE e = RANGE_END(range);
int nm = FIXNUM_P(e) || rb_obj_is_kind_of(e, rb_cNumeric);
if (rb_block_given_p() || (EXCL(range) && !nm)) {
if (sel == NULL) {
sel = sel_registerName("max");
}
return rb_vm_call_super(range, sel, 0, NULL);
}
else {
VALUE b = RANGE_BEG(range);
int c = rb_cmpint(rb_objs_cmp(b, e), b, e);
if (c > 0)
return Qnil;
if (EXCL(range)) {
if (!FIXNUM_P(e) && !rb_obj_is_kind_of(e, rb_cInteger)) {
rb_raise(rb_eTypeError, "cannot exclude non Integer end value");
}
if (c == 0) {
return Qnil;
}
if (FIXNUM_P(e)) {
return LONG2NUM(FIX2LONG(e) - 1);
}
VALUE one = INT2FIX(1);
return rb_vm_call(e, selMINUS, 1, &one);
}
return e;
}
}
示例3: cmp_gt
static VALUE
cmp_gt(VALUE x, VALUE y)
{
VALUE c = rb_funcall(x, cmp, 1, y);
if (rb_cmpint(c, x, y) > 0) return Qtrue;
return Qfalse;
}
示例4: cmp_eq
static VALUE
cmp_eq(VALUE *a)
{
VALUE c = rb_exec_recursive_paired_outer(cmp_eq_recursive, a[0], a[1], a[1]);
if (NIL_P(c)) return Qfalse;
if (rb_cmpint(c, a[0], a[1]) == 0) return Qtrue;
return Qfalse;
}
示例5: cmp_1
static int
cmp_1(const void *ap, const void *bp, void *dummy)
{
struct sort_data *d = dummy;
VALUE a = rb_enc_str_new(ap, d->elsize, d->enc);
VALUE b = rb_enc_str_new(bp, d->elsize, d->enc);
VALUE retval = rb_yield_values(2, a, b);
return rb_cmpint(retval, a, b);
}
示例6: cmp_eq
static VALUE
cmp_eq(VALUE *a)
{
VALUE c = rb_funcall(a[0], cmp, 1, a[1]);
if (NIL_P(c)) return Qfalse;
if (rb_cmpint(c, a[0], a[1]) == 0) return Qtrue;
return Qfalse;
}
示例7: cmp_gt
static VALUE
cmp_gt(VALUE x, SEL sel, VALUE y)
{
VALUE c = rb_vm_call(x, cmp, 1, &y);
if (rb_cmpint(c, x, y) > 0) {
return Qtrue;
}
return Qfalse;
}
示例8: r_lt
static int
r_lt(VALUE a, VALUE b)
{
VALUE r = rb_funcall(a, id_cmp, 1, b);
if (NIL_P(r))
return (int)Qfalse;
if (rb_cmpint(r, a, b) < 0)
return (int)Qtrue;
return (int)Qfalse;
}
示例9: r_lt
static int
r_lt(VALUE a, VALUE b)
{
VALUE r = rb_objs_cmp(a, b);
if (NIL_P(r))
return Qfalse;
if (rb_cmpint(r, a, b) < 0)
return Qtrue;
return Qfalse;
}
示例10: rb_invcmp
VALUE
rb_invcmp(VALUE x, VALUE y)
{
VALUE invcmp = rb_exec_recursive(invcmp_recursive, x, y);
if (invcmp == Qundef || NIL_P(invcmp)) {
return Qnil;
}
else {
int result = -rb_cmpint(invcmp, x, y);
return INT2FIX(result);
}
}
示例11: cmp_eq
static VALUE
cmp_eq(VALUE *a)
{
VALUE c = rb_vm_call(a[0], cmp, 1, &a[1]);
if (NIL_P(c)) {
return Qfalse;
}
if (rb_cmpint(c, a[0], a[1]) == 0) {
return Qtrue;
}
return Qfalse;
}
示例12: cmp_equal
static VALUE
cmp_equal(VALUE x, VALUE y)
{
VALUE c;
if (x == y) return Qtrue;
c = rb_exec_recursive_paired_outer(cmp_eq_recursive, x, y, y);
if (NIL_P(c)) return Qfalse;
if (rb_cmpint(c, x, y) == 0) return Qtrue;
return Qfalse;
}
示例13: r_le
static int
r_le(VALUE a, VALUE b)
{
int c;
VALUE r = rb_objs_cmp(a, b);
if (NIL_P(r))
return Qfalse;
c = rb_cmpint(r, a, b);
if (c == 0)
return INT2FIX(0);
if (c < 0)
return Qtrue;
return Qfalse;
}
示例14: r_le
static int
r_le(VALUE a, VALUE b)
{
int c;
VALUE r = rb_funcall(a, id_cmp, 1, b);
if (NIL_P(r))
return (int)Qfalse;
c = rb_cmpint(r, a, b);
if (c == 0)
return (int)INT2FIX(0);
if (c < 0)
return (int)Qtrue;
return (int)Qfalse;
}
示例15: range_min
static VALUE
range_min(VALUE range)
{
if (rb_block_given_p()) {
return rb_call_super(0, 0);
}
else {
VALUE b = RANGE_BEG(range);
VALUE e = RANGE_END(range);
int c = rb_cmpint(rb_funcall(b, id_cmp, 1, e), b, e);
if (c > 0 || (c == 0 && EXCL(range)))
return Qnil;
return b;
}
}