@JRubyMethod(name = "try_convert", meta = true) public static IRubyObject try_convert(ThreadContext context, IRubyObject self, IRubyObject arg) { return arg.checkArrayType(); }
@JRubyMethod(name = "try_convert", meta = true) public static IRubyObject try_convert(ThreadContext context, IRubyObject self, IRubyObject arg) { return arg.checkArrayType(); }
@JRubyMethod(name = "try_convert", meta = true, compat = RUBY1_9) public static IRubyObject try_convert(ThreadContext context, IRubyObject self, IRubyObject arg) { return arg.checkArrayType(); }
@JRubyMethod(name = "try_convert", meta = true, compat = RUBY1_9) public static IRubyObject try_convert(ThreadContext context, IRubyObject self, IRubyObject arg) { return arg.checkArrayType(); }
private static IRubyObject[] splatToArgumentsCommon(Ruby runtime, IRubyObject value) { if (value.isNil()) { return runtime.getSingleNilArray(); } IRubyObject tmp = value.checkArrayType(); if (tmp.isNil()) { return convertSplatToJavaArray(runtime, value); } return ((RubyArray)tmp).toJavaArrayMaybeUnsafe(); }
@Deprecated // no longer used public static IRubyObject[] splatToArguments(IRubyObject value) { if (value.isNil()) { return value.getRuntime().getSingleNilArray(); } IRubyObject tmp = value.checkArrayType(); if (tmp.isNil()) { return convertSplatToJavaArray(value.getRuntime(), value); } return ((RubyArray)tmp).toJavaArrayMaybeUnsafe(); }
private static IRubyObject[] splatToArgumentsCommon(Ruby runtime, IRubyObject value) { if (value.isNil()) { return runtime.getSingleNilArray(); } IRubyObject tmp = value.checkArrayType(); if (tmp.isNil()) { return convertSplatToJavaArray(runtime, value); } return ((RubyArray)tmp).toJavaArrayMaybeUnsafe(); }
@Deprecated // no longer used public static IRubyObject[] splatToArguments(IRubyObject value) { if (value.isNil()) { return value.getRuntime().getSingleNilArray(); } IRubyObject tmp = value.checkArrayType(); if (tmp.isNil()) { return convertSplatToJavaArray(value.getRuntime(), value); } return ((RubyArray)tmp).toJavaArrayMaybeUnsafe(); }
public IRubyObject call(ThreadContext ctx, IRubyObject[] largs, Block blk) { IRubyObject larg = packEnumValues(ctx, largs); IRubyObject i = block.yield(ctx, larg); IRubyObject tmp = i.checkArrayType(); synchronized(ary) { if(tmp.isNil()) { ary.append(i); } else { ary.concat(tmp); } } return ctx.nil; } });
public IRubyObject call(ThreadContext ctx, IRubyObject[] largs, Block blk) { IRubyObject larg = packEnumValues(ctx, largs); IRubyObject i = block.yield(ctx, larg); IRubyObject tmp = i.checkArrayType(); synchronized(ary) { if(tmp.isNil()) { ary.append(i); } else { ary.concat(tmp); } } return ctx.nil; } });
public IRubyObject call(ThreadContext ctx, IRubyObject[] largs, Block blk) { IRubyObject larg = packEnumValues(runtime, largs); IRubyObject i = block.yield(ctx, larg); IRubyObject tmp = i.checkArrayType(); synchronized(ary) { if(tmp.isNil()) { ary.append(i); } else { ary.concat(tmp); } } return runtime.getNil(); } });
public IRubyObject call(ThreadContext ctx, IRubyObject[] largs, Block blk) { IRubyObject larg = packEnumValues(runtime, largs); IRubyObject i = block.yield(ctx, larg); IRubyObject tmp = i.checkArrayType(); synchronized(ary) { if(tmp.isNil()) { ary.append(i); } else { ary.concat(tmp); } } return runtime.getNil(); } });
@JRubyMethod(name = "value=") public static IRubyObject value_set(IRubyObject self, IRubyObject val) { org.yecht.Node node = (org.yecht.Node)self.dataGetStructChecked(); Ruby runtime = self.getRuntime(); val = val.checkArrayType(); if(!val.isNil()) { node.seqEmpty(); Data.Seq ds = (Data.Seq)node.data; for(int i=0; i<((RubyArray)val).getLength(); i++) { node.seqAdd(((RubyArray)val).entry(i)); } } ((RubyObject)self).fastSetInstanceVariable("@value", val); return val; }
private RubyString opFormatCommon(ThreadContext context, IRubyObject arg) { IRubyObject tmp; if (arg instanceof RubyHash) { tmp = arg; } else { tmp = arg.checkArrayType(); if (tmp.isNil()) tmp = arg; } ByteList out = new ByteList(value.getRealSize()); out.setEncoding(value.getEncoding()); boolean tainted; // FIXME: Should we make this work with platform's locale, // or continue hardcoding US? tainted = Sprintf.sprintf1_9(out, Locale.US, value, tmp); RubyString str = newString(context.runtime, out); str.setTaint(tainted || isTaint()); return str; }
private RubyString opFormatCommon(ThreadContext context, IRubyObject arg) { IRubyObject tmp; if (arg instanceof RubyHash) { tmp = arg; } else { tmp = arg.checkArrayType(); if (tmp.isNil()) tmp = arg; } ByteList out = new ByteList(value.getRealSize()); out.setEncoding(value.getEncoding()); boolean tainted; // FIXME: Should we make this work with platform's locale, // or continue hardcoding US? tainted = Sprintf.sprintf1_9(out, Locale.US, value, tmp); RubyString str = newString(context.runtime, out); str.setTaint(tainted || isTaint()); return str; }
public static RubyArray asArray18(ThreadContext context, IRubyObject value) { Ruby runtime = context.runtime; IRubyObject tmp = value.checkArrayType(); if (tmp.isNil()) { // Object#to_a is obsolete. We match Ruby's hack until to_a goes away. Then we can // remove this hack too. if (value.respondsTo("to_a") && value.getMetaClass().searchMethod("to_a").getImplementationClass() != runtime.getKernel()) { IRubyObject avalue = value.callMethod(context, "to_a"); if (!(avalue instanceof RubyArray)) { if (runtime.is1_9() && avalue.isNil()) { return runtime.newArray(value); } else { throw runtime.newTypeError("`to_a' did not return Array"); } } return (RubyArray)avalue; } else { return runtime.newArray(value); } } return (RubyArray) tmp; }
public static RubyArray arrayValue(ThreadContext context, Ruby runtime, IRubyObject value) { IRubyObject tmp = value.checkArrayType(); if (tmp.isNil()) { // Object#to_a is obsolete. We match Ruby's hack until to_a goes away. Then we can // remove this hack too. if (value.respondsTo("to_a") && value.getMetaClass().searchMethod("to_a").getImplementationClass() != runtime.getKernel()) { IRubyObject avalue = value.callMethod(context, "to_a"); if (!(avalue instanceof RubyArray)) { if (runtime.is1_9() && avalue.isNil()) { return runtime.newArray(value); } else { throw runtime.newTypeError("`to_a' did not return Array"); } } return (RubyArray)avalue; } else { return runtime.newArray(value); } } RubyArray arr = (RubyArray) tmp; return runtime.is1_9() ? arr.aryDup19() : arr; }
public static RubyArray arrayValue(ThreadContext context, Ruby runtime, IRubyObject value) { IRubyObject tmp = value.checkArrayType(); if (tmp.isNil()) { // Object#to_a is obsolete. We match Ruby's hack until to_a goes away. Then we can // remove this hack too. if (value.respondsTo("to_a") && value.getMetaClass().searchMethod("to_a").getImplementationClass() != runtime.getKernel()) { IRubyObject avalue = value.callMethod(context, "to_a"); if (!(avalue instanceof RubyArray)) { if (runtime.is1_9() && avalue.isNil()) { return runtime.newArray(value); } else { throw runtime.newTypeError("`to_a' did not return Array"); } } return (RubyArray)avalue; } else { return runtime.newArray(value); } } RubyArray arr = (RubyArray) tmp; return runtime.is1_9() ? arr.aryDup19() : arr; }
@JRubyMethod(name = "to_h") public IRubyObject to_h(ThreadContext context) { Ruby runtime = context.runtime; int realLength = this.realLength; boolean useSmallHash = realLength <= 10; RubyHash hash = useSmallHash ? RubyHash.newSmallHash(runtime) : RubyHash.newHash(runtime); for (int i = 0; i < realLength; i++) { IRubyObject elt = eltInternal(i).checkArrayType(); if (elt == context.nil) { throw context.runtime.newTypeError("wrong element type " + eltInternal(i).getMetaClass().getRealClass() + " at " + i + " (expected array)"); } RubyArray ary = (RubyArray)elt; if (ary.getLength() != 2) { throw context.runtime.newArgumentError("wrong array length at " + i + " (expected 2, was " + ary.getLength() + ")"); } if (useSmallHash) { hash.fastASetSmall(runtime, ary.eltInternal(0), ary.eltInternal(1), true); } else { hash.fastASet(runtime, ary.eltInternal(0), ary.eltInternal(1), true); } } return hash; }
@JRubyMethod(name = "to_h") public IRubyObject to_h(ThreadContext context) { Ruby runtime = context.runtime; int realLength = this.realLength; boolean useSmallHash = realLength <= 10; RubyHash hash = useSmallHash ? RubyHash.newSmallHash(runtime) : RubyHash.newHash(runtime); for (int i = 0; i < realLength; i++) { IRubyObject elt = eltInternal(i).checkArrayType(); if (elt == context.nil) { throw context.runtime.newTypeError("wrong element type " + eltInternal(i).getMetaClass().getRealClass() + " at " + i + " (expected array)"); } RubyArray ary = (RubyArray)elt; if (ary.getLength() != 2) { throw context.runtime.newArgumentError("wrong array length at " + i + " (expected 2, was " + ary.getLength() + ")"); } if (useSmallHash) { hash.fastASetSmall(runtime, ary.eltInternal(0), ary.eltInternal(1), true); } else { hash.fastASet(runtime, ary.eltInternal(0), ary.eltInternal(1), true); } } return hash; }