Package org.jruby.runtime

Examples of org.jruby.runtime.Arity.required()


        // for zsupers in define_method (blech!) we tell the proc scope to act as the "argument" scope
        scope.setArgumentScope(true);

        Arity arity = block.arity();
        // just using required is broken...but no more broken than before zsuper refactoring
        scope.setRequiredArgs(arity.required());

        if(!arity.isFixed()) {
            scope.setRestArg(arity.required());
        }
View Full Code Here


        Arity arity = block.arity();
        // just using required is broken...but no more broken than before zsuper refactoring
        scope.setRequiredArgs(arity.required());

        if(!arity.isFixed()) {
            scope.setRestArg(arity.required());
        }

        return new ProcMethod(this, proc, visibility);
    }
View Full Code Here

        // for zsupers in define_method (blech!) we tell the proc scope to act as the "argument" scope
        scope.makeArgumentScope();

        Arity arity = block.arity();
        // just using required is broken...but no more broken than before zsuper refactoring
        scope.setRequiredArgs(arity.required());

        if(!arity.isFixed()) {
            scope.setRestArg(arity.required());
        }
View Full Code Here

        Arity arity = block.arity();
        // just using required is broken...but no more broken than before zsuper refactoring
        scope.setRequiredArgs(arity.required());

        if(!arity.isFixed()) {
            scope.setRestArg(arity.required());
        }

        return new ProcMethod(this, proc, visibility);
    }
View Full Code Here

        // for zsupers in define_method (blech!) we tell the proc scope to act as the "argument" scope
        scope.makeArgumentScope();

        Arity arity = block.arity();
        // just using required is broken...but no more broken than before zsuper refactoring
        scope.setRequiredArgs(arity.required());

        if(!arity.isFixed()) {
            scope.setRestArg(arity.required());
        }
View Full Code Here

        Arity arity = block.arity();
        // just using required is broken...but no more broken than before zsuper refactoring
        scope.setRequiredArgs(arity.required());

        if(!arity.isFixed()) {
            scope.setRestArg(arity.required());
        }

        return new ProcMethod(this, proc, visibility);
    }
View Full Code Here

   
    private IRubyObject[] prepareProcArgs(ThreadContext context, IRubyObject[] args) {
        Arity arity = block.arity();
       
        // for procs and blocks, single array passed to multi-arg must be spread
        if (arity != Arity.ONE_ARGUMENT && arity.required() != 0 &&
                (arity.isFixed() || arity != Arity.OPTIONAL) &&
                args.length == 1 && args[0].respondsTo("to_ary")) {
            args = args[0].convertToArray().toJavaArray();
        }
View Full Code Here

            args = args[0].convertToArray().toJavaArray();
        }

        if (arity.isFixed()) {
            List<IRubyObject> list = new ArrayList<IRubyObject>(Arrays.asList(args));
            int required = arity.required();
            if (required > args.length) {
                for (int i = args.length; i < required; i++) {
                    list.add(context.runtime.getNil());
                }
                args = list.toArray(args);
View Full Code Here

            // medium path, invoke user's respond_to? if defined

            // We have to check and enforce arity
            Arity arity = method.getArity();
            ThreadContext context = runtime.getCurrentContext();
            if (arity.isFixed() && arity.required() == 1) {
                return method.call(context, this, metaClass, "respond_to?", runtime.newSymbol(name)).isTrue();
            } else if (arity.isFixed() && arity.required() != 2) {
                throw runtime.newArgumentError("respond_to? must accept 1 or 2 arguments (requires " + arity.getValue() + ")");
            } else {
View Full Code Here

            // We have to check and enforce arity
            Arity arity = method.getArity();
            ThreadContext context = runtime.getCurrentContext();
            if (arity.isFixed() && arity.required() == 1) {
                return method.call(context, this, metaClass, "respond_to?", runtime.newSymbol(name)).isTrue();
            } else if (arity.isFixed() && arity.required() != 2) {
                throw runtime.newArgumentError("respond_to? must accept 1 or 2 arguments (requires " + arity.getValue() + ")");
            } else {

            }
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.