public static JavaCallable matchingCallableArityTwo(Ruby runtime, Map cache, JavaCallable[] methods, IRubyObject arg0, IRubyObject arg1) { int signatureCode = argsHashCode(arg0, arg1); JavaCallable method = (JavaCallable)cache.get(signatureCode); if (method == null) { method = (JavaCallable)findMatchingCallableForArgs(runtime, cache, signatureCode, methods, arg0, arg1); } return method; }
private static <T extends ParameterTypes> T findMatchingCallableForArgsFallback(final Ruby runtime, final T[] methods, final IRubyObject... args) { T method = findCallable(methods, Exact, args); if (method == null) { method = findCallable(methods, AssignableAndPrimitivable, args); if (method == null) { method = findCallable(methods, AssignableOrDuckable, args); if (method == null) { method = findCallable(methods, AssignableOrDuckable, args); if (method == null) { method = findCallable(methods, AssignableAndPrimitivableWithVarargs, args); } } } } return method; }
private T matchVarArgsCallableArityFour(IRubyObject self, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2, IRubyObject arg3) { final T[] varArgsCallables = this.javaVarargsCallables; if ( varArgsCallables != null ) { T callable = CallableSelector.matchingCallableArityFour(runtime, this, varArgsCallables, arg0, arg1, arg2, arg3); if ( callable == null ) { throw newErrorDueArgumentTypeMismatch(self, varArgsCallables, arg0, arg1, arg2, arg3); } return callable; } return null; }
public static RaiseException argTypesDoNotMatch(Ruby runtime, IRubyObject receiver, JavaCallable[] methods, Object... args) { Class[] argTypes = new Class[args.length]; for (int i = 0; i < args.length; i++) { argTypes[i] = argClassTypeError(args[i]); } return argumentError(runtime.getCurrentContext(), methods, receiver, argTypes); }
private T matchVarArgsCallableArityN(IRubyObject self, IRubyObject[] args) { final T[] varArgsCallables = this.javaVarargsCallables; if ( varArgsCallables != null ) { T callable = CallableSelector.matchingCallableArityN(runtime, this, varArgsCallables, args); if ( callable == null ) { throw newErrorDueArgumentTypeMismatch(self, varArgsCallables, args); } return callable; } return null; }
private T matchVarArgsCallableArityOne(IRubyObject self, IRubyObject arg0) { final T[] varArgsCallables = this.javaVarargsCallables; if ( varArgsCallables != null ) { T callable = CallableSelector.matchingCallableArityOne(runtime, this, varArgsCallables, arg0); if ( callable == null ) { throw newErrorDueArgumentTypeMismatch(self, varArgsCallables, arg0); } return callable; } return null; }
protected JavaCallable findCallableArityThree(IRubyObject self, String name, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2) { JavaCallable callable; if ((callable = javaCallable) == null) { // TODO: varargs? JavaCallable[] callablesForArity = null; if (javaCallables.length <= 3 || (callablesForArity = javaCallables[3]) == null) { throw self.getRuntime().newArgumentError(3, javaCallables.length - 1); } callable = CallableSelector.matchingCallableArityThree(runtime, cache, callablesForArity, arg0, arg1, arg2); if (callable == null) { throw CallableSelector.argTypesDoNotMatch(self.getRuntime(), self, callablesForArity, arg0, arg1, arg2); } } else { if (callable.getParameterTypes().length != 3) { throw self.getRuntime().newArgumentError(3, callable.getParameterTypes().length); } } return callable; }
protected JavaCallable findCallableArityTwo(IRubyObject self, String name, IRubyObject arg0, IRubyObject arg1) { JavaCallable callable; if ((callable = javaCallable) == null) { // TODO: varargs? JavaCallable[] callablesForArity = null; if (javaCallables.length <= 2 || (callablesForArity = javaCallables[2]) == null) { throw self.getRuntime().newArgumentError(2, javaCallables.length - 1); } callable = CallableSelector.matchingCallableArityTwo(runtime, cache, callablesForArity, arg0, arg1); if (callable == null) { throw CallableSelector.argTypesDoNotMatch(self.getRuntime(), self, callablesForArity, arg0, arg1); } } else { if (callable.getParameterTypes().length != 2) { throw self.getRuntime().newArgumentError(2, callable.getParameterTypes().length); } } return callable; }
protected JavaCallable findCallableArityFour(IRubyObject self, String name, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2, IRubyObject arg3) { JavaCallable callable; if ((callable = javaCallable) == null) { // TODO: varargs? JavaCallable[] callablesForArity = null; if (javaCallables.length <= 4 || (callablesForArity = javaCallables[4]) == null) { throw self.getRuntime().newArgumentError(4, javaCallables.length - 1); } callable = CallableSelector.matchingCallableArityFour(runtime, cache, callablesForArity, arg0, arg1, arg2, arg3); if (callable == null) { throw CallableSelector.argTypesDoNotMatch(self.getRuntime(), self, callablesForArity, arg0, arg1, arg2, arg3); } } else { if (callable.getParameterTypes().length != 4) { throw self.getRuntime().newArgumentError(4, callable.getParameterTypes().length); } } return callable; } }
protected JavaCallable findCallableArityOne(IRubyObject self, String name, IRubyObject arg0) { JavaCallable callable; if ((callable = javaCallable) == null) { // TODO: varargs? JavaCallable[] callablesForArity = null; if (javaCallables.length <= 1 || (callablesForArity = javaCallables[1]) == null) { throw self.getRuntime().newArgumentError(1, javaCallables.length - 1); } callable = CallableSelector.matchingCallableArityOne(runtime, cache, callablesForArity, arg0); if (callable == null) { throw CallableSelector.argTypesDoNotMatch(self.getRuntime(), self, callablesForArity, arg0); } } else { if (callable.getParameterTypes().length != 1) { throw self.getRuntime().newArgumentError(1, callable.getParameterTypes().length); } } return callable; }
if (arity >= javaCallables.length || (callablesForArity = javaCallables[arity]) == null) { if (javaVarargsCallables != null) { callable = CallableSelector.matchingCallableArityN(runtime, cache, javaVarargsCallables, args, arity); if (callable == null) { throw CallableSelector.argTypesDoNotMatch(self.getRuntime(), self, javaVarargsCallables, (Object[])args); callable = CallableSelector.matchingCallableArityN(runtime, cache, callablesForArity, args, arity); if (callable == null && javaVarargsCallables != null) { callable = CallableSelector.matchingCallableArityN(runtime, cache, javaVarargsCallables, args, arity); if (callable == null) { throw CallableSelector.argTypesDoNotMatch(self.getRuntime(), self, javaVarargsCallables, (Object[])args); throw CallableSelector.argTypesDoNotMatch(self.getRuntime(), self, callablesForArity, (Object[])args);
private T matchVarArgsCallableArityThree(IRubyObject self, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2) { final T[] varArgsCallables = this.javaVarargsCallables; if ( varArgsCallables != null ) { T callable = CallableSelector.matchingCallableArityThree(runtime, this, varArgsCallables, arg0, arg1, arg2); if ( callable == null ) { throw newErrorDueArgumentTypeMismatch(self, varArgsCallables, arg0, arg1, arg2); } return callable; } return null; }
private T matchVarArgsCallableArityTwo(IRubyObject self, IRubyObject arg0, IRubyObject arg1) { final T[] varArgsCallables = this.javaVarargsCallables; if ( varArgsCallables != null ) { T callable = CallableSelector.matchingCallableArityTwo(runtime, this, varArgsCallables, arg0, arg1); if ( callable == null ) { throw newErrorDueArgumentTypeMismatch(self, varArgsCallables, arg0, arg1); } return callable; } return null; }
public static <T extends JavaCallable> T matchingCallableArityZero(Ruby runtime, RubyToJavaInvoker<T> invoker, T[] methods) { final int signatureCode = 0; T method = invoker.getSignature(signatureCode); if (method == null) { method = findMatchingCallableForArgs(runtime, methods); if (method != null) invoker.putSignature(signatureCode, method); } return method; }
Class argClass = argClass(arg); if (type.isPrimitive()) {
private T matchVarArgsCallableArityN(IRubyObject self, IRubyObject[] args) { final T[] varArgsCallables = this.javaVarargsCallables; if ( varArgsCallables != null ) { T callable = CallableSelector.matchingCallableArityN(runtime, this, varArgsCallables, args); if ( callable == null ) { throw newErrorDueArgumentTypeMismatch(self, varArgsCallables, args); } return callable; } return null; }
private T matchVarArgsCallableArityOne(IRubyObject self, IRubyObject arg0) { final T[] varArgsCallables = this.javaVarargsCallables; if ( varArgsCallables != null ) { T callable = CallableSelector.matchingCallableArityOne(runtime, this, varArgsCallables, arg0); if ( callable == null ) { throw newErrorDueArgumentTypeMismatch(self, varArgsCallables, arg0); } return callable; } return null; }
protected JavaCallable findCallableArityThree(IRubyObject self, String name, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2) { JavaCallable callable; if ((callable = javaCallable) == null) { // TODO: varargs? JavaCallable[] callablesForArity = null; if (javaCallables.length <= 3 || (callablesForArity = javaCallables[3]) == null) { throw self.getRuntime().newArgumentError(3, javaCallables.length - 1); } callable = CallableSelector.matchingCallableArityThree(runtime, cache, callablesForArity, arg0, arg1, arg2); if (callable == null) { throw CallableSelector.argTypesDoNotMatch(self.getRuntime(), self, callablesForArity, arg0, arg1, arg2); } } else { if (callable.getParameterTypes().length != 3) { throw self.getRuntime().newArgumentError(3, callable.getParameterTypes().length); } } return callable; }
protected JavaCallable findCallableArityTwo(IRubyObject self, String name, IRubyObject arg0, IRubyObject arg1) { JavaCallable callable; if ((callable = javaCallable) == null) { // TODO: varargs? JavaCallable[] callablesForArity = null; if (javaCallables.length <= 2 || (callablesForArity = javaCallables[2]) == null) { throw self.getRuntime().newArgumentError(2, javaCallables.length - 1); } callable = CallableSelector.matchingCallableArityTwo(runtime, cache, callablesForArity, arg0, arg1); if (callable == null) { throw CallableSelector.argTypesDoNotMatch(self.getRuntime(), self, callablesForArity, arg0, arg1); } } else { if (callable.getParameterTypes().length != 2) { throw self.getRuntime().newArgumentError(2, callable.getParameterTypes().length); } } return callable; }
protected JavaCallable findCallableArityFour(IRubyObject self, String name, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2, IRubyObject arg3) { JavaCallable callable; if ((callable = javaCallable) == null) { // TODO: varargs? JavaCallable[] callablesForArity = null; if (javaCallables.length <= 4 || (callablesForArity = javaCallables[4]) == null) { throw self.getRuntime().newArgumentError(4, javaCallables.length - 1); } callable = CallableSelector.matchingCallableArityFour(runtime, cache, callablesForArity, arg0, arg1, arg2, arg3); if (callable == null) { throw CallableSelector.argTypesDoNotMatch(self.getRuntime(), self, callablesForArity, arg0, arg1, arg2, arg3); } } else { if (callable.getParameterTypes().length != 4) { throw self.getRuntime().newArgumentError(4, callable.getParameterTypes().length); } } return callable; } }