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(); }
public void visitFunctionCall(FunctionCall functionCall) { visitMemberRef(functionCall); visit(functionCall.getTarget()); visit(functionCall.getFunction()); for (Pair<String, Expression> x : copy(functionCall.getArguments())) if (x != null) visit(x.getSecond()); }
protected static Object cloneObject(Object value) throws CloneNotSupportedException { if (value == null) return null; Class<?> type = value.getClass(); if (Element.class.isAssignableFrom(type)) return ((Element) value).clone(); else if (EnumSet.class.isAssignableFrom(type)) return ((EnumSet<?>) value).clone(); else if (Collection.class.isAssignableFrom(type)) return cloneElements((Collection<?>) value); else if (Map.class.isAssignableFrom(type)) return cloneElements((Map<?, ?>) value); else if (Pair.class.isAssignableFrom(type)) { Pair<?, ?> pair = (Pair<?, ?>) value; return new Pair<Object, Object>(cloneObject(pair.getFirst()), cloneObject(pair.getSecond())); } // else if (value instanceof String || type.isPrimitive()) return value; // throw new CloneNotSupportedException(); }
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 setArguments(List<Pair<String, Expression>> arguments) { for (Pair<String, Expression> p : this.arguments) p.getSecond().setParentElement(null); this.arguments.clear(); for (Pair<String, Expression> p : arguments) addArgument(p.getFirst(), p.getSecond()); }