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 Expression getFlatArraySizeExpression(TypeRef.Pointer.ArrayRef arrayRef, Identifier callerLibraryName) throws UnsupportedConversionException { Expression mul = null; List<Expression> dims = arrayRef.flattenDimensions(); for (int i = dims.size(); i-- != 0;) { Expression x = dims.get(i); if (x == null || x instanceof Expression.EmptyArraySize) { return null; //javaType = jr = new ArrayRef(typeRef(Pointer.class)); //break; } else { Pair<Expression, TypeRef> c = convertExpressionToJava(x, callerLibraryName, false, true, null); c.getFirst().setParenthesis(dims.size() > 1); if (mul == null) { mul = c.getFirst(); } else { mul = expr(c.getFirst(), Expression.BinaryOperator.Multiply, mul); } } } return mul; }
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.getFirst()))), new JScrollPane(new JLabel(new ImageIcon(imgs.getSecond())))
private Identifier getFakePointerName(Identifier name) { String nameStr = name == null ? null : name.toString(); String trimmed = StringUtils.trimUnderscores(nameStr); if (trimmed != null && !nameStr.equals(trimmed)) { String nicerName = trimmed; Pair<TypeDef, Declarator> pair = typeDefs.get(nicerName); if (pair != null) { TypeRef targetType = pair.getFirst().getValueType(); String target = targetType.toString(); if (target.equals(nameStr + "*") || target.equals(nameStr)) { name = ident(nameStr = nicerName); } } } return name; }
private Identifier getUndefinedTypeName(Identifier name) { String nameStr = name == null ? null : name.toString(); String trimmed = StringUtils.trimUnderscores(nameStr); if (trimmed != null && !nameStr.equals(trimmed)) { String nicerName = trimmed; Pair<TypeDef, Declarator> pair = typeDefs.get(nicerName); if (pair != null) { String target = pair.getFirst().getValueType().toString(); if (target.equals(nameStr))// || target.equals(nameStr+"*")) { name = ident(nameStr = nicerName); } } } return name; }
Declarator.MutableByDeclarator mt = p.getValue().mutateType(p.getFirst().getValueType()); return mt instanceof TypeRef ? (TypeRef) mt : null;
void replaceMalloc(TypeRef pointedType, Element toReplace, Expression sizeExpression) { // TODO handle casts and sizeof expressions ! Pair<TypeRef, Expression> typeAndSize = recognizeSizeOfMult(sizeExpression); if (typeAndSize != null && (pointedType == null || pointedType.equals(typeAndSize.getFirst()))) { String tStr = String.valueOf(typeAndSize.getFirst()); try { JavaPrim prim = JavaPrim.getJavaPrim(tStr); if (prim != null && prim.isPrimitive) { String cap = StringUtils.capitalize(tStr); toReplace.replaceBy(staticPtrMethod("allocate" + cap + "s", typeAndSize.getValue())); return; } } catch (Throwable th) { // Do nothing } } toReplace.replaceBy(staticPtrMethod("allocateBytes", sizeExpression)); }
@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(); }
Expression val = casted.getFirst(); return typed(val, tr);
VariablesDeclaration vd = new VariablesDeclaration(tr, new DirectDeclarator(name, val.getFirst())); if (!result.config.noComments) { vd.setCommentBefore(v.getCommentBefore());