@Override public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject arg0) { if (javaVarargsCallables != null) return call(context, self, clazz, name, new IRubyObject[] {arg0}); JavaMethod method = (JavaMethod)findCallableArityOne(self, name, arg0); if (method.isVarArgs()) return call(context, self, clazz, name, new IRubyObject[] {arg0}); Object cArg0 = convertArg(arg0, method, 0); return method.invokeDirect(singleton, cArg0); }
@Override public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject[] args) { JavaMethod method = (JavaMethod) findCallable(self, name, args, args.length); return method.invokeDirect( context, singleton, convertArguments(method, args) ); }
@Override public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2, Block block) { if (block.isGiven()) { RubyProc proc = RubyProc.newProc(context.runtime, block, block.type); JavaMethod method = (JavaMethod)findCallableArityFour(self, name, arg0, arg1, arg2, proc); Object cArg0 = convertArg(arg0, method, 0); Object cArg1 = convertArg(arg1, method, 1); Object cArg2 = convertArg(arg2, method, 2); Object cArg3 = convertArg(proc, method, 3); return method.invokeDirect(singleton, cArg0, cArg1, cArg2, cArg3); } else { return call(context, self, clazz, name, arg0, arg1, arg2); } } }
@Override public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2) { if (javaVarargsCallables != null) return call(context, self, clazz, name, new IRubyObject[] {arg0, arg1, arg2}); JavaMethod method = (JavaMethod)findCallableArityThree(self, name, arg0, arg1, arg2); Object cArg0 = convertArg(arg0, method, 0); Object cArg1 = convertArg(arg1, method, 1); Object cArg2 = convertArg(arg2, method, 2); return method.invokeDirect(singleton, cArg0, cArg1, cArg2); }
@Override public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject arg0, IRubyObject arg1) { if (javaVarargsCallables != null) return call(context, self, clazz, name, new IRubyObject[] {arg0, arg1}); JavaMethod method = (JavaMethod)findCallableArityTwo(self, name, arg0, arg1); Object cArg0 = convertArg(arg0, method, 0); Object cArg1 = convertArg(arg1, method, 1); return method.invokeDirect(singleton, cArg0, cArg1); }
@Override public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject arg0, IRubyObject arg1) { if (javaVarargsCallables != null) return call(context, self, clazz, name, new IRubyObject[] {arg0, arg1}); JavaMethod method = (JavaMethod)findCallableArityTwo(self, name, arg0, arg1); final Class<?>[] paramTypes = method.getParameterTypes(); Object cArg0 = arg0.toJava(paramTypes[0]); Object cArg1 = arg1.toJava(paramTypes[1]); return method.invokeDirect(context, singleton, cArg0, cArg1); }
@Override public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject arg0) { if (javaVarargsCallables != null) return call(context, self, clazz, name, new IRubyObject[] {arg0}); JavaMethod method = (JavaMethod) findCallableArityOne(self, name, arg0); if (method.isVarArgs()) return call(context, self, clazz, name, new IRubyObject[] {arg0}); final Class<?>[] paramTypes = method.getParameterTypes(); Object cArg0 = arg0.toJava(paramTypes[0]); return method.invokeDirect(context, singleton, cArg0); }
@Override public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2) { if (javaVarargsCallables != null) return call(context, self, clazz, name, new IRubyObject[] {arg0, arg1, arg2}); JavaMethod method = (JavaMethod) findCallableArityThree(self, name, arg0, arg1, arg2); final Class<?>[] paramTypes = method.getParameterTypes(); Object cArg0 = arg0.toJava(paramTypes[0]); Object cArg1 = arg1.toJava(paramTypes[1]); Object cArg2 = arg2.toJava(paramTypes[2]); return method.invokeDirect(context, singleton, cArg0, cArg1, cArg2); }
@Override public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name) { if (javaVarargsCallables != null) return call(context, self, clazz, name, IRubyObject.NULL_ARRAY); JavaMethod method = (JavaMethod) findCallableArityZero(self, name); return method.invokeDirect(context, singleton); }
public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject[] args, Block block) { if (block.isGiven()) { int len = args.length; // too much array creation! Object[] convertedArgs = new Object[len + 1]; IRubyObject[] intermediate = new IRubyObject[len + 1]; System.arraycopy(args, 0, intermediate, 0, len); intermediate[len] = RubyProc.newProc(context.runtime, block, block.type); JavaMethod method = (JavaMethod)findCallable(self, name, intermediate, len + 1); for (int i = 0; i < len + 1; i++) { convertedArgs[i] = convertArg(intermediate[i], method, i); } return method.invokeDirect(singleton, convertedArgs); } else { return call(context, self, clazz, name, args); } }
@Override public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2, Block block) { if (block.isGiven()) { RubyProc proc = RubyProc.newProc(context.runtime, block, block.type); JavaMethod method = (JavaMethod) findCallableArityFour(self, name, arg0, arg1, arg2, proc); final Class<?>[] paramTypes = method.getParameterTypes(); Object cArg0 = arg0.toJava(paramTypes[0]); Object cArg1 = arg1.toJava(paramTypes[1]); Object cArg2 = arg2.toJava(paramTypes[2]); Object cArg3 = proc.toJava(paramTypes[3]); return method.invokeDirect(context, singleton, cArg0, cArg1, cArg2, cArg3); } return call(context, self, clazz, name, arg0, arg1, arg2); } }
@Override public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject[] args, Block block) { if (block.isGiven()) { int len = args.length; // too much array creation! Object[] convertedArgs = new Object[len + 1]; IRubyObject[] intermediate = new IRubyObject[len + 1]; System.arraycopy(args, 0, intermediate, 0, len); intermediate[len] = RubyProc.newProc(context.runtime, block, block.type); JavaMethod method = (JavaMethod) findCallable(self, name, intermediate, len + 1); final Class<?>[] paramTypes = method.getParameterTypes(); for (int i = 0; i < len + 1; i++) { convertedArgs[i] = intermediate[i].toJava(paramTypes[i]); } return method.invokeDirect(context, singleton, convertedArgs); } return call(context, self, clazz, name, args); }
@Override public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject[] args) { int len = args.length; Object[] convertedArgs = new Object[len]; JavaMethod method = (JavaMethod)findCallable(self, name, args, len); if (method.isVarArgs()) { len = method.getParameterTypes().length - 1; convertedArgs = new Object[len + 1]; for (int i = 0; i < len && i < args.length; i++) { convertedArgs[i] = convertArg(args[i], method, i); } convertedArgs[len] = convertVarargs(args, method); } else { convertedArgs = new Object[len]; for (int i = 0; i < len && i < args.length; i++) { convertedArgs[i] = convertArg(args[i], method, i); } } return method.invokeDirect(singleton, convertedArgs); }
@Override void install(final RubyModule proxy) { // we don't check haveLocalMethod() here because it's not local and we know // that we always want to go ahead and install it final RubyClass singletonClass = proxy.getSingletonClass(); defineMethods(singletonClass, new SingletonMethodInvoker(this.singleton, singletonClass, methods, name), false); } }
@Override public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2) { if (javaVarargsCallables != null) return call(context, self, clazz, name, new IRubyObject[] {arg0, arg1, arg2}); JavaMethod method = (JavaMethod)findCallableArityThree(self, name, arg0, arg1, arg2); Object cArg0 = convertArg(arg0, method, 0); Object cArg1 = convertArg(arg1, method, 1); Object cArg2 = convertArg(arg2, method, 2); return method.invokeDirect(singleton, cArg0, cArg1, cArg2); }
@Override public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject arg0, IRubyObject arg1) { if (javaVarargsCallables != null) return call(context, self, clazz, name, new IRubyObject[] {arg0, arg1}); JavaMethod method = (JavaMethod)findCallableArityTwo(self, name, arg0, arg1); Object cArg0 = convertArg(arg0, method, 0); Object cArg1 = convertArg(arg1, method, 1); return method.invokeDirect(singleton, cArg0, cArg1); }
@Override public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject arg0, IRubyObject arg1) { if (javaVarargsCallables != null) return call(context, self, clazz, name, new IRubyObject[] {arg0, arg1}); JavaMethod method = (JavaMethod)findCallableArityTwo(self, name, arg0, arg1); final Class<?>[] paramTypes = method.getParameterTypes(); Object cArg0 = arg0.toJava(paramTypes[0]); Object cArg1 = arg1.toJava(paramTypes[1]); return method.invokeDirect(context, singleton, cArg0, cArg1); }
@Override public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject arg0) { if (javaVarargsCallables != null) return call(context, self, clazz, name, new IRubyObject[] {arg0}); JavaMethod method = (JavaMethod) findCallableArityOne(self, name, arg0); if (method.isVarArgs()) return call(context, self, clazz, name, new IRubyObject[] {arg0}); final Class<?>[] paramTypes = method.getParameterTypes(); Object cArg0 = arg0.toJava(paramTypes[0]); return method.invokeDirect(context, singleton, cArg0); }
@Override public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2) { if (javaVarargsCallables != null) return call(context, self, clazz, name, new IRubyObject[] {arg0, arg1, arg2}); JavaMethod method = (JavaMethod) findCallableArityThree(self, name, arg0, arg1, arg2); final Class<?>[] paramTypes = method.getParameterTypes(); Object cArg0 = arg0.toJava(paramTypes[0]); Object cArg1 = arg1.toJava(paramTypes[1]); Object cArg2 = arg2.toJava(paramTypes[2]); return method.invokeDirect(context, singleton, cArg0, cArg1, cArg2); }
@Override public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name) { if (javaVarargsCallables != null) return call(context, self, clazz, name, IRubyObject.NULL_ARRAY); JavaMethod method = (JavaMethod)findCallableArityZero(self, name); return method.invokeDirect(singleton); }