(Object proxy, Method method, Object[] args)
| 25 | } |
| 26 | |
| 27 | public Object invoke(Object proxy, Method method, Object[] args) throws Throwable{ |
| 28 | Class rt = method.getReturnType(); |
| 29 | IFn fn = (IFn) fns.valAt(method.getName()); |
| 30 | if(fn == null) |
| 31 | { |
| 32 | if(rt == Void.TYPE) |
| 33 | return null; |
| 34 | else if(method.getName().equals("equals")) |
| 35 | { |
| 36 | return proxy == args[0]; |
| 37 | } |
| 38 | else if(method.getName().equals("hashCode")) |
| 39 | { |
| 40 | return System.identityHashCode(proxy); |
| 41 | } |
| 42 | else if(method.getName().equals("toString")) |
| 43 | { |
| 44 | return "Proxy: " + System.identityHashCode(proxy); |
| 45 | } |
| 46 | throw new UnsupportedOperationException(); |
| 47 | } |
| 48 | Object ret = fn.applyTo(ArraySeq.create(args)); |
| 49 | if(rt == Void.TYPE) |
| 50 | return null; |
| 51 | else if(rt.isPrimitive()) |
| 52 | { |
| 53 | if(rt == Character.TYPE) |
| 54 | return ret; |
| 55 | else if(rt == Integer.TYPE) |
| 56 | return ((Number) ret).intValue(); |
| 57 | else if(rt == Long.TYPE) |
| 58 | return ((Number) ret).longValue(); |
| 59 | else if(rt == Float.TYPE) |
| 60 | return ((Number) ret).floatValue(); |
| 61 | else if(rt == Double.TYPE) |
| 62 | return ((Number) ret).doubleValue(); |
| 63 | else if(rt == Boolean.TYPE && !(ret instanceof Boolean)) |
| 64 | return ret == null ? Boolean.FALSE : Boolean.TRUE; |
| 65 | else if(rt == Byte.TYPE) |
| 66 | return (byte) ((Number) ret).intValue(); |
| 67 | else if(rt == Short.TYPE) |
| 68 | return (short) ((Number) ret).intValue(); |
| 69 | } |
| 70 | return ret; |
| 71 | } |
| 72 | } |
nothing calls this directly
no test coverage detected