private static int findMatchingMethod(FastArray list, MetaMethod method) { int len = list.size(); Object data[] = list.getArray(); for (int j = 0; j != len; ++j) { MetaMethod aMethod = (MetaMethod) data[j]; if (isMatchingMethod(aMethod, method)) return j; } return -1; }
public Object chooseMethod(Class[] arguments, boolean coerce) { if (arguments.length == 0) { return MetaClassHelper.chooseEmptyMethodParams(methods); } else if (arguments.length == 1 && arguments[0] == null) { return MetaClassHelper.chooseMostGeneralMethodWith1NullParam(methods); } else { List matchingMethods = new ArrayList(); final Object[] data = methods.getArray(); for (int i = 0, len = methods.size(); i != len; ++i) { Object method = data[i]; // making this false helps find matches if (((ParameterTypes) method).isValidMethod(arguments)) { matchingMethods.add(method); } } int size = matchingMethods.size(); if (0 == size) { return null; } else if (1 == size) { return matchingMethods.get(0); } return chooseMostSpecificParams(CLOSURE_DO_CALL_METHOD, matchingMethods, arguments); } }
public void testRegistry () { final MetaClassRegistryImpl metaClassRegistry = new MetaClassRegistryImpl(); final Object [] instanceMethods = metaClassRegistry.getInstanceMethods().getArray(); for (int i = 0; i < instanceMethods.length; i++) { System.out.println(instanceMethods[i]); } } }
/** * @param methods the methods to choose from * @return the method with 1 parameter which takes the most general type of * object (e.g. Object) */ public static Object chooseEmptyMethodParams(FastArray methods) { Object vargsMethod = null; final int len = methods.size(); final Object[] data = methods.getArray(); for (int i = 0; i != len; ++i) { Object method = data[i]; final ParameterTypes pt = (ParameterTypes) method; CachedClass[] paramTypes = pt.getParameterTypes(); int paramLength = paramTypes.length; if (paramLength == 0) { return method; } else if (paramLength == 1 && pt.isVargsMethod(EMPTY_ARRAY)) { vargsMethod = method; } } return vargsMethod; }
private void copyAllMethodsToSuper(Entry from, Header to) { Object oldListOrMethod = from.methods; if (oldListOrMethod instanceof FastArray) { FastArray oldList = (FastArray) oldListOrMethod; Entry e = null; int len1 = oldList.size(); Object list[] = oldList.getArray(); for (int j = 0; j != len1; ++j) { MetaMethod method = (MetaMethod) list[j]; if (e == null) e = getOrPutMethods(from.name, to); e.methodsForSuper = addMethodToList(e.methodsForSuper, method); } } else { MetaMethod method = (MetaMethod) oldListOrMethod; Entry e = getOrPutMethods(from.name, to); e.methodsForSuper = addMethodToList(e.methodsForSuper, method); } }
Object data[] = methods.getArray(); for (int i = 0; i != len; ++i) { Object method = data[i];
private void copyNonPrivateMethodsFromSuper(Entry e) { Object oldListOrMethod = e.methodsForSuper; if (oldListOrMethod == null) return; if (oldListOrMethod instanceof FastArray) { FastArray oldList = (FastArray) oldListOrMethod; int len1 = oldList.size(); Object list[] = oldList.getArray(); for (int j = 0; j != len1; ++j) { MetaMethod method = (MetaMethod) list[j]; if (method.isPrivate()) continue; e.methods = addMethodToList(e.methods, method); } } else { MetaMethod method = (MetaMethod) oldListOrMethod; if (!method.isPrivate()) { e.methods = addMethodToList(e.methods, method); } } }
private static void filterMatchingMethodForCategory(FastArray list, MetaMethod method) { int len = list.size(); if (len==0) { list.add(method); return; } Object data[] = list.getArray(); for (int j = 0; j != len; ++j) { MetaMethod aMethod = (MetaMethod) data[j]; Boolean match = getMatchKindForCategory(aMethod, method); // true == replace if (match==Boolean.TRUE) { list.set(j, method); return; // null == ignore (we have a better method already) } else if (match==null) { return; } } // the casese true and null for a match are through, the // remaining case is false and that means adding the method // to our list list.add(method); }
private void copyAllMethods(Entry from, Header to) { Object oldListOrMethod = from.methods; if (oldListOrMethod instanceof FastArray) { FastArray oldList = (FastArray) oldListOrMethod; Entry e = null; int len1 = oldList.size(); Object list[] = oldList.getArray(); for (int j = 0; j != len1; ++j) { MetaMethod method = (MetaMethod) list[j]; if (e == null) e = getOrPutMethods(from.name, to); e.methods = addMethodToList(e.methods, method); } } else { MetaMethod method = (MetaMethod) oldListOrMethod; if (!method.isPrivate()) { Entry e = getOrPutMethods(from.name, to); e.methods = addMethodToList(e.methods, method); } } }
/** * @return the matching method which should be found */ private MetaMethod findMethod(CachedMethod aMethod) { Object methods = getMethods(theClass, aMethod.getName(), false); if (methods instanceof FastArray) { FastArray m = (FastArray) methods; final int len = m.size; final Object data[] = m.getArray(); for (int i = 0; i != len; ++i) { MetaMethod method = (MetaMethod) data[i]; if (method.isMethod(aMethod)) { return method; } } } else { MetaMethod method = (MetaMethod) methods; if (method.getName().equals(aMethod.getName()) // TODO: should be better check for case when only diff in modifiers can be SYNTHETIC flag // && method.getModifiers() == aMethod.getModifiers() && method.getReturnType().equals(aMethod.getReturnType()) && MetaMethod.equal(method.getParameterTypes(), aMethod.getParameterTypes())) { return method; } } return aMethod; }
private void copyNonPrivateMethods(Entry from, Header to) { Object oldListOrMethod = from.methods; if (oldListOrMethod instanceof FastArray) { FastArray oldList = (FastArray) oldListOrMethod; Entry e = null; int len1 = oldList.size(); Object list[] = oldList.getArray(); for (int j = 0; j != len1; ++j) { MetaMethod method = (MetaMethod) list[j]; if (method.isPrivate()) continue; if (e == null) e = getOrPutMethods(from.name, to); e.methods = addMethodToList(e.methods, method); } } else { MetaMethod method = (MetaMethod) oldListOrMethod; if (!method.isPrivate()) { Entry e = getOrPutMethods(from.name, to); e.methods = addMethodToList(e.methods, method); } } }
private void copyNonPrivateNonNewMetaMethods(Entry from, Header to) { Object oldListOrMethod = from.methods; if (oldListOrMethod == null) return; if (oldListOrMethod instanceof FastArray) { FastArray oldList = (FastArray) oldListOrMethod; Entry e = null; int len1 = oldList.size(); Object list[] = oldList.getArray(); for (int j = 0; j != len1; ++j) { MetaMethod method = (MetaMethod) list[j]; if (method instanceof NewMetaMethod || method.isPrivate()) continue; if (e == null) e = getOrPutMethods(from.name, to); e.methods = addMethodToList(e.methods, method); } } else { MetaMethod method = (MetaMethod) oldListOrMethod; if (method instanceof NewMetaMethod || method.isPrivate()) return; Entry e = getOrPutMethods(from.name, to); e.methods = addMethodToList(e.methods, method); } }
FastArray methods = (FastArray) e.methods; final int len = methods.size(); final Object[] data = methods.getArray(); for (int i = 0; i != len; ++i) { MetaMethod method = (MetaMethod) data[i];
FastArray methods = (FastArray) methodOrList; final int len = methods.size(); final Object[] data = methods.getArray(); for (int i = 0; i != len; ++i) { MetaMethod element = (MetaMethod) data[i];
final int len = methods.size(); for (int i = 0; i != len; ++i) { final Object[] data = methods.getArray(); Object method = data[i]; final ParameterTypes pt = (ParameterTypes) method;
private int findMatchingMethod(FastArray list, MetaMethod method) { int len = list.size(); Object data[] = list.getArray(); for (int j = 0; j != len; ++j) { MetaMethod aMethod = (MetaMethod) data[j]; if (isMatchingMethod(aMethod, method)) return j; } return -1; }
private int findMatchingMethod(FastArray list, MetaMethod method) { int len = list.size(); Object data[] = list.getArray(); for (int j = 0; j != len; ++j) { MetaMethod aMethod = (MetaMethod) data[j]; if (isMatchingMethod(aMethod, method)) return j; } return -1; }
private int findMatchingMethod(FastArray list, MetaMethod method) { int len = list.size(); Object data[] = list.getArray(); for (int j = 0; j != len; ++j) { MetaMethod aMethod = (MetaMethod) data[j]; if (isMatchingMethod(aMethod, method)) return j; } return -1; }
private void copyAllMethodsToSuper(Entry from, Header to) { Object oldListOrMethod = from.methods; if (oldListOrMethod instanceof FastArray) { FastArray oldList = (FastArray) oldListOrMethod; Entry e = null; int len1 = oldList.size(); Object list[] = oldList.getArray(); for (int j = 0; j != len1; ++j) { MetaMethod method = (MetaMethod) list[j]; if (e == null) e = getOrPutMethods(from.name, to); e.methodsForSuper = addMethodToList(e.methodsForSuper, method); } } else { MetaMethod method = (MetaMethod) oldListOrMethod; Entry e = getOrPutMethods(from.name, to); e.methodsForSuper = addMethodToList(e.methodsForSuper, method); } }
private void copyAllMethodsToSuper(Entry from, Header to) { Object oldListOrMethod = from.methods; if (oldListOrMethod instanceof FastArray) { FastArray oldList = (FastArray) oldListOrMethod; Entry e = null; int len1 = oldList.size(); Object list[] = oldList.getArray(); for (int j = 0; j != len1; ++j) { MetaMethod method = (MetaMethod) list[j]; if (e == null) e = getOrPutMethods(from.name, to); e.methodsForSuper = addMethodToList(e.methodsForSuper, method); } } else { MetaMethod method = (MetaMethod) oldListOrMethod; Entry e = getOrPutMethods(from.name, to); e.methodsForSuper = addMethodToList(e.methodsForSuper, method); } }