public static IRubyObject checkIntegerType(ThreadContext context, IRubyObject obj) { if (obj instanceof RubyFixnum) return obj; TypeConverterSites sites = sites(context); IRubyObject conv = convertToTypeWithCheck(context, obj, context.runtime.getInteger(), sites.to_int_checked); return conv instanceof RubyInteger ? conv : context.nil; }
public static IRubyObject checkIntegerType(Ruby runtime, IRubyObject obj, String method) { if (obj instanceof RubyFixnum) return obj; IRubyObject conv = TypeConverter.convertToType(obj, runtime.getInteger(), method, false); return conv instanceof RubyInteger ? conv : runtime.getNil(); }
public static IRubyObject checkIntegerType(Ruby runtime, IRubyObject obj, String method) { if (obj instanceof RubyFixnum) return obj; IRubyObject conv = TypeConverter.convertToType(obj, runtime.getInteger(), method, false); return conv instanceof RubyInteger ? conv : runtime.getNil(); }
public static IRubyObject checkIntegerType(ThreadContext context, IRubyObject obj) { if (obj instanceof RubyFixnum) return obj; TypeConverterSites sites = sites(context); IRubyObject conv = convertToTypeWithCheck(context, obj, context.runtime.getInteger(), sites.to_int_checked); return conv instanceof RubyInteger ? conv : context.nil; }
public static IRubyObject checkIntegerType(Ruby runtime, IRubyObject obj, String method) { if (method.equals("to_int")) return checkIntegerType(runtime.getCurrentContext(), obj); if (obj instanceof RubyFixnum) return obj; if (method.equals("to_i")) { ThreadContext context = runtime.getCurrentContext(); TypeConverterSites sites = sites(context); IRubyObject conv = convertToTypeWithCheck(context, obj, runtime.getInteger(), sites.to_i_checked); return conv instanceof RubyInteger ? conv : runtime.getNil(); } IRubyObject conv = TypeConverter.convertToType(obj, runtime.getInteger(), method, false); return conv instanceof RubyInteger ? conv : runtime.getNil(); }
public static IRubyObject checkIntegerType(Ruby runtime, IRubyObject obj, String method) { if (method.equals("to_int")) return checkIntegerType(runtime.getCurrentContext(), obj); if (obj instanceof RubyFixnum) return obj; if (method.equals("to_i")) { ThreadContext context = runtime.getCurrentContext(); TypeConverterSites sites = sites(context); IRubyObject conv = convertToTypeWithCheck(context, obj, runtime.getInteger(), sites.to_i_checked); return conv instanceof RubyInteger ? conv : runtime.getNil(); } IRubyObject conv = TypeConverter.convertToType(obj, runtime.getInteger(), method, false); return conv instanceof RubyInteger ? conv : runtime.getNil(); }
public static RubyClass createBignumClass(Ruby runtime) { RubyClass bignum = runtime.defineClass("Bignum", runtime.getInteger(), ObjectAllocator.NOT_ALLOCATABLE_ALLOCATOR); runtime.setBignum(bignum); bignum.index = ClassIndex.BIGNUM; bignum.setReifiedClass(RubyBignum.class); bignum.defineAnnotatedMethods(RubyBignum.class); return bignum; }
public static RubyClass createBignumClass(Ruby runtime) { RubyClass bignum = runtime.getInteger(); runtime.getObject().setConstant("Bignum", bignum); runtime.getObject().deprecateConstant(runtime, "Bignum"); runtime.setBignum(bignum); return bignum; }
public static RubyClass createBignumClass(Ruby runtime) { RubyClass bignum = runtime.getInteger(); runtime.getObject().setConstant("Bignum", bignum); runtime.getObject().deprecateConstant(runtime, "Bignum"); runtime.setBignum(bignum); return bignum; }
public static RubyInteger convertToInteger(IRubyObject self, String convertMethod) { IRubyObject val = TypeConverter.convertToType(self, getRuntime(self).getInteger(), convertMethod, true); if (!(val instanceof RubyInteger)) throw getRuntime(self).newTypeError(getMetaClass(self).getName() + '#' + convertMethod + " should return Integer"); return (RubyInteger)val; }
/** * Tries to convert this object to a Ruby Integer using the * supplied conversion method. */ public RubyInteger convertToInteger(String convertMethod) { IRubyObject val = TypeConverter.convertToType(this, getRuntime().getInteger(), convertMethod, true); if (!(val instanceof RubyInteger)) throw getRuntime().newTypeError(getMetaClass().getName() + "#" + convertMethod + " should return Integer"); return (RubyInteger)val; }
/** * Tries to convert this object to a Ruby Integer using the * supplied conversion method. */ public RubyInteger convertToInteger(String convertMethod) { IRubyObject val = TypeConverter.convertToType(this, getRuntime().getInteger(), convertMethod, true); if (!(val instanceof RubyInteger)) throw getRuntime().newTypeError(getMetaClass().getName() + "#" + convertMethod + " should return Integer"); return (RubyInteger)val; }
public static RubyClass createFixnumClass(Ruby runtime) { RubyClass fixnum = runtime.getInteger(); runtime.getObject().setConstant("Fixnum", fixnum); runtime.getObject().deprecateConstant(runtime, "Fixnum"); runtime.setFixnum(fixnum); for (int i = 0; i < runtime.fixnumCache.length; i++) { runtime.fixnumCache[i] = new RubyFixnum(fixnum, i - CACHE_OFFSET); } return fixnum; }
public static RubyInteger convertToInteger(IRubyObject self, String convertMethod) { IRubyObject val = TypeConverter.convertToType(self, getRuntime(self).getInteger(), convertMethod, true); if (!(val instanceof RubyInteger)) throw getRuntime(self).newTypeError(getMetaClass(self).getName() + "#" + convertMethod + " should return Integer"); return (RubyInteger)val; }
public static RubyInteger convertToInteger(IRubyObject self, String convertMethod) { IRubyObject val = TypeConverter.convertToType(self, getRuntime(self).getInteger(), convertMethod, true); if (!(val instanceof RubyInteger)) throw getRuntime(self).newTypeError(getMetaClass(self).getName() + "#" + convertMethod + " should return Integer"); return (RubyInteger)val; }
public static RubyClass createFixnumClass(Ruby runtime) { RubyClass fixnum = runtime.getInteger(); runtime.getObject().setConstant("Fixnum", fixnum); runtime.getObject().deprecateConstant(runtime, "Fixnum"); runtime.setFixnum(fixnum); for (int i = 0; i < runtime.fixnumCache.length; i++) { runtime.fixnumCache[i] = new RubyFixnum(fixnum, i - CACHE_OFFSET); } return fixnum; }
public static RubyInteger convertToInteger(IRubyObject self, String convertMethod) { IRubyObject val = TypeConverter.convertToType(self, getRuntime(self).getInteger(), convertMethod, true); if (!(val instanceof RubyInteger)) throw getRuntime(self).newTypeError(getMetaClass(self).getName() + '#' + convertMethod + " should return Integer"); return (RubyInteger)val; }
public IRubyObject aset(IRubyObject index, IRubyObject value) { if (! (index instanceof RubyInteger)) { throw getRuntime().newTypeError(index, getRuntime().getInteger()); } int intIndex = (int) ((RubyInteger) index).getLongValue(); if (! (value instanceof JavaObject)) { throw getRuntime().newTypeError("not a java object:" + value); } Object javaObject = ((JavaObject) value).getValue(); ArrayUtils.setWithExceptionHandlingDirect(getRuntime(), javaObject, intIndex, javaObject); return value; }
public IRubyObject aset(IRubyObject index, IRubyObject value) { if (! (index instanceof RubyInteger)) { throw getRuntime().newTypeError(index, getRuntime().getInteger()); } int intIndex = (int) ((RubyInteger) index).getLongValue(); if (! (value instanceof JavaObject)) { throw getRuntime().newTypeError("not a java object:" + value); } Object javaObject = ((JavaObject) value).getValue(); ArrayUtils.setWithExceptionHandlingDirect(getRuntime(), javaObject, intIndex, javaObject); return value; }
public IRubyObject aset(IRubyObject index, IRubyObject value) { if (! (index instanceof RubyInteger)) { throw getRuntime().newTypeError(index, getRuntime().getInteger()); } int intIndex = (int) ((RubyInteger) index).getLongValue(); if (! (value instanceof JavaObject)) { throw getRuntime().newTypeError("not a java object:" + value); } Object javaObject = ((JavaObject) value).getValue(); ArrayUtils.setWithExceptionHandlingDirect(getRuntime(), javaObject, intIndex, javaObject); return value; }