Package org.jruby.java.dispatch
Class CallableSelector
java.lang.Object
org.jruby.java.dispatch.CallableSelector
Method selection logic for calling from Ruby to Java.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static interfacestatic interfaceA cache of "callables" based on method signature hash.private static interface -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final CallableSelector.Matcherprivate static final CallableSelector.CallableAcceptorprivate static final CallableSelector.CallableAcceptorprivate static final CallableSelector.CallableAcceptorprivate static final CallableSelector.Matcherprivate static final CallableSelector.CallableAcceptorprivate static final CallableSelector.Matcherprivate static final CallableSelector.Matcher -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static intprivate static intargsHashCode(IRubyObject[] args) private static intargsHashCode(IRubyObject a0, IRubyObject a1) private static intargsHashCode(IRubyObject a0, IRubyObject a1, IRubyObject a2) private static intargsHashCode(IRubyObject a0, IRubyObject a1, IRubyObject a2, IRubyObject a3) private static booleanassignable(Class<?> type, IRubyObject arg) private static booleanassignableAndPrimitivable(ParameterTypes paramTypes, IRubyObject... args) private static booleanassignableAndPrimitivableWithVarargs(ParameterTypes paramTypes, IRubyObject... args) private static booleanassignableOrDuckable(ParameterTypes paramTypes, IRubyObject... args) private static intcalcExactnessScore(ParameterTypes callable, IRubyObject[] args) private static intcalcTypePreference(Class<?> type, IRubyObject arg) private static booleanduckable(Class<?> type, IRubyObject arg) private static booleanexactMatch(ParameterTypes paramTypes, IRubyObject... args) private static <T extends ParameterTypes>
TfindCallable(T[] callables, CallableSelector.CallableAcceptor acceptor, IRubyObject[] args) private static <T extends ParameterTypes>
List<T>findCallableCandidates(T[] callables, IRubyObject[] args) private static <T extends ParameterTypes>
TfindMatchingCallableForArgs(Ruby runtime, T[] methods, IRubyObject... args) private static <T extends ParameterTypes>
TfindMatchingCallableForArgsFallback(Ruby runtime, T[] methods, IRubyObject... args) private static Class<?>getJavaClass(IRubyObject arg) private static intprivate static intstatic JavaCallablematchingCallableArityFour(Ruby runtime, Map cache, JavaCallable[] methods, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2, IRubyObject arg3) Deprecated.static <T extends ParameterTypes>
TmatchingCallableArityFour(Ruby runtime, CallableSelector.CallableCache<T> cache, T[] methods, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2, IRubyObject arg3) static <T extends JavaCallable>
TmatchingCallableArityFour(Ruby runtime, RubyToJavaInvoker<T> invoker, T[] methods, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2, IRubyObject arg3) static JavaCallablematchingCallableArityN(Ruby runtime, Map cache, JavaCallable[] methods, IRubyObject[] args) Deprecated.static ParameterTypesmatchingCallableArityN(Ruby runtime, Map cache, ParameterTypes[] methods, IRubyObject[] args) Deprecated.static <T extends ParameterTypes>
TmatchingCallableArityN(Ruby runtime, CallableSelector.CallableCache<T> cache, T[] methods, IRubyObject[] args) static <T extends JavaCallable>
TmatchingCallableArityN(Ruby runtime, RubyToJavaInvoker<T> invoker, T[] methods, IRubyObject[] args) static JavaCallablematchingCallableArityOne(Ruby runtime, Map cache, JavaCallable[] methods, IRubyObject arg0) Deprecated.static <T extends ParameterTypes>
TmatchingCallableArityOne(Ruby runtime, CallableSelector.CallableCache<T> cache, T[] methods, IRubyObject arg0) static <T extends JavaCallable>
TmatchingCallableArityOne(Ruby runtime, RubyToJavaInvoker<T> invoker, T[] methods, IRubyObject arg0) static JavaCallablematchingCallableArityThree(Ruby runtime, Map cache, JavaCallable[] methods, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2) Deprecated.static <T extends ParameterTypes>
TmatchingCallableArityThree(Ruby runtime, CallableSelector.CallableCache<T> cache, T[] methods, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2) static <T extends JavaCallable>
TmatchingCallableArityThree(Ruby runtime, RubyToJavaInvoker<T> invoker, T[] methods, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2) static JavaCallablematchingCallableArityTwo(Ruby runtime, Map cache, JavaCallable[] methods, IRubyObject arg0, IRubyObject arg1) Deprecated.static <T extends ParameterTypes>
TmatchingCallableArityTwo(Ruby runtime, CallableSelector.CallableCache<T> cache, T[] methods, IRubyObject arg0, IRubyObject arg1) static <T extends JavaCallable>
TmatchingCallableArityTwo(Ruby runtime, RubyToJavaInvoker<T> invoker, T[] methods, IRubyObject arg0, IRubyObject arg1) static <T extends JavaCallable>
TmatchingCallableArityZero(Ruby runtime, RubyToJavaInvoker<T> invoker, T[] methods) private static BooleanmoreSpecificTypes(Class[] msTypes, Class[] cTypes, boolean lastArgProc) static <T extends ParameterTypes>
IntHashMap<T>Deprecated.private static booleanprimitivable(Class<?> type, IRubyObject arg) This method checks whether an argument can be *directly* converted into the target primitive, i.e.private static intprocArityValue(IRubyObject proc)
-
Field Details
-
Exact
-
AssignableAndPrimitivable
-
AssignableOrDuckable
-
AssignableAndPrimitivableWithVarargs
-
EXACT
-
ASSIGNABLE
-
PRIMITIVABLE
-
DUCKABLE
-
-
Constructor Details
-
CallableSelector
private CallableSelector()
-
-
Method Details
-
matchingCallableArityN
public static <T extends ParameterTypes> T matchingCallableArityN(Ruby runtime, CallableSelector.CallableCache<T> cache, T[] methods, IRubyObject[] args) -
matchingCallableArityOne
public static <T extends ParameterTypes> T matchingCallableArityOne(Ruby runtime, CallableSelector.CallableCache<T> cache, T[] methods, IRubyObject arg0) -
matchingCallableArityTwo
public static <T extends ParameterTypes> T matchingCallableArityTwo(Ruby runtime, CallableSelector.CallableCache<T> cache, T[] methods, IRubyObject arg0, IRubyObject arg1) -
matchingCallableArityThree
public static <T extends ParameterTypes> T matchingCallableArityThree(Ruby runtime, CallableSelector.CallableCache<T> cache, T[] methods, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2) -
matchingCallableArityFour
public static <T extends ParameterTypes> T matchingCallableArityFour(Ruby runtime, CallableSelector.CallableCache<T> cache, T[] methods, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2, IRubyObject arg3) -
matchingCallableArityN
public static <T extends JavaCallable> T matchingCallableArityN(Ruby runtime, RubyToJavaInvoker<T> invoker, T[] methods, IRubyObject[] args) -
matchingCallableArityZero
public static <T extends JavaCallable> T matchingCallableArityZero(Ruby runtime, RubyToJavaInvoker<T> invoker, T[] methods) -
matchingCallableArityOne
public static <T extends JavaCallable> T matchingCallableArityOne(Ruby runtime, RubyToJavaInvoker<T> invoker, T[] methods, IRubyObject arg0) -
matchingCallableArityTwo
public static <T extends JavaCallable> T matchingCallableArityTwo(Ruby runtime, RubyToJavaInvoker<T> invoker, T[] methods, IRubyObject arg0, IRubyObject arg1) -
matchingCallableArityThree
public static <T extends JavaCallable> T matchingCallableArityThree(Ruby runtime, RubyToJavaInvoker<T> invoker, T[] methods, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2) -
matchingCallableArityFour
public static <T extends JavaCallable> T matchingCallableArityFour(Ruby runtime, RubyToJavaInvoker<T> invoker, T[] methods, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2, IRubyObject arg3) -
findMatchingCallableForArgs
private static <T extends ParameterTypes> T findMatchingCallableForArgs(Ruby runtime, T[] methods, IRubyObject... args) -
moreSpecificTypes
-
findMatchingCallableForArgsFallback
private static <T extends ParameterTypes> T findMatchingCallableForArgsFallback(Ruby runtime, T[] methods, IRubyObject... args) -
findCallable
private static <T extends ParameterTypes> T findCallable(T[] callables, CallableSelector.CallableAcceptor acceptor, IRubyObject[] args) -
findCallableCandidates
private static <T extends ParameterTypes> List<T> findCallableCandidates(T[] callables, IRubyObject[] args) -
calcExactnessScore
-
exactMatch
-
assignableAndPrimitivable
-
assignableOrDuckable
-
assignableAndPrimitivableWithVarargs
private static boolean assignableAndPrimitivableWithVarargs(ParameterTypes paramTypes, IRubyObject... args) -
assignable
-
primitivable
This method checks whether an argument can be *directly* converted into the target primitive, i.e. without changing from integral to floating-point.- Parameters:
type- The target typearg- The argument to convert- Returns:
- Whether the argument can be directly converted to the target primitive type
-
calcTypePreference
-
duckable
-
argsHashCode
-
argsHashCode
-
argsHashCode
-
argsHashCode
-
argsHashCode
-
javaClassHashCode
-
javaClassOrProcHashCode
-
procArityValue
-
getJavaClass
-
newCallableCache
Deprecated.Internal helper to allocate a callable map to cache argument method matches.- Type Parameters:
T- the callable type- Returns:
- cache usable with
CallableSelector
-
matchingCallableArityN
@Deprecated public static ParameterTypes matchingCallableArityN(Ruby runtime, Map cache, ParameterTypes[] methods, IRubyObject[] args) Deprecated. -
matchingCallableArityN
@Deprecated public static JavaCallable matchingCallableArityN(Ruby runtime, Map cache, JavaCallable[] methods, IRubyObject[] args) Deprecated. -
matchingCallableArityOne
@Deprecated public static JavaCallable matchingCallableArityOne(Ruby runtime, Map cache, JavaCallable[] methods, IRubyObject arg0) Deprecated. -
matchingCallableArityTwo
@Deprecated public static JavaCallable matchingCallableArityTwo(Ruby runtime, Map cache, JavaCallable[] methods, IRubyObject arg0, IRubyObject arg1) Deprecated. -
matchingCallableArityThree
@Deprecated public static JavaCallable matchingCallableArityThree(Ruby runtime, Map cache, JavaCallable[] methods, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2) Deprecated. -
matchingCallableArityFour
@Deprecated public static JavaCallable matchingCallableArityFour(Ruby runtime, Map cache, JavaCallable[] methods, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2, IRubyObject arg3) Deprecated.
-