public void addDeclarators(List<Declarator> declarators) { for (Declarator d : declarators) addDeclarator(d); }
@Override public VariablesDeclaration addModifiers(Modifier... mod) { return (VariablesDeclaration) super.addModifiers(mod); } @Override
public void setDeclarators(List<Declarator> declarators) { changeValue(this, this.declarators, declarators); } public void addDeclarators(List<Declarator> declarators) {
@Override protected void visitStoredDeclarations(StoredDeclarations d) { super.visitStoredDeclarations(d); if (d.getDeclarators().size() == 1) { Declarator declarator = d.getDeclarators().get(0); if (declarator instanceof FunctionDeclarator) { FunctionDeclarator fd = (FunctionDeclarator) declarator; Function f = new Function(Function.Type.CFunction, null, d.getValueType(), fd.getArgs()); f.addModifiers(fd.getTarget().getModifiers()); FunctionSignature fs = new FunctionSignature(f); d.setValueType(fs); Declarator target = fd.getTarget(); Declarator newTarget = target == null ? new DirectDeclarator(fd.resolveName(), fd.getDefaultValue()) : target.clone(); d.setDeclarators(Arrays.asList(newTarget)); d.accept(this); } } }
classHolder.addModifiers(ModifierType.Private, ModifierType.Static); classHolder.setValueType(typeRef(classClassName)); if (isProtocol || isCategory) { classGetter = null; classHolder.addDeclarator(new Declarator.DirectDeclarator(classInstanceName, call)); } else { classHolder.addDeclarator(new Declarator.DirectDeclarator(classInstanceName));
protected void valueTypeAndStorageSuffix(StoredDeclarations e) { if (e.getValueType() instanceof FunctionSignature) { FunctionSignature sig = (FunctionSignature) e.getValueType(); if (sig.getFunction() != null) { Identifier name = sig.getFunction().getName(); if (name != null && e.declarators.size() == 1) { String stoName = e.declarators.get(0).resolveName(); if (name.equals(stoName) || stoName == null) { append(sig); return; } } } } append(e.getValueType()).space(!e.getDeclarators().isEmpty()).implode(e.getDeclarators(), ", "); }
StoredDeclarations d = as(parent, StoredDeclarations.class); if (d != null && d.getDeclarators().isEmpty()) { if (d instanceof VariablesDeclaration) { VariablesDeclaration pvd = (VariablesDeclaration) d; functionSignature.replaceBy(functionSignatureRef(fnameClone)); } else { d.replaceBy(null); // special case of C++-like struct sub-type definition
protected void visitStoredDeclarations(StoredDeclarations d) { visitDeclaration(d); visit(d.getDeclarators()); }
@Override public Element getNextChild(Element child) { Element e = super.getNextChild(child); if (e != null) return e; return getNextSibling(declarators, child); }
@Override public Element getPreviousChild(Element child) { Element e = super.getPreviousChild(child); if (e != null) return e; return getPreviousSibling(declarators, child); }
@Override public boolean replaceChild(Element child, Element by) { if (super.replaceChild(child, by)) return true; return replaceChild(declarators, Declarator.class, this, child, by); } }
@Override protected void visitStoredDeclarations(StoredDeclarations d) { super.visitStoredDeclarations(d); if (d.getDeclarators().size() == 1) { Declarator declarator = d.getDeclarators().get(0); if (declarator instanceof FunctionDeclarator) { FunctionDeclarator fd = (FunctionDeclarator) declarator; Function f = new Function(Function.Type.CFunction, null, d.getValueType(), fd.getArgs()); f.addModifiers(fd.getTarget().getModifiers()); FunctionSignature fs = new FunctionSignature(f); d.setValueType(fs); Declarator target = fd.getTarget(); Declarator newTarget = target == null ? new DirectDeclarator(fd.resolveName(), fd.getDefaultValue()) : target.clone(); d.setDeclarators(Arrays.asList(newTarget)); d.accept(this); } } }
classHolder.addModifiers(ModifierType.Private, ModifierType.Static); classHolder.setValueType(typeRef(classClassName)); if (isProtocol || isCategory) { classGetter = null; classHolder.addDeclarator(new Declarator.DirectDeclarator(classInstanceName, call)); } else { classHolder.addDeclarator(new Declarator.DirectDeclarator(classInstanceName));
TaggedTypeRef ttr = sd.getValueType() instanceof TaggedTypeRef ? (TaggedTypeRef) sd.getValueType() : null; String idealName = null; if (ttr != null && ttr.getTag() != null) { for (Declarator st : sd.getDeclarators()) { if (st instanceof DirectDeclarator) { DirectDeclarator decl = (DirectDeclarator) st;
StoredDeclarations d = as(parent, StoredDeclarations.class); if (d != null && d.getDeclarators().isEmpty()) { if (d instanceof VariablesDeclaration) { VariablesDeclaration pvd = (VariablesDeclaration) d; functionSignature.replaceBy(functionSignatureRef(fnameClone)); } else { d.replaceBy(null); // special case of C++-like struct sub-type definition
List<String> getNames(Declaration d) { if (d instanceof StoredDeclarations) { List<String> ret = new ArrayList<String>(); for (Declarator declarator : ((StoredDeclarations) d).getDeclarators()) { ret.add(declarator.resolveName()); } return ret; } else if (d instanceof TaggedTypeRefDeclaration) { TaggedTypeRef tr = ((TaggedTypeRefDeclaration) d).getTaggedTypeRef(); Identifier id = tr.getTag(); if (id instanceof SimpleIdentifier) { return Collections.singletonList(((SimpleIdentifier) id).getName()); } } return Collections.EMPTY_LIST; }
TaggedTypeRef ttr = sd.getValueType() instanceof TaggedTypeRef ? (TaggedTypeRef) sd.getValueType() : null; String idealName = null; if (ttr != null && ttr.getTag() != null) { for (Declarator st : sd.getDeclarators()) { if (st instanceof DirectDeclarator) { DirectDeclarator decl = (DirectDeclarator) st;
List<String> getNames(Declaration d) { if (d instanceof StoredDeclarations) { List<String> ret = new ArrayList<String>(); for (Declarator declarator : ((StoredDeclarations) d).getDeclarators()) { ret.add(declarator.resolveName()); } return ret; } else if (d instanceof TaggedTypeRefDeclaration) { TaggedTypeRef tr = ((TaggedTypeRefDeclaration) d).getTaggedTypeRef(); Identifier id = tr.getTag(); if (id instanceof SimpleIdentifier) { return Collections.singletonList(((SimpleIdentifier) id).getName()); } } return Collections.EMPTY_LIST; }