Refine search
@JRubyMethod(name = "number=") public IRubyObject setNumber(ThreadContext context, IRubyObject value) { this.number = value; this.builder.setNumber(RubyNumeric.num2int(value)); return context.runtime.getNil(); }
@JRubyMethod(meta = true) public static IRubyObject lookup(ThreadContext context, IRubyObject recv, IRubyObject number) { RubyEnumDescriptor rubyEnumDescriptorescriptor = (RubyEnumDescriptor) getDescriptor(context, recv); Descriptors.EnumDescriptor descriptor = rubyEnumDescriptorescriptor.getDescriptor(); Descriptors.EnumValueDescriptor value = descriptor.findValueByNumber(RubyNumeric.num2int(number)); if (value == null) return context.runtime.getNil(); return context.runtime.newSymbol(value.getName()); }
@JRubyMethod(name = "add_value") public IRubyObject addValue(ThreadContext context, IRubyObject name, IRubyObject number) { DescriptorProtos.EnumValueDescriptorProto.Builder valueBuilder = DescriptorProtos.EnumValueDescriptorProto.newBuilder(); valueBuilder.setName(name.asJavaString()); valueBuilder.setNumber(RubyNumeric.num2int(number)); this.builder.addValue(valueBuilder); return context.runtime.getNil(); }
@JRubyMethod(required=1, optional=1, name = {"at", "[]"}) public IRubyObject index(ThreadContext context, IRubyObject[] args) { if (args.length == 1){ IRubyObject arg = args[0]; if (Utils.isRubyNum(arg)) { /* standard case */ int arrIndex = normalizeArrayIndex(arg); if (arrIndex < 0 || arrIndex >= this.storage.size()) { return context.runtime.getNil(); } return this.storage.eltInternal(arrIndex); } else if (arg instanceof RubyRange) { RubyRange range = ((RubyRange) arg); int beg = RubyNumeric.num2int(range.first(context)); int to = RubyNumeric.num2int(range.last(context)); int len = to - beg + 1; return this.storage.subseq(beg, len); } } /* assume 2 arguments */ int beg = RubyNumeric.num2int(args[0]); int len = RubyNumeric.num2int(args[1]); if (beg < 0) { beg += this.storage.size(); } if (beg >= this.storage.size()) { return context.runtime.getNil(); } return this.storage.subseq(beg, len); }
@JRubyMethod(name = {"[]", "slice"}, reads = BACKREF, writes = BACKREF) public IRubyObject op_aref(ThreadContext context, IRubyObject arg1, IRubyObject arg2) { Ruby runtime = context.runtime; if (arg1 instanceof RubyRegexp) return subpat(context, (RubyRegexp) arg1, arg2); return substr19(runtime, RubyNumeric.num2int(arg1), RubyNumeric.num2int(arg2)); }
@JRubyMethod(name = {"[]", "slice"}, reads = BACKREF, writes = BACKREF) public IRubyObject op_aref(ThreadContext context, IRubyObject arg1, IRubyObject arg2) { Ruby runtime = context.runtime; if (arg1 instanceof RubyRegexp) return subpat(context, (RubyRegexp) arg1, arg2); return substr19(runtime, RubyNumeric.num2int(arg1), RubyNumeric.num2int(arg2)); }
@JRubyMethod(name = {"[]", "slice"}, reads = BACKREF, writes = BACKREF, compat = RUBY1_9) public IRubyObject op_aref19(ThreadContext context, IRubyObject arg1, IRubyObject arg2) { Ruby runtime = context.runtime; if (arg1 instanceof RubyRegexp) return subpat19(runtime, context, (RubyRegexp)arg1, arg2); return substr19(runtime, RubyNumeric.num2int(arg1), RubyNumeric.num2int(arg2)); }
/** rb_ary_aset * */ @JRubyMethod(name = "[]=") public IRubyObject aset(IRubyObject arg0, IRubyObject arg1, IRubyObject arg2) { modifyCheck(); splice(getRuntime(), RubyNumeric.num2int(arg0), RubyNumeric.num2int(arg1), arg2); return arg2; }
/** rb_ary_aset * */ @JRubyMethod(name = "[]=") public IRubyObject aset(IRubyObject arg0, IRubyObject arg1, IRubyObject arg2) { modifyCheck(); splice(getRuntime(), RubyNumeric.num2int(arg0), RubyNumeric.num2int(arg1), arg2); return arg2; }
/** rb_ary_slice_bang * */ @JRubyMethod(name = "slice!") public IRubyObject slice_bang(IRubyObject arg0, IRubyObject arg1) { modifyCheck(); return slice_internal(getRuntime(), RubyNumeric.num2int(arg0), RubyNumeric.num2int(arg1)); }
@JRubyMethod(name = "[]") public final IRubyObject aref(ThreadContext context, IRubyObject indexArg) { final int index = RubyNumeric.num2int(indexArg); final int offset = index * typeSize; if (offset >= size) { throw context.runtime.newIndexError(String.format("Index %d out of range", index)); } return slice(context.runtime, offset); }
@JRubyMethod(name = "[]") public final IRubyObject aref(ThreadContext context, IRubyObject indexArg) { final int index = RubyNumeric.num2int(indexArg); final int offset = index * typeSize; if (offset >= size) { throw context.runtime.newIndexError(String.format("Index %d out of range", index)); } return slice(context.runtime, offset); }
@JRubyMethod(name = "ldexp", required = 2, module = true, visibility = Visibility.PRIVATE) public static RubyFloat ldexp(ThreadContext context, IRubyObject recv, IRubyObject mantissa, IRubyObject exponent) { return RubyFloat.newFloat(context.runtime, RubyNumeric.num2dbl(context, mantissa) * Math.pow(2.0, RubyNumeric.num2int(exponent))); }
@JRubyMethod(name = "new", meta = true, required = 3, optional = 1) public static final IRubyObject newStructLayout(ThreadContext context, IRubyObject klass, IRubyObject[] args) { IRubyObject rbFields = args[0], size = args[1], alignment = args[2]; if (!(rbFields instanceof RubyArray)) { throw context.runtime.newTypeError(rbFields, context.runtime.getArray()); } List<IRubyObject> fields = Arrays.asList(((RubyArray) rbFields).toJavaArrayMaybeUnsafe()); return new StructLayout(context.runtime, (RubyClass) klass, fields, RubyNumeric.num2int(size), RubyNumeric.num2int(alignment)); }
@JRubyMethod public IRubyObject setbyte(ThreadContext context, IRubyObject index, IRubyObject val) { int i = RubyNumeric.num2int(index); int b = RubyNumeric.num2int(val); int normalizedIndex = checkIndexForRef(i, value.getRealSize()); modify19(); value.getUnsafeBytes()[normalizedIndex] = (byte)b; return val; }
@JRubyMethod public IRubyObject setbyte(ThreadContext context, IRubyObject index, IRubyObject val) { int i = RubyNumeric.num2int(index); int b = RubyNumeric.num2int(val); int normalizedIndex = checkIndexForRef(i, value.getRealSize()); modify19(); value.getUnsafeBytes()[normalizedIndex] = (byte)b; return val; }
@JRubyMethod(name = "setbyte", compat = RUBY1_9) public IRubyObject setbyte(ThreadContext context, IRubyObject index, IRubyObject val) { modifyAndKeepCodeRange(); int i = RubyNumeric.num2int(index); int b = RubyNumeric.num2int(val); value.getUnsafeBytes()[checkIndexForRef(i, value.getRealSize())] = (byte)b; return val; }
@JRubyMethod(name = "setbyte", compat = RUBY1_9) public IRubyObject setbyte(ThreadContext context, IRubyObject index, IRubyObject val) { modifyAndKeepCodeRange(); int i = RubyNumeric.num2int(index); int b = RubyNumeric.num2int(val); value.getUnsafeBytes()[checkIndexForRef(i, value.getRealSize())] = (byte)b; return val; }
@JRubyMethod(name = "insert") public IRubyObject insert(ThreadContext context, IRubyObject indexArg, IRubyObject stringArg) { RubyString str = stringArg.convertToString(); int index = RubyNumeric.num2int(indexArg); if (index == -1) return append19(stringArg); if (index < 0) index++; replaceInternal19(index, 0, str); return this; }
@JRubyMethod(meta = true) public static IRubyObject mkfifo(ThreadContext context, IRubyObject recv, IRubyObject path, IRubyObject mode) { if (Platform.IS_WINDOWS) throw context.runtime.newNotImplementedError("mkfifo"); return mkfifo(context, get_path(context, path), RubyNumeric.num2int(mode)); }