Package org.jruby

Examples of org.jruby.RubyArray$RubyArrayConversionIterator


                allArgs.add(args[i]);
            }

            // only set in scope if named
            if (restArg >= 0) {
                RubyArray array = runtime.newArray(args.length - expectedArgsCount);
                for (int i = expectedArgsCount; i < args.length; i++) {
                    array.append(args[i]);
                }

                context.getCurrentScope().setValue(restArg, array, 0);
            }
        }
View Full Code Here


            return requiredArgsCount;
        }
    }
    private void interpretRestArg(ThreadContext context, Ruby runtime, IRubyObject[] args, int givenArgsCount) {
        if (restArg >= 0) {
            RubyArray array = RubyArray.newArrayNoCopy(runtime, args, givenArgsCount);
            context.getCurrentScope().setValue(restArg, array, 0);
        }
    }
View Full Code Here

       
        if (!fillValue.isNil()) {
            fillJavaObject = converter.convert(context, fillValue);
        }
       
        RubyArray array = null;
        int rubyLength;
        if (rubyArray instanceof RubyArray) {
            array = (RubyArray)rubyArray;
            rubyLength = ((RubyArray)rubyArray).getLength();
        } else {
            rubyLength = 0;
            fillJavaObject = converter.convert(context, rubyArray);
        }
       
        int i = 0;
        for (; i < rubyLength && i < javaLength; i++) {
            javaArrayJavaObj.setWithExceptionHandling(i, converter.convert(context, array.entry(i)));
        }
       
        if (i < javaLength && fillJavaObject != null) {
            javaArrayJavaObj.fillWithExceptionHandling(i, javaLength, fillJavaObject);
        }
View Full Code Here

   
    @JRubyMethod
    public static IRubyObject copy_data_simple(
            ThreadContext context, IRubyObject from, IRubyObject to) {
        JavaArray javaArray = (JavaArray)to.dataGetStruct();
        RubyArray rubyArray = (RubyArray)from;
       
        copyDataToJavaArray(context, rubyArray, javaArray);
       
        return to;
    }
View Full Code Here

    public static IRubyObject dimensions(ThreadContext context, IRubyObject maybeArray) {
        Ruby runtime = context.getRuntime();
        if (!(maybeArray instanceof RubyArray)) {
            return runtime.newEmptyArray();
        }
        RubyArray rubyArray = (RubyArray)maybeArray;
        RubyArray dims = runtime.newEmptyArray();
       
        return dimsRecurse(context, rubyArray, dims, 0);
    }
View Full Code Here

        if (!(maybeArray instanceof RubyArray)) {
            return runtime.newEmptyArray();
        }
        assert dims instanceof RubyArray;
       
        RubyArray rubyArray = (RubyArray)maybeArray;
       
        return dimsRecurse(context, rubyArray, (RubyArray)dims, 0);
    }
View Full Code Here

            return runtime.newEmptyArray();
        }
        assert dims instanceof RubyArray;
        assert index instanceof RubyFixnum;
       
        RubyArray rubyArray = (RubyArray)maybeArray;
       
        return dimsRecurse(context, rubyArray, (RubyArray)dims, (int)((RubyFixnum)index).getLongValue());
    }
View Full Code Here

            ArrayNode iVisited2 = (ArrayNode) getValueNode();
            return ASTInterpreter.multipleAsgnArrayNode(runtime, context, this, iVisited2, self, aBlock);
        }
        case SPLATNODE: {
            SplatNode splatNode = (SplatNode) getValueNode();
            RubyArray rubyArray = RuntimeHelpers.splatValue(splatNode.getValue().interpret(runtime, context, self, aBlock));
            return AssignmentVisitor.multiAssign(runtime, context, self, this, rubyArray, false);
        }
        default:
            IRubyObject value = getValueNode().interpret(runtime, context, self, aBlock);
View Full Code Here

            // rest arg must be splatted
            IRubyObject restArg = getValue(staticScope.getRestArg(), 0);
            assert restArg != null;
           
            // FIXME: not very efficient
            RubyArray splattedArgs = RuntimeHelpers.splatValue(restArg);           
            IRubyObject[] argValues = new IRubyObject[totalArgs + splattedArgs.size()];
            System.arraycopy(splattedArgs.toJavaArray(), 0, argValues, totalArgs, splattedArgs.size());
            switch (totalArgs) {
            case 4:
                argValues[3] = variableValueThree;
            case 3:
                argValues[2] = variableValueTwo;
View Full Code Here

            // rest arg must be splatted
            IRubyObject restArg = getValue(staticScope.getRestArg(), 0);
            assert restArg != null;
           
            // FIXME: not very efficient
            RubyArray splattedArgs = RuntimeHelpers.splatValue(restArg);           
            IRubyObject[] argValues = new IRubyObject[totalArgs + splattedArgs.size()];
            System.arraycopy(splattedArgs.toJavaArray(), 0, argValues, totalArgs, splattedArgs.size());
            switch (totalArgs) {
            case 2:
                argValues[1] = variableValueOne;
            case 1:
                argValues[0] = variableValueZero;
View Full Code Here

TOP

Related Classes of org.jruby.RubyArray$RubyArrayConversionIterator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.