@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); }
@Override public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name) { if (javaVarargsCallables != null) return call(context, self, clazz, name, IRubyObject.NULL_ARRAY); JavaProxy proxy = castJavaProxy(self); JavaMethod method = (JavaMethod) findCallableArityZero(self, name); return method.invokeDirect(context, proxy.getObject()); }
@Override public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name) { if (javaVarargsCallables != null) return call(context, self, clazz, name, IRubyObject.NULL_ARRAY); JavaProxy proxy = castJavaProxy(self); JavaMethod method = (JavaMethod) findCallableArityZero(self, name); return method.invokeDirect(context, proxy.getObject()); }
@Override public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name) { if (javaVarargsCallables != null) return call(context, self, clazz, name, IRubyObject.NULL_ARRAY); JavaProxy proxy = castJavaProxy(self); JavaMethod method = (JavaMethod)findCallableArityZero(self, name); return method.invokeDirect(proxy.getObject()); }
@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}); Object cArg0 = convertArg(arg0, method, 0); return method.invokeDirect(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); 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) { 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 arg0) { if (javaVarargsCallables != null) return call(context, self, clazz, name, new IRubyObject[] {arg0}); JavaProxy proxy = castJavaProxy(self); JavaMethod method = (JavaMethod) findCallableArityOne(self, name, arg0); final Class<?>[] paramTypes = method.getParameterTypes(); Object cArg0 = arg0.toJava(paramTypes[0]); return method.invokeDirect(context, proxy.getObject(), cArg0); }
@Override public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, Block block) { if (block.isGiven()) { RubyProc proc = RubyProc.newProc(context.runtime, block, block.type); JavaMethod method = (JavaMethod) findCallableArityOne(self, name, proc); final Class<?>[] paramTypes = method.getParameterTypes(); Object cArg0 = proc.toJava(paramTypes[0]); return method.invokeDirect(context, singleton, cArg0); } return call(context, self, clazz, name); }
@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, 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, IRubyObject arg0, Block block) { if (block.isGiven()) { RubyProc proc = RubyProc.newProc(context.runtime, block, block.type); JavaMethod method = (JavaMethod)findCallableArityTwo(self, name, arg0, proc); Object cArg0 = convertArg(arg0, method, 0); Object cArg1 = convertArg(proc, method, 1); return method.invokeDirect(singleton, cArg0, cArg1); } else { return call(context, self, clazz, name, arg0); } }
@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}); JavaProxy proxy = castJavaProxy(self); 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, proxy.getObject(), cArg0, cArg1); }
@JRubyMethod public IRubyObject java_send(ThreadContext context, IRubyObject rubyName, IRubyObject argTypes) { String name = rubyName.asJavaString(); RubyArray argTypesAry = argTypes.convertToArray(); Ruby runtime = context.runtime; checkArgSizeMismatch(runtime, 0, argTypesAry); JavaMethod method = new JavaMethod(runtime, getMethod(context, name)); return method.invokeDirect(context, getObject()); }
@Override public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject arg0, Block block) { if (block.isGiven()) { RubyProc proc = RubyProc.newProc(context.runtime, block, block.type); JavaMethod method = (JavaMethod) findCallableArityTwo(self, name, arg0, proc); final Class<?>[] paramTypes = method.getParameterTypes(); Object cArg0 = arg0.toJava(paramTypes[0]); Object cArg1 = proc.toJava(paramTypes[1]); return method.invokeDirect(context, singleton, cArg0, cArg1); } return call(context, self, clazz, name, arg0); }
@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}); JavaProxy proxy = castJavaProxy(self); 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, proxy.getObject(), cArg0, cArg1, cArg2); }
@Override public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, Block block) { if (block.isGiven()) { JavaProxy proxy = castJavaProxy(self); RubyProc proc = RubyProc.newProc(context.runtime, block, block.type); JavaMethod method = (JavaMethod) findCallableArityOne(self, name, proc); final Class<?>[] paramTypes = method.getParameterTypes(); Object cArg0 = proc.toJava(paramTypes[0]); return method.invokeDirect(context, proxy.getObject(), cArg0); } return call(context, self, clazz, name); }
@JRubyMethod public IRubyObject java_send(ThreadContext context, IRubyObject rubyName, IRubyObject argTypes, IRubyObject arg0) { String name = rubyName.asJavaString(); RubyArray argTypesAry = argTypes.convertToArray(); Ruby runtime = context.runtime; checkArgSizeMismatch(runtime, 1, argTypesAry); Class argTypeClass = (Class) argTypesAry.eltInternal(0).toJava(Class.class); JavaMethod method = new JavaMethod(runtime, getMethod(context, name, argTypeClass)); return method.invokeDirect(context, getObject(), arg0.toJava(argTypeClass)); }