public static <U, V> Pair<U, V> create(U u, V v) { return new Pair<U, V>(u, v); } public U getFirst() {
public static <A, B> Pair<A, B> pair(A a, B b) { return new Pair<A, B>(a, b); }
public static Pair<Expression, TypeRef> typed(Expression a, TypeRef b) { return new Pair<Expression, TypeRef>(a, b); }
@Override public void executeOnEachRefresh(GLExecutable<Void, GL_TYPE> executable, double orderPriority) { synchronized(repeatingTasks){ repeatingTasks.add(new Pair<Double,GLExecutable<?,GL_TYPE>>(orderPriority,executable)); } }
static void defRecon(String s32, String s64, TypeRef sRecon) { predefined32_64Reconciliations.put(new Pair<String, String>(s32, s64), sRecon); } /*static TypeRef cleanClone(TypeRef t) {
public void addFunctionReifiableInFakePointer(Identifier resolvedFakePointer, Identifier libraryClassName, Function f) { List<Pair<Identifier, Function>> list = functionsReifiableInFakePointers.get(resolvedFakePointer); if (list == null) { functionsReifiableInFakePointers.put(resolvedFakePointer, list = new ArrayList<Pair<Identifier, Function>>()); } list.add(new Pair<Identifier, Function>(libraryClassName, f)); }
boolean isReferenced(Element e) { if (e == null) { return false; } return ret.referencedElements.contains(new Pair<Element, Integer>(e, e.getId())); }
public static final List<Pair<String, String[]>> grep(Collection<String> list, Pattern p) { List<Pair<String, String[]>> ret = new ArrayList<Pair<String, String[]>>(list.size()); for (String s : list) { Matcher matcher = p.matcher(s); if (matcher.find()) ret.add(new Pair<String, String[]>(s, getGroups(matcher))); } return ret; }
public void rehabilitateWeakTypeDefs() { for (Map.Entry<String, TypeRef> e : weakTypeDefs.entrySet()) { if (typeDefs.get(e.getKey()) == null) { DirectDeclarator dd = new DirectDeclarator(e.getKey()); TypeDef td = new TypeDef(e.getValue(), dd); typeDefs.put(e.getKey(), new Pair<TypeDef, Declarator>(td, dd)); } } } Map<String, TypeRef> manualTypeDefs = new LinkedHashMap<String, TypeRef>();
@Override public boolean add(final E e) { Pair<KEY,E>pair= pairs.get(e); if(pair!=null) return false; try{pair= new Pair<KEY,E>(propertyAdapter.adapt(new PropertyChangeEvent(e, propertyName, null, (PROPERTY_TYPE)PropertyUtils.getProperty(e, propertyName))),e);} catch(NoSuchMethodException ex){throw new IllegalArgumentException("Supplied element (bean) does not expose method for property: `"+propertyName+"`.");} catch(InvocationTargetException ex){throw new RuntimeException(ex);} catch(IllegalAccessException ex){throw new IllegalArgumentException("Supplied element (bean) does not allow access for property `"+propertyName+"`.",ex);} //listeners.put(e,propertyChangeListener); pairs.put(e,pair); e.addPropertyChangeListener(propertyName, elementPCL); assert pair!=null:"pair unexpectedly null."; delegate.add(pair); return true; }//end add(...)
public static synchronized Pair<List<Pair<Function, String>>, Set<String>> getMethodsAndTheirSignatures(Class<?> originalLib) { if (cachedForcedMethodsAndTheirSignatures == null) { cachedForcedMethodsAndTheirSignatures = new LinkedHashMap<Class<?>, Pair<List<Pair<Function, String>>, Set<String>>>(); } Pair<List<Pair<Function, String>>, Set<String>> pair = cachedForcedMethodsAndTheirSignatures.get(originalLib); if (pair == null) { pair = new Pair<List<Pair<Function, String>>, Set<String>>(new ArrayList<Pair<Function, String>>(), new HashSet<String>()); for (Method m : originalLib.getDeclaredMethods()) { Function f = Function.fromMethod(m); String sig = f.computeSignature(Function.SignatureType.JavaStyle); //if (m.getDeclaringClass().equals(NSObject.class) && f.getName().equals("as")) { // Declaration //} pair.getFirst().add(new Pair<Function, String>(f, sig)); pair.getSecond().add(sig); } } return pair; }
public static synchronized Pair<List<Pair<Function, String>>, Set<String>> getMethodsAndTheirSignatures(Class<?> originalLib) { if (cachedForcedMethodsAndTheirSignatures == null) { cachedForcedMethodsAndTheirSignatures = new LinkedHashMap<Class<?>, Pair<List<Pair<Function, String>>, Set<String>>>(); } Pair<List<Pair<Function, String>>, Set<String>> pair = cachedForcedMethodsAndTheirSignatures.get(originalLib); if (pair == null) { pair = new Pair<List<Pair<Function, String>>, Set<String>>(new ArrayList<Pair<Function, String>>(), new HashSet<String>()); for (Method m : originalLib.getDeclaredMethods()) { Function f = Function.fromMethod(m); String sig = f.computeSignature(SignatureType.JavaStyle); //if (m.getDeclaringClass().equals(NSObject.class) && f.getName().equals("as")) { // Declaration //} pair.getFirst().add(new Pair<Function, String>(f, sig)); pair.getSecond().add(sig); } } return pair; }
public static TypeRef reconciliateSimple32bitsAnd64bits(TypeRef t32, TypeRef t64) { TypeRef recon = predefined32_64Reconciliations.get(new Pair<String, String>(t32.toString(), t64.toString())); /*if (recon == null) { TypeRef tt32 = cleanClone(t32), tt64 = cleanClone(t64); if (tt32.toString().equals(t64)) return tt32; recon = predefined32_64Reconciliations.get(new Pair<String, String>(tt32.toString(), tt64.toString())); }*/ return recon == null ? null : recon.clone(); } }
@Override public boolean add(Pair<KEY,CollectionActionDispatcher<E>> e) { if(!map.containsKey(e.getKey())){ final CollectionActionDispatcher<E> newCollection = new CollectionActionDispatcher<E>(new ArrayList<E>()); final Pair<KEY,CollectionActionDispatcher<E>> newPair = new Pair<KEY,CollectionActionDispatcher<E>>(e.getKey(),newCollection); map.put(e.getKey(),newPair); delegate.add(newPair); cache.add(newPair); }//end (create new entry) return e.getValue().addTarget(map.get(e.getKey()).getValue(), true); }//end add()
@Override public void visitTypeDef(TypeDef typeDef) { super.visitTypeDef(typeDef); for (Declarator vs : typeDef.getDeclarators()) { typeDefs.put(vs.resolveName(), new Pair<TypeDef, Declarator>(typeDef, vs)); } } private static Pattern frameworkPathPattern = Pattern.compile(".*/(\\w+)\\.framework/(?:.*/)?Headers/(?:.*/)?([^/]+)\\.[^/.]+$");
@Override public boolean add(Pair<KEY,E> e) { cache.add(e); if(!map.containsKey(e.getKey())){ final CollectionActionDispatcher<E> newCollection = new CollectionActionDispatcher<E>(new ArrayList<E>()); final Pair<KEY,CollectionActionDispatcher<E>> newPair = new Pair<KEY,CollectionActionDispatcher<E>>(e.getKey(),newCollection); map.put(e.getKey(),newPair); delegate.add(newPair); }//end (create new entry) return map.get(e.getKey()).getValue().add(e.getValue()); }//end add()
Runnable worker = new Runnable() { public void run() { for (;!Thread.interrupted();) { U value; synchronized (it) { if (!it.hasNext()) break; value = it.next(); } try { V mappedValue = mapper.adapt(value); synchronized (out) { out.add(mappedValue); } } catch (Throwable th) { synchronized (errorsOut) { errorsOut.add(new Pair<U, Throwable>(value, th)); } } //Thread.yield(); } }};
public synchronized Pair<Renderer,Integer> acquirePortalRenderer() throws PortalNotAvailableException { final int index = portalFrameBufferIndexPool.pop(); if(index == -1) throw new PortalNotAvailableException(); final Renderer result = acquireRenderer(); assert !rendererPortalIndexMap.containsKey(result); rendererPortalIndexMap.put(result, index); result.setRenderingTarget(portalFrameBuffers[index]); printPortalState(); return new Pair<Renderer,Integer>(result,index); }//end acquirePortalRenderer()
@Override public void visitIdentifier(Identifier identifier) { super.visitIdentifier(identifier); Element e = result.symbols.getVariable(identifier); if (e != null && isReferenced(e)) { String changedName = referencedElementsChangedNames.get(e.getId()); if (changedName != null) { Identifier replacedIdentifier = ident(changedName); identifier.replaceBy(replacedIdentifier); ret.referencedElements.add(new Pair<Element, Integer>(replacedIdentifier, replacedIdentifier.getId())); } } }
@Override public void visitUnaryOp(UnaryOp unaryOp) { super.visitUnaryOp(unaryOp); if (unaryOp.getOperator() == UnaryOperator.Reference) { if (unaryOp.getOperand() instanceof VariableRef) { VariableRef vr = (VariableRef) unaryOp.getOperand(); Element e = result.symbols.getVariable(vr.getName()); if (e != null) { ret.referencedElements.add(new Pair<Element, Integer>(e, e.getId())); } } } } });