Package org.jruby

Examples of org.jruby.RubyArray.entry()


            }
            RubyModule pathHelper = runtime.getClassFromPath("JRuby::PathHelper");
            RubyArray parts = (RubyArray) RuntimeHelpers.invoke(context, pathHelper, "smart_split_command", rawArgs);
            args = new String[parts.getLength()];
            for (int i = 0; i < parts.getLength(); i++) {
                args[i] = parts.entry(i).toString();
            }
        } else {
            args = new String[rawArgs.length];
            for (int i = 0; i < rawArgs.length; i++) {
                args[i] = rawArgs[i].toString();
View Full Code Here


        RubyArray arr = (RubyArray) arrParam;
        int count = arr.getLength();
        checkBounds(context, offset, count * 2);
        byte[] array = new byte[count];       
        for (int i = 0; i < array.length; ++i) {
            array[i] = Util.int8Value((IRubyObject) arr.entry(i));
        }
        getMemoryIO().put(getOffset(offset), array, 0, array.length);
        return this;
    }
    @JRubyMethod(name = { "get_array_of_int16", "get_array_of_short" }, required = 2)
View Full Code Here

        RubyArray arr = (RubyArray) arrParam;
        int count = arr.getLength();
        checkBounds(context, offset, count * 2);
        short[] array = new short[count];       
        for (int i = 0; i < array.length; ++i) {
            array[i] = Util.int16Value((IRubyObject) arr.entry(i));
        }
        getMemoryIO().put(getOffset(offset), array, 0, array.length);
        return this;
    }
    @JRubyMethod(name = { "get_array_of_int32", "get_array_of_int" }, required = 2)
View Full Code Here

        RubyArray arr = (RubyArray) arrParam;
        int count = arr.getLength();
        checkBounds(context, offset, count * 4);
        int[] array = new int[count];
        for (int i = 0; i < array.length; ++i) {
            array[i] = Util.int32Value((IRubyObject) arr.entry(i));
        }
        getMemoryIO().put(getOffset(offset), array, 0, array.length);
        return this;
    }
    @JRubyMethod(name = "get_array_of_long", required = 2)
View Full Code Here

        RubyArray arr = (RubyArray) arrParam;
        int count = arr.getLength();
        checkBounds(context, offset, count * 8);
        long[] array = new long[count];
        for (int i = 0; i < array.length; ++i) {
            array[i] = Util.int64Value((IRubyObject) arr.entry(i));
        }
        getMemoryIO().put(getOffset(offset), array, 0, array.length);
        return this;
    }
    @JRubyMethod(name = { "get_array_of_float32", "get_array_of_float" }, required = 2)
View Full Code Here

        RubyArray arr = (RubyArray) arrParam;
        int count = arr.getLength();
        checkBounds(context, offset, count * 4);
        float[] array = new float[count];
        for (int i = 0; i < array.length; ++i) {
            array[i] = Util.floatValue((IRubyObject) arr.entry(i));
        }
        getMemoryIO().put(getOffset(offset), array, 0, array.length);
        return this;
    }
    @JRubyMethod(name = { "get_array_of_float64", "get_array_of_double" }, required = 2)
View Full Code Here

        RubyArray arr = (RubyArray) arrParam;
        int count = arr.getLength();
        checkBounds(context, offset, count * 8);
        double[] array = new double[count];
        for (int i = 0; i < array.length; ++i) {
            array[i] = Util.doubleValue((IRubyObject) arr.entry(i));
        }
        getMemoryIO().put(getOffset(offset), array, 0, array.length);
        return this;
    }
    @JRubyMethod(name = "get_string")
View Full Code Here

    public IRubyObject createInvoker(ThreadContext context, IRubyObject[] args)
    {
        RubyArray paramTypes = (RubyArray) args[3];
        NativeParam[] nativeParamTypes = new NativeParam[paramTypes.size()];
        for (int i = 0; i < paramTypes.size(); ++i) {
            IRubyObject obj = (IRubyObject) paramTypes.entry(i);
            if (obj instanceof NativeParam) {
                nativeParamTypes[i] = (NativeParam) obj;
            } else if (obj instanceof RubyInteger) {
                nativeParamTypes[i] = NativeType.valueOf(Util.int32Value(obj));
            } else {
View Full Code Here

    public IRubyObject createCallback(ThreadContext context, IRubyObject returnType, IRubyObject _paramTypes)
    {
        RubyArray paramTypes = (RubyArray) _paramTypes;
        NativeType[] nativeParamTypes = new NativeType[paramTypes.size()];
        for (int i = 0; i < paramTypes.size(); ++i) {
            nativeParamTypes[i] = NativeType.valueOf(Util.int32Value((IRubyObject) paramTypes.entry(i)));
        }
        try {
            return createCallback(context.getRuntime(),
                    NativeType.valueOf(Util.int32Value(returnType)), nativeParamTypes);
        } catch (UnsatisfiedLinkError ex) {
View Full Code Here

    }

    private static void addEntries(ThreadContext context, ZipOutputStream zip, RubyHash entries) throws IOException {
        RubyArray keys = entries.keys().sort(context, Block.NULL_BLOCK);
        for (int i = 0; i < keys.getLength(); i++) {
            IRubyObject key = keys.entry(i);
            IRubyObject value = entries.op_aref(context, key);
            addEntry(context, zip, key.convertToString().getUnicodeValue(), value);
        }
    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.