/** Getter for property list. * @return Value of property list. */ public List getList() { return Arrays.asList(toJavaArray()); }
/** * @deprecated RubyArray implements List, use it directly * @return a read-only copy of this list */ public final List<IRubyObject> getList() { return Arrays.asList(toJavaArray()); }
/** * @deprecated RubyArray implements List, use it directly * @return a read-only copy of this list */ public final List<IRubyObject> getList() { return Arrays.asList(toJavaArray()); }
@JIT public static IRubyObject[] singleBlockArgToArray(IRubyObject value) { IRubyObject[] args; if (value instanceof RubyArray) { args = value.convertToArray().toJavaArray(); } else { args = new IRubyObject[] { value }; } return args; }
@JIT public static IRubyObject[] singleBlockArgToArray(IRubyObject value) { IRubyObject[] args; if (value instanceof RubyArray) { args = value.convertToArray().toJavaArray(); } else { args = new IRubyObject[] { value }; } return args; }
@JRubyMethod(required = 4, visibility = PRIVATE) public static IRubyObject _exec_internal(ThreadContext context, IRubyObject recv, IRubyObject[] args) { IRubyObject env = args[0]; IRubyObject prog = args[1]; IRubyObject options = args[2]; RubyArray cmdArgs = (RubyArray) args[3]; if (options instanceof RubyHash) checkExecOptions(context, (RubyHash) options); return execCommon(context, env, prog, options, cmdArgs.toJavaArray()); }
private static IRubyObject inspectPuts(ThreadContext context, IRubyObject maybeIO, RubyArray array) { try { context.runtime.registerInspecting(array); return putsArray(context, maybeIO, array.toJavaArray()); } finally { context.runtime.unregisterInspecting(array); } }
private static IRubyObject inspectPuts(ThreadContext context, IRubyObject maybeIO, RubyArray array) { Ruby runtime = context.runtime; try { runtime.registerInspecting(array); return puts(context, maybeIO, array.toJavaArray()); } finally { runtime.unregisterInspecting(array); } }
private static IRubyObject inspectPuts(ThreadContext context, IRubyObject maybeIO, RubyArray array) { Ruby runtime = context.runtime; try { runtime.registerInspecting(array); return puts(context, maybeIO, array.toJavaArray()); } finally { runtime.unregisterInspecting(array); } }
private IRubyObject yieldInner(ThreadContext context, RubyArray array, Block blockArg) { if (array.isEmpty()) { throw context.runtime.newArgumentError("no receiver given"); } final IRubyObject self = array.shift(context); return site.call(context, self, self, array.toJavaArray(), blockArg); }
private IRubyObject[] toAry(ThreadContext context, IRubyObject value) { final IRubyObject ary = Helpers.aryToAry(context, value); if (ary == context.nil) return new IRubyObject[] { value }; if (ary instanceof RubyArray) return ((RubyArray) ary).toJavaArray(); throw context.runtime.newTypeError(value.getType().getName() + "#to_ary should return Array"); }
private IRubyObject yieldInner(ThreadContext context, RubyArray array, Block block) { if (array.isEmpty()) { throw context.runtime.newArgumentError("no receiver given"); } IRubyObject self = array.shift(context); return site.call(context, self, self, array.toJavaArray(), block); }
public static IRubyObject newThread(Ruby runtime, long fn, IRubyObject args_ary) { RubyProc proc = (RubyProc) newProc(runtime, fn); IRubyObject[] args = (args_ary instanceof RubyArray) ? ((RubyArray)args_ary).toJavaArray() : new IRubyObject[] {args_ary}; return RubyThread.newInstance(runtime.getThread(), args, proc.getBlock()); }
@Override public IRubyObject yield(ThreadContext context, IRubyObject value, IRubyObject self, RubyModule klass, boolean argIsArray, Binding binding, Type type) { // Unwrap the array arg IRubyObject[] args; if (type == Block.Type.LAMBDA) { args = (value == null) ? IRubyObject.NULL_ARRAY : (argIsArray ? ((RubyArray)value).toJavaArray() : new IRubyObject[] { value }); arity().checkArity(context.runtime, args); } else { args = (value == null) ? IRubyObject.NULL_ARRAY : convertValueIntoArgArray(context, value, false, argIsArray); } return commonYieldPath(context, args, self, klass, binding, type, Block.NULL_BLOCK); }
@Override public IRubyObject yield(ThreadContext context, IRubyObject value, IRubyObject self, RubyModule klass, boolean argIsArray, Binding binding, Type type) { // Unwrap the array arg IRubyObject[] args; if (type == Block.Type.LAMBDA) { args = (value == null) ? IRubyObject.NULL_ARRAY : (argIsArray ? ((RubyArray)value).toJavaArray() : new IRubyObject[] { value }); arity().checkArity(context.runtime, args); } else { args = (value == null) ? IRubyObject.NULL_ARRAY : convertValueIntoArgArray(context, value, false, argIsArray); } return commonYieldPath(context, args, self, klass, binding, type, Block.NULL_BLOCK); }
public static IRubyObject newThread(Ruby runtime, long fn, IRubyObject args_ary) { RubyProc proc = (RubyProc) newProc(runtime, fn); IRubyObject[] args = (args_ary instanceof RubyArray) ? ((RubyArray)args_ary).toJavaArray() : new IRubyObject[] {args_ary}; return RubyThread.newInstance(runtime.getThread(), args, proc.getBlock()); }
public static IRubyObject[] toAry(ThreadContext context, IRubyObject[] args) { IRubyObject ary; if (args.length == 1 && (ary = Helpers.aryOrToAry(context, args[0])) != context.nil) { if (ary instanceof RubyArray) { args = ((RubyArray) ary).toJavaArray(); } else { throw context.runtime.newTypeError(args[0].getType().getName() + "#to_ary should return Array"); } } return args; }
private IRubyObject inspectPuts(ThreadContext context, RubyArray array) { try { getRuntime().registerInspecting(array); return puts(context, array.toJavaArray()); } finally { getRuntime().unregisterInspecting(array); } }
private IRubyObject selfAssign(Ruby runtime, ThreadContext context, IRubyObject self, IRubyObject value, Block block, boolean checkArity) { IRubyObject receiver = receiverNode.interpret(runtime, context, self, block); if (argsNode == null) { // attribute set. Helpers.invoke(context, receiver, name, value); } else { // element set RubyArray args = (RubyArray) argsNode.interpret(runtime, context, self, block); args.append(value); Helpers.invoke(context, receiver, name, args.toJavaArray()); } return runtime.getNil(); }
@Override public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject arg, Block block) { if (!(arg instanceof RubyClass)) { throw context.runtime.newTypeError("append_features called with non-class"); } RubyClass target = (RubyClass)arg; RubyArray javaInterfaceMods = (RubyArray)self.getInstanceVariables().getInstanceVariable("@java_interface_mods"); target.include(javaInterfaceMods.toJavaArray()); return Helpers.invokeAs(context, clazz.getSuperClass(), self, name, arg, block); } });