Examples of ParameterTypes


Examples of org.codehaus.groovy.reflection.ParameterTypes

        int closestDist = -1;
        final int len = methods.size();
        for (int i = 0; i != len; ++i) {
            final Object[] data = methods.getArray();
            Object method = data[i];
            final ParameterTypes pt = (ParameterTypes) method;
            CachedClass[] paramTypes = pt.getParameterTypes();
            int paramLength = paramTypes.length;
            if (paramLength == 0 || paramLength > 2) continue;

            CachedClass theType = paramTypes[0];
            if (theType.isPrimitive) continue;

            if (paramLength == 2) {
                if (!pt.isVargsMethod(ARRAY_WITH_NULL)) continue;
                if (closestClass == null) {
                    closestVargsClass = paramTypes[1];
                    closestClass = theType;
                    answer = method;
                } else if (closestClass.getTheClass() == theType.getTheClass()) {
View Full Code Here

Examples of org.codehaus.groovy.reflection.ParameterTypes

        long matchesDistance = -1;
        LinkedList matches = new LinkedList();
        for (Iterator iter = matchingMethods.iterator(); iter.hasNext();) {
            Object method = iter.next();
            ParameterTypes paramTypes = (ParameterTypes) method;
            long dist = MetaClassHelper.calculateParameterDistance(arguments, paramTypes);
            if (dist == 0) return method;
            if (matches.size() == 0) {
                matches.add(method);
                matchesDistance = dist;
View Full Code Here

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

Examples of org.jruby.javasupport.ParameterTypes

        }
        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

Examples of org.jruby.javasupport.ParameterTypes

        }
        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

Examples of org.jruby.javasupport.ParameterTypes

       
        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

Examples of org.jruby.javasupport.ParameterTypes

* 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

Examples of org.jruby.javasupport.ParameterTypes

    }

    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

Examples of org.jruby.javasupport.ParameterTypes

        }
        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

Examples of org.jruby.javasupport.ParameterTypes

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