summaryrefslogtreecommitdiff
path: root/src/tools/gen-cpp-ast/generate-ast.cpp
diff options
context:
space:
mode:
authorChristian Kamm <christian.d.kamm@nokia.com>2011-01-05 12:17:57 +0100
committerChristian Kamm <christian.d.kamm@nokia.com>2011-01-06 15:01:52 +0100
commitd6a418fc5d4373f3a6b84838c86af718aa81d58a (patch)
treeb82a8d9801b79b0d7185c97738fa14eec875f750 /src/tools/gen-cpp-ast/generate-ast.cpp
parent261c4f1d70ef0937a2e419e1168969c6129961aa (diff)
downloadqt-creator-d6a418fc5d4373f3a6b84838c86af718aa81d58a.tar.gz
C++: Update and improve ASTPatternBuilder.
* Updated for new AST nodes. * Now also includes helpers for building Lists. Reviewed-by: Erik Verbruggen
Diffstat (limited to 'src/tools/gen-cpp-ast/generate-ast.cpp')
-rw-r--r--src/tools/gen-cpp-ast/generate-ast.cpp24
1 files changed, 20 insertions, 4 deletions
diff --git a/src/tools/gen-cpp-ast/generate-ast.cpp b/src/tools/gen-cpp-ast/generate-ast.cpp
index 1d958dcb4c..1b754353e9 100644
--- a/src/tools/gen-cpp-ast/generate-ast.cpp
+++ b/src/tools/gen-cpp-ast/generate-ast.cpp
@@ -1447,10 +1447,11 @@ void generateASTPatternBuilder_h(const QDir &cplusplusDir)
<< "public:" << endl
<< " ASTPatternBuilder() {}" << endl
<< endl
- << " void reset() { pool.reset(); };" << endl
+ << " void reset() { pool.reset(); }" << endl
<< endl;
Control *control = AST_h_document->control();
+ QSet<QString> listClasses;
foreach (ClassSpecifierAST *classNode, astNodes.deriveds) {
Class *klass = classNode->symbol;
@@ -1490,8 +1491,8 @@ void generateASTPatternBuilder_h(const QDir &cplusplusDir)
const QString tyName = oo(ptrTy->elementType());
if (tyName.endsWith("ListAST"))
- continue;
- else if (tyName.endsWith("AST")) {
+ listClasses.insert(tyName);
+ if (tyName.endsWith("AST")) {
if (! first)
out << ", ";
@@ -1521,6 +1522,21 @@ void generateASTPatternBuilder_h(const QDir &cplusplusDir)
<< endl;
}
+ foreach (const QString &className, listClasses) {
+ const QString methodName = className.left(className.length() - 3);
+ const QString elementName = className.left(className.length() - 7) + QLatin1String("AST");
+ out
+ << " " << className << " *" << methodName << "("
+ << elementName << " *value, " << className << " *next = 0)" << endl
+ << " {" << endl
+ << " " << className << " *__list = new (&pool) " << className << ";" << endl
+ << " __list->next = next;" << endl
+ << " __list->value = value;" << endl
+ << " return __list;" << endl
+ << " }" << endl
+ << endl;
+ }
+
out
<< "};" << endl
<< endl
@@ -1557,5 +1573,5 @@ int main(int argc, char *argv[])
astDerivedClasses.sort();
generateASTFwd_h(snapshot, cplusplusDir, astDerivedClasses);
- //generateASTPatternBuilder_h(cplusplusDir);
+ generateASTPatternBuilder_h(cplusplusDir);
}