private boolean is_even(IRubyObject x) { if (x instanceof RubyFixnum) { return RubyNumeric.fix2long((RubyFixnum) x) % 2 == 0; } if (x instanceof RubyBignum) { return RubyBignum.big2long((RubyBignum) x) % 2 == 0; } return false; } }// RubyBigdecimal
private boolean is_even(IRubyObject x) { if (x instanceof RubyFixnum) { return RubyNumeric.fix2long((RubyFixnum) x) % 2 == 0; } if (x instanceof RubyBignum) { return RubyBignum.big2long((RubyBignum) x) % 2 == 0; } return false; } }// RubyBigdecimal
public static int fix2int(IRubyObject arg) { long num = arg instanceof RubyFixnum ? fix2long(arg) : num2long(arg); checkInt(arg, num); return (int) num; }
public static int fix2int(IRubyObject arg) { long num = arg instanceof RubyFixnum ? fix2long(arg) : num2long(arg); checkInt(arg, num); return (int) num; }
public static int fix2int(IRubyObject arg) { long num = arg instanceof RubyFixnum ? fix2long(arg) : num2long(arg); checkInt(arg, num); return (int) num; }
public static int fix2int(IRubyObject arg) { long num = arg instanceof RubyFixnum ? fix2long(arg) : num2long(arg); checkInt(arg, num); return (int) num; }
@Override public int hashCode() { final IRubyObject hash = hash(getRuntime().getCurrentContext()); if (hash instanceof RubyFixnum) return (int) RubyNumeric.fix2long(hash); return nonFixnumHashCode(hash); }
/** * This override does not do "checked" dispatch since Object usually has #hash defined. * * @see RubyBasicObject#hashCode() */ @Override public int hashCode() { IRubyObject hashValue = invokedynamic(getRuntime().getCurrentContext(), this, HASH); if (hashValue instanceof RubyFixnum) return (int) RubyNumeric.fix2long(hashValue); return nonFixnumHashCode(hashValue); }
/** * Override the Object#hashCode method to make sure that the Ruby * hash is actually used as the hashcode for Ruby objects. If the * Ruby "hash" method doesn't return a number, the Object#hashCode * implementation will be used instead. */ @Override public int hashCode() { IRubyObject hashValue = invokedynamic(getRuntime().getCurrentContext(), this, HASH); if (hashValue instanceof RubyFixnum) return (int) RubyNumeric.fix2long(hashValue); return nonFixnumHashCode(hashValue); }
/** * This override does not do "checked" dispatch since Object usually has #hash defined. * * @see RubyBasicObject#hashCode() */ @Override public int hashCode() { IRubyObject hashValue = invokedynamic(getRuntime().getCurrentContext(), this, HASH); if (hashValue instanceof RubyFixnum) return (int) RubyNumeric.fix2long(hashValue); return nonFixnumHashCode(hashValue); }
@Override public int hashCode() { final IRubyObject hash = hash(getRuntime().getCurrentContext()); if (hash instanceof RubyFixnum) return (int) RubyNumeric.fix2long(hash); return nonFixnumHashCode(hash); }
/** * Override the Object#hashCode method to make sure that the Ruby * hash is actually used as the hashcode for Ruby objects. If the * Ruby "hash" method doesn't return a number, the Object#hashCode * implementation will be used instead. */ @Override public int hashCode() { IRubyObject hashValue = invokedynamic(getRuntime().getCurrentContext(), this, HASH); if (hashValue instanceof RubyFixnum) return (int) RubyNumeric.fix2long(hashValue); return nonFixnumHashCode(hashValue); }
@JRubyMethod(name = "pos=", required = 1) public IRubyObject set_pos(IRubyObject arg) { checkInitialized(); long p = RubyNumeric.fix2long(arg); if (p < 0) throw getRuntime().newErrnoEINVALError(arg.toString()); if (p > Integer.MAX_VALUE) throw getRuntime().newArgumentError("JRuby does not support StringIO larger than " + Integer.MAX_VALUE + " bytes"); ptr.pos = (int)p; return arg; }
@JRubyMethod(name = "pos=", required = 1) public IRubyObject set_pos(IRubyObject arg) { checkInitialized(); long p = RubyNumeric.fix2long(arg); if (p < 0) throw getRuntime().newErrnoEINVALError(arg.toString()); if (p > Integer.MAX_VALUE) throw getRuntime().newArgumentError("JRuby does not support StringIO larger than " + Integer.MAX_VALUE + " bytes"); ptr.pos = (int)p; return arg; }
@JRubyMethod(required = 1, module = true, visibility = PRIVATE) public static IRubyObject undefine_finalizer(IRubyObject recv, IRubyObject obj, Block block) { recv.getRuntime().getObjectSpace().removeFinalizers(RubyNumeric.fix2long(obj.id())); return recv; }
@JRubyMethod(required = 1, module = true, visibility = PRIVATE) public static IRubyObject undefine_finalizer(IRubyObject recv, IRubyObject obj, Block block) { recv.getRuntime().getObjectSpace().removeFinalizers(RubyNumeric.fix2long(obj.id())); return recv; }
@JRubyMethod(required = 1, module = true, visibility = PRIVATE) public static IRubyObject undefine_finalizer(IRubyObject recv, IRubyObject arg1, Block block) { recv.getRuntime().getObjectSpace().removeFinalizers(RubyNumeric.fix2long(arg1.id())); return recv; }
@JRubyMethod(required = 1, module = true, visibility = PRIVATE) public static IRubyObject undefine_finalizer(IRubyObject recv, IRubyObject arg1, Block block) { recv.getRuntime().getObjectSpace().removeFinalizers(RubyNumeric.fix2long(arg1.id())); return recv; }
@JRubyMethod(name = "gets", writes = FrameField.LASTLINE, compat = RUBY1_9) public IRubyObject gets19(ThreadContext context, IRubyObject separator, IRubyObject limit_arg) { Ruby runtime = context.runtime; long limit = limit_arg.isNil() ? -1 : RubyNumeric.fix2long(TypeConverter.checkIntegerType(runtime, limit_arg, "to_int")); IRubyObject result = getline(context, separator(runtime, separator), limit); if (!result.isNil()) context.setLastLine(result); return result; }
@JRubyMethod(name = "gets", writes = FrameField.LASTLINE, compat = RUBY1_9) public IRubyObject gets19(ThreadContext context, IRubyObject separator, IRubyObject limit_arg) { Ruby runtime = context.runtime; long limit = limit_arg.isNil() ? -1 : RubyNumeric.fix2long(TypeConverter.checkIntegerType(runtime, limit_arg, "to_int")); IRubyObject result = getline(context, separator(runtime, separator), limit); if (!result.isNil()) context.setLastLine(result); return result; }