Package org.jruby.javasupport

Examples of org.jruby.javasupport.ParameterTypes


* Method selection logic for calling from Ruby to Java.
*/
public class CallableSelector {
    public static ParameterTypes matchingCallableArityN(Map cache, ParameterTypes[] methods, IRubyObject[] args, int argsLength) {
        int signatureCode = argsHashCode(args);
        ParameterTypes method = (ParameterTypes)cache.get(signatureCode);
        if (method == null) {
            method = findMatchingCallableForArgs(cache, signatureCode, methods, args);
        }
        return method;
    }
View Full Code Here


        }
        return method;
    }

    private static ParameterTypes findMatchingCallableForArgs(Map cache, int signatureCode, ParameterTypes[] methods, IRubyObject... args) {
        ParameterTypes method = null;

        // try the new way first
        List<ParameterTypes> newFinds = findCallable(methods, args);
        if (newFinds.size() > 0) {
            // new way found one, so let's go with that
View Full Code Here

        }
        args[0].getRuntime().getWarnings().warn(builder.toString());
    }

    private static ParameterTypes findCallable(ParameterTypes[] callables, CallableAcceptor acceptor, IRubyObject... args) {
        ParameterTypes bestCallable = null;
        int bestScore = -1;
        for (int k = 0; k < callables.length; k++) {
            ParameterTypes callable = callables[k];

            if (acceptor.accept(callable, args)) {
                int currentScore = getExactnessScore(callable, args);
                if (currentScore > bestScore) {
                    bestCallable = callable;
View Full Code Here

       
        for (int currentArg = 0; currentArg < args.length; currentArg++) {
            retainedCallables.clear();
            for (Matcher matcher : MATCH_SEQUENCE) {
                for (Iterator<ParameterTypes> callableIter = incomingCallables.iterator(); callableIter.hasNext();) {
                    ParameterTypes callable = callableIter.next();
                    Class[] types = callable.getParameterTypes();

                    if (matcher.match(types[currentArg], args[currentArg])) {
                        callableIter.remove();
                        retainedCallables.add(callable);
                    }
View Full Code Here

* Method selection logic for calling from Ruby to Java.
*/
public class CallableSelector {
    public static ParameterTypes matchingCallableArityN(Ruby runtime, Map cache, ParameterTypes[] methods, IRubyObject[] args, int argsLength) {
        int signatureCode = argsHashCode(args);
        ParameterTypes method = (ParameterTypes)cache.get(signatureCode);
        if (method == null) {
            method = findMatchingCallableForArgs(runtime, cache, signatureCode, methods, args);
        }
        return method;
    }
View Full Code Here

    }

    private static final boolean DEBUG = true;

    private static ParameterTypes findMatchingCallableForArgs(Ruby runtime, Map cache, int signatureCode, ParameterTypes[] methods, IRubyObject... args) {
        ParameterTypes method = null;

        // try the new way first
        List<ParameterTypes> newFinds = findCallable(methods, args);
        if (newFinds.size() > 0) {
            // new way found one, so let's go with that
            if (newFinds.size() == 1) {
                method = newFinds.get(0);
            } else {
                // narrow to most specific version (or first version, if none are more specific
                ParameterTypes mostSpecific = null;
                Class[] msTypes = null;
                boolean ambiguous = false;
                OUTER: for (ParameterTypes candidate : newFinds) {
                    if (mostSpecific == null) {
                        mostSpecific = candidate;
                        msTypes = mostSpecific.getParameterTypes();
                        continue;
                    }

                    Class[] cTypes = candidate.getParameterTypes();
View Full Code Here

        }
        args[0].getRuntime().getWarnings().warn(builder.toString());
    }

    private static ParameterTypes findCallable(ParameterTypes[] callables, CallableAcceptor acceptor, IRubyObject... args) {
        ParameterTypes bestCallable = null;
        int bestScore = -1;
        for (int k = 0; k < callables.length; k++) {
            ParameterTypes callable = callables[k];

            if (acceptor.accept(callable, args)) {
                int currentScore = getExactnessScore(callable, args);
                if (currentScore > bestScore) {
                    bestCallable = callable;
View Full Code Here

       
        for (int currentArg = 0; currentArg < args.length; currentArg++) {
            retainedCallables.clear();
            for (Matcher matcher : MATCH_SEQUENCE) {
                for (Iterator<ParameterTypes> callableIter = incomingCallables.iterator(); callableIter.hasNext();) {
                    ParameterTypes callable = callableIter.next();
                    Class[] types = callable.getParameterTypes();

                    if (matcher.match(types[currentArg], args[currentArg])) {
                        callableIter.remove();
                        retainedCallables.add(callable);
                    }
View Full Code Here

TOP

Related Classes of org.jruby.javasupport.ParameterTypes

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.