Examples of RubyArray


Examples of org.jruby.RubyArray

    }
   
    @JRubyMethod(name = { "create_invoker", "createInvoker" }, required = 5)
    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

Examples of org.jruby.RubyArray

    }
   
    @JRubyMethod(name = { "create_callback", "createCallback" })
    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

Examples of org.jruby.RubyArray

                runtime.fastGetModule("YAML").fastGetConstant("PrivateType"),
                "new", runtime.newString(node.getTag()),(IRubyObject)val);
    }

    public Object constructRubySequence(final Node node) {
        final RubyArray arr = runtime.newArray();
        List l = (List)super.constructSequence(node);
        doRecursionFix(node, arr);
        int i = 0;
        for(Iterator iter = l.iterator();iter.hasNext();i++) {
            Object oo = iter.next();
            if(oo instanceof LinkNode) {
                arr.append(runtime.getNil());
                final IRubyObject ix = runtime.newFixnum(i);
                addFixer((Node)(((LinkNode)oo).getValue()), new RecursiveFixer() {
                        public void replace(Node node, Object real) {
                            arr.aset(ix, (IRubyObject)real);
                        }
                    });
            } else {
                arr.append((IRubyObject)oo);
            }
        }
        return arr;
    }
View Full Code Here

Examples of org.jruby.RubyArray

        return SafeConstructorImpl.constructYamlBool(ctor,node) == Boolean.TRUE ? ((JRubyConstructor)ctor).runtime.getTrue() : ((JRubyConstructor)ctor).runtime.getFalse();
    }

    public static Object constructYamlOmap(final Constructor ctor, final Node node) {
        Ruby runtime = ((JRubyConstructor)ctor).runtime;
        RubyArray arr = (RubyArray)(runtime.fastGetModule("YAML").fastGetConstant("Omap").callMethod(runtime.getCurrentContext(),"new"));
        List l = (List)ctor.constructSequence(node);
        ctor.doRecursionFix(node, arr);
        for(Iterator iter = l.iterator();iter.hasNext();) {
            IRubyObject v = (IRubyObject)iter.next();
            if(v instanceof RubyHash) {
                arr.concat(((RubyHash)v).to_a());
            } else {
                throw new ConstructorException(null,"Invalid !omap entry: " + l,null);
            }
        }
        return arr;
View Full Code Here

Examples of org.jruby.RubyArray

            struct_type = RubyStruct.newInstance(runtime.fastGetModule("Struct"),params,Block.NULL_BLOCK);
        } else {
            struct_type = (RubyClass)sClass;
        }
        IRubyObject st = struct_type.callMethod(runtime.getCurrentContext(),"new");
        RubyArray members = RubyStruct.members(struct_type,Block.NULL_BLOCK);
        for(int i=0,j=members.size();i<j;i++) {
            IRubyObject m = members.eltInternal(i);
            st.callMethod(runtime.getCurrentContext(), m.toString() + "=", (IRubyObject)val.get(m));
        }
        for(Iterator iter = props.entrySet().iterator();iter.hasNext();) {
            Map.Entry em = (Map.Entry)iter.next();
            ((RubyObject)st).instance_variable_set((IRubyObject)em.getKey(),(IRubyObject)em.getValue());
View Full Code Here

Examples of org.jruby.RubyArray

        }

        @JRubyMethod(name = "to_a")
        public static IRubyObject s_hist_to_a(IRubyObject recv) throws Exception {
            ConsoleHolder holder = getHolder(recv.getRuntime());
            RubyArray histList = recv.getRuntime().newArray();
            for (Iterator i = holder.history.getHistoryList().iterator(); i.hasNext();) {
                histList.append(recv.getRuntime().newString((String) i.next()));
            }
            return histList;
        }
View Full Code Here

Examples of org.jruby.RubyArray

                if (proxyClass == null || proxyClass.isNil()) {
                    proxyClass = JavaProxyClass.get_with_class(self, self.getMetaClass());
                    self.getMetaClass().getInstanceVariables().fastSetInstanceVariable("@java_proxy_class", proxyClass);
                }
                JavaProxyClass realProxyClass = (JavaProxyClass)proxyClass;
                RubyArray constructors = realProxyClass.constructors();
                ArrayList<JavaProxyConstructor> forArity = new ArrayList<JavaProxyConstructor>();
                for (int i = 0; i < constructors.size(); i++) {
                    JavaProxyConstructor constructor = (JavaProxyConstructor)constructors.eltInternal(i);
                    if (constructor.getParameterTypes().length == args.length) {
                        forArity.add(constructor);
                    }
                }
                if (forArity.size() == 0) {
View Full Code Here

Examples of org.jruby.RubyArray

    public static IRubyObject aValueSplat(Ruby runtime, IRubyObject value) {
        if (!(value instanceof RubyArray) || ((RubyArray) value).length().getLongValue() == 0) {
            return runtime.getNil();
        }

        RubyArray array = (RubyArray) value;

        return array.getLength() == 1 ? array.first(IRubyObject.NULL_ARRAY) : array;
    }
View Full Code Here

Examples of org.jruby.RubyArray

    @Override
    public IRubyObject interpret(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock) {
        IRubyObject arg = getArgsNode().interpret(runtime, context, self, aBlock);
       
        if (arg instanceof RubyArray) {
            RubyArray nodes = (RubyArray) arg;
           
            switch (nodes.size()) {
                case 0:
                    return callAdapter.call(context, self, self);
                case 1:
                    return callAdapter.call(context, self, self, nodes.eltInternal(0));
                case 2:
                    return callAdapter.call(context, self, self, nodes.eltInternal(0), nodes.eltInternal(1));
                case 3:
                    return callAdapter.call(context, self, self, nodes.eltInternal(0), nodes.eltInternal(1), nodes.eltInternal(2));
                default:
                    return callAdapter.call(context, self, self, nodes.toJavaArrayMaybeUnsafe());
            }
        }
       
        return callAdapter.call(context, self, self, arg);
    }
View Full Code Here

Examples of org.jruby.RubyArray

    public IRubyObject interpret(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock) {
        IRubyObject arg = getArgsNode().interpret(runtime, context, self, aBlock);
        Block block = getBlock(context, self);
       
        if (arg instanceof RubyArray) {
            RubyArray nodes = (RubyArray) arg;
           
            switch (nodes.size()) {
                case 0:
                    return callAdapter.callIter(context, self, self, block);
                case 1:
                    return callAdapter.callIter(context, self, self, nodes.eltInternal(0), block);
                case 2:
                    return callAdapter.callIter(context, self, self, nodes.eltInternal(0), nodes.eltInternal(1), block);
                case 3:
                    return callAdapter.callIter(context, self, self, nodes.eltInternal(0), nodes.eltInternal(1), nodes.eltInternal(2), block);
                default:
                    return callAdapter.callIter(context, self, self, nodes.toJavaArrayMaybeUnsafe(), block);
            }
        }
       
        return callAdapter.callIter(context, self, self, arg, block);
    }
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.