Package org.jruby.runtime

Examples of org.jruby.runtime.Arity


            return getMetaClass().isMethodBound(name, false);
        } else if (!method.isUndefined()) {
            // 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 {

            }

            return method.call(context, this, metaClass, "respond_to?", runtime.newSymbol(name), runtime.newBoolean(true)).isTrue();
View Full Code Here


       
        Class<?>[] params = method.getParameterTypes();
        this.needsBlock = params.length > 0 && params[params.length - 1] == Block.class;
        this.isStatic = Modifier.isStatic(method.getModifiers());
       
        Arity arity = Arity.fromAnnotation(annotation, params, this.isStatic);
        setArity(arity);

        this.required = arity.getValue() >= 0 ? arity.getValue() : Math.abs(arity.getValue())-1;
        this.optional = annotation.optional();
        this.rest = annotation.rest();
       
        this.needsThreadContext = params.length > 0 && params[0] == ThreadContext.class;
        this.argsAsIs = ! isStatic && optional == 0 && !rest && !needsBlock && !needsThreadContext;
View Full Code Here

        StaticScope scope = block.getBody().getStaticScope();

        // 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());
        }

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

TOP

Related Classes of org.jruby.runtime.Arity

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.