public boolean isEmpty() { return getFirst() == null && getSecond() == null; } }
public boolean isFull() { return getFirst() != null && getSecond() != null; }
@SuppressWarnings("unchecked") public int compareTo(Pair<U, V> o) { Comparable<U> cu = (Comparable<U>)getFirst(); if (cu == null) { if (first != null) return 1; } else { int d = cu.compareTo(o.getFirst()); if (d != 0) return d; } Comparable<V> cv = (Comparable<V>)getSecond(); if (cv == null) return second != null ? 1 : -1; return cv.compareTo(o.getSecond()); }
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; }
new JScrollPane(new JLabel(new ImageIcon(imgs.getSecond())))
public static TypeRef recognizeSizeOf(Expression e) { if (!(e instanceof FunctionCall)) { return null; } FunctionCall fc = (FunctionCall) e; List<Pair<String, Expression>> args = fc.getArguments(); if (args.size() != 1) { return null; } Pair<String, Expression> arg = args.get(0); if (arg == null) { return null; } Expression f = fc.getFunction(); if (!(f instanceof VariableRef)) { return null; } VariableRef vr = (VariableRef) f; if (!"sizeof".equals(String.valueOf(vr.getName()))) { return null; } Expression a = arg.getSecond(); if (!(a instanceof Expression.TypeRefExpression)) { return null; } Expression.TypeRefExpression tr = (Expression.TypeRefExpression) a; return tr.getType(); }
for (Iterator<Map.Entry<String, Pair<Define, Set<Identifier>>>> it = pending.entrySet().iterator(); it.hasNext();) { Map.Entry<String, Pair<Define, Set<Identifier>>> e = it.next(); Set<Identifier> dependencies = e.getValue().getSecond(); String name = e.getKey(); boolean missesDep = false;
if (DeclarationsConverter.getMethodsAndTheirSignatures(NSObject.class).getSecond().contains(sig)) { return true;
public void addMissingMethods(Class<?> originalLib, Signatures existingSignatures, Struct outputLib) { for (Pair<Function, String> f : getMethodsAndTheirSignatures(originalLib).getFirst()) { if (existingSignatures.addMethod(f.getSecond())) { outputLib.addDeclaration(f.getFirst().clone()); } } }
public void addMissingMethods(Class<?> originalLib, Signatures existingSignatures, Struct outputLib) { for (Pair<Function, String> f : getMethodsAndTheirSignatures(originalLib).getFirst()) { if (existingSignatures.addMethod(f.getSecond())) { outputLib.addDeclaration(f.getFirst().clone()); } } }
@Override public Void call() throws Exception { try { if(oldRelevanceFuture!=null) oldRelevanceFuture.get(); if (getPortalRenderer() != null) throw new IllegalStateException( "portalRenderer is intolerably non-null."); final Pair<Renderer, Integer> newRendererPair = Features.get(getTr(), GPUFeature.class).rendererFactory .get().acquirePortalRenderer(); System.out.println("Activating portal entrance... "+PortalEntrance.this); getPortalExit().setControlledCamera( newRendererPair.getFirst().getCamera()); newRendererPair.getFirst().getSkyCube().setSkyCubeGen(skyCubeGen); setPortalRenderer(newRendererPair.getFirst()); setPortalTextureID(newRendererPair.getSecond()); portalExit.activate(); setPortalUnavailable(false); System.out.println("Done activating portal entrance."); } catch (PortalNotAvailableException e) { System.out.println("Portal acquisition rejected: All are in use. PortalEntrance hash="+this.hashCode()); setPortalUnavailable(true); }// end catch(PortalNotAvailableException) catch(Exception e){e.printStackTrace();} return null; }}); }else{//Not rendering
public Identifier getActualTaggedTypeName(TaggedTypeRef struct) { Identifier structName = null; Identifier tag = struct.getTag(); if (tag == null || tag.isPlain() && tag.toString().startsWith("_")) { TypeDef parentDef = as(struct.getParentElement(), TypeDef.class); if (parentDef != null) { structName = new Identifier.SimpleIdentifier(JNAeratorUtils.findBestPlainStorageName(parentDef)); } else if (tag != null) { String better = tag.toString().substring(1); Pair<TypeDef, Declarator> pair = result.typeDefs.get(better); if (pair != null && pair.getFirst().getValueType() != null && pair.getSecond() instanceof DirectDeclarator) { TypeRef tr = pair.getFirst().getValueType(); DirectDeclarator dd = (DirectDeclarator) pair.getSecond(); if (tr instanceof SimpleTypeRef) { if (tag.equals(((SimpleTypeRef) tr).getName())) { structName = ident(dd.resolveName()); } } else if (tr instanceof TaggedTypeRef) { if (tag.equals(((TaggedTypeRef) tr).getTag())) { structName = ident(dd.resolveName()); } } } } } if (structName == null || structName.toString().equals("")) { structName = tag; } return structName == null ? null : structName.clone(); }
convValue = convertExpressionToJava(((Expression.AssignmentOp) x).getValue(), libraryClassName, promoteNativeLongToLong, forceConstants, mappings); res = typed(expr(convTarget.getFirst(), Expression.AssignmentOperator.Equal, convValue.getFirst()), convTarget.getSecond()); } else if (x instanceof Expression.BinaryOp) { Expression.BinaryOp bop = (Expression.BinaryOp) x; TypeRef t1 = conv1.getSecond(), t2 = conv2.getSecond(); Expression x1 = conv1.getFirst(), x2 = conv2.getFirst(); res = typed(expr(op, conv.getFirst()), conv.getSecond()); } else if (x instanceof Expression.Constant) { Class<?> c = null;
pair.getSecond().add(new Pair<String, String>(vd.getCommentBefore(), name)); List<Expression> orderedFieldNames = new ArrayList<Expression>(); int iArg = 0; for (VariablesDeclaration vd : new CompoundCollection<VariablesDeclaration>(decls.getFirst(), decls.getSecond())) { String name = chooseJavaArgName(vd.getDeclarators().get(0).resolveName(), iArg, names); namesById.put(vd.getId(), name); for (VariablesDeclaration vd : decls.getSecond()) { String name = vd.getDeclarators().get(0).resolveName(), uname = namesById.get(vd.getId()); if (!result.config.noComments) {
Function original = p.getSecond(); Function fDirect = original.clone();
for (Pair<MessageFormat, MessageFormat> mf : result.config.onlineDocumentationURLFormats) { try { MessageFormat urlFormat = mf.getSecond(); URL url = new URL(urlFormat.format(name)); URLConnection con = url.openConnection();
instanceStruct.setResolvedJavaIdentifier(fullClassName); Set<String> objSigs = DeclarationsConverter.getMethodsAndTheirSignatures(NSObject.class).getSecond(), clasSigs = new HashSet<String>();//DeclarationsConverter.getMethodsAndTheirSignatures(NSClass.class).getSecond();