diff options
author | Jedrzej Nowacki <jedrzej.nowacki@nokia.com> | 2010-05-12 15:07:42 (GMT) |
---|---|---|
committer | Jedrzej Nowacki <jedrzej.nowacki@nokia.com> | 2010-05-12 15:12:02 (GMT) |
commit | 0c6973b15cc3884f35d7d414ab7d23d365c768e8 (patch) | |
tree | 6789c19c662de7aee001ce42c4653dd0a39193cd /tests/auto/qscriptvalue | |
parent | 366913da05d833ebf447a061f9d859ec3a344658 (diff) | |
download | Qt-0c6973b15cc3884f35d7d414ab7d23d365c768e8.zip Qt-0c6973b15cc3884f35d7d414ab7d23d365c768e8.tar.gz Qt-0c6973b15cc3884f35d7d414ab7d23d365c768e8.tar.bz2 |
Fix a coding style issue in a generated code in the QScriptValue tests.
Fix the generator, few redundant commas and spaces where removed from
generated code.
The autotest suite wasn't regenerated.
Reviewed-by: Kent Hansen
Diffstat (limited to 'tests/auto/qscriptvalue')
-rw-r--r-- | tests/auto/qscriptvalue/testgen/testgenerator.cpp | 82 |
1 files changed, 48 insertions, 34 deletions
diff --git a/tests/auto/qscriptvalue/testgen/testgenerator.cpp b/tests/auto/qscriptvalue/testgen/testgenerator.cpp index 8e6d8e1..9d7d33d 100644 --- a/tests/auto/qscriptvalue/testgen/testgenerator.cpp +++ b/tests/auto/qscriptvalue/testgen/testgenerator.cpp @@ -162,7 +162,7 @@ static QString generateIsXXXDef(const QString& name, const QList<QString>& list) " initScriptValues();\n"\ "}\n"\ "\n"\ - "static QString %1_array [] = {%2};\n\n"\ + "static QString %1_array[] = {%2};\n\n"\ "void tst_QScriptValue::%1_makeData(const char* expr)\n"\ "{\n"\ " static QSet<QString> %1;\n"\ @@ -193,9 +193,11 @@ static QString generateIsXXXDef(const QString& name, const QList<QString>& list) QStringList set; set.reserve(3 * list.count()); foreach(const QString& t, list) { + if (!set.isEmpty()) + set.append("\","); set.append("\n \""); set.append(escape(t)); - set.append("\","); + set.append("\""); } return result.arg(name, set.join(QString()), QString::number(list.count())); @@ -211,8 +213,8 @@ static QString generateToXXXDef(const QString& name, const QList<QPair<QString, " initScriptValues();\n"\ "}\n"\ "\n"\ - "static QString %1_tagArray [] = {%4};\n\n"\ - "static %2 %1_valueArray [] = {%5};\n\n"\ + "static QString %1_tagArray[] = {%4};\n\n"\ + "static %2 %1_valueArray[] = {%5};\n\n"\ "void tst_QScriptValue::%1_makeData(const char* expr)\n"\ "{\n"\ " static QHash<QString, %2> %1;\n"\ @@ -236,16 +238,18 @@ static QString generateToXXXDef(const QString& name, const QList<QPair<QString, typename QList<QPair<QString, T> >::const_iterator i = list.constBegin(); QStringList tagSet, valueSet; - tagSet.reserve(list.count()); - valueSet.reserve(list.count()); + tagSet.reserve(4 * list.count()); + valueSet.reserve(3 * list.count()); for(int lineBreaker = 0; i != list.constEnd(); ++i) { QPair<QString, T> t = *i; t.first = escape(t.first); + if (!valueSet.isEmpty()) { + valueSet.append(QString(",")); + tagSet.append(QString::fromAscii(",")); + } tagSet.append(QString("\n \"")); tagSet.append(t.first); - tagSet.append(QString::fromAscii("\",")); - if (!valueSet.isEmpty()) - valueSet.append(QString(",")); + tagSet.append(QString::fromAscii("\"")); if (!((lineBreaker++)%2)) valueSet.append(QString("\n ")); else @@ -270,8 +274,8 @@ QString generateToXXXDef<qsreal>(const QString& name, const QList<QPair<QString, " initScriptValues();\n"\ "}\n"\ "\n"\ - "static QString %1_tagArray [] = {%3};\n"\ - "static %2 %1_valueArray [] = {%4};\n"\ + "static QString %1_tagArray[] = {%3};\n"\ + "static %2 %1_valueArray[] = {%4};\n"\ "void tst_QScriptValue::%1_makeData(const char* expr)\n"\ "{\n"\ " static QHash<QString, %2> %1;\n"\ @@ -301,16 +305,18 @@ QString generateToXXXDef<qsreal>(const QString& name, const QList<QPair<QString, QList<QPair<QString, qsreal> >::const_iterator i = list.constBegin(); QStringList tagSet, valueSet; - tagSet.reserve(list.count()); - valueSet.reserve(list.count()); + tagSet.reserve(4 * list.count()); + valueSet.reserve(3 * list.count()); for(int lineBreaker = 0; i != list.constEnd(); ++i) { QPair<QString, qsreal> t = *i; t.first = escape(t.first); + if (!valueSet.isEmpty()) { + valueSet.append(QString(",")); + tagSet.append(QString::fromAscii(",")); + } tagSet.append(QString("\n \"")); tagSet.append(t.first); - tagSet.append(QString::fromAscii("\",")); - if (!valueSet.isEmpty()) - valueSet.append(QString(",")); + tagSet.append(QString::fromAscii("\"")); if (!((lineBreaker++)%10)) valueSet.append(QString("\n ")); else @@ -345,8 +351,8 @@ static QString generateCastDef(const QList<QPair<QString, T> >& list) " initScriptValues();\n"\ "}\n"\ "\n"\ - "static QString qscriptvalue_cast%1_tagArray [] = {%2};\n"\ - "static %1 qscriptvalue_cast%1_valueArray [] = {%3};\n"\ + "static QString qscriptvalue_cast%1_tagArray[] = {%2};\n"\ + "static %1 qscriptvalue_cast%1_valueArray[] = {%3};\n"\ "void tst_QScriptValue::qscriptvalue_cast%1_makeData(const char* expr)\n"\ "{\n"\ " static QHash<QString, %1> value;\n"\ @@ -370,16 +376,18 @@ static QString generateCastDef(const QList<QPair<QString, T> >& list) typename QList<QPair<QString, T> >::const_iterator i = list.constBegin(); QStringList tagSet, valueSet; - tagSet.reserve(list.count()); - valueSet.reserve(list.count()); + tagSet.reserve(4 * list.count()); + valueSet.reserve(3 * list.count()); for(int lineBreaker = 0; i != list.constEnd(); ++i) { QPair<QString, T> t = *i; t.first = escape(t.first); + if (!valueSet.isEmpty()) { + valueSet.append(QString(",")); + tagSet.append(QString::fromAscii(",")); + } tagSet.append(QString("\n \"")); tagSet.append(t.first); - tagSet.append(QString::fromAscii("\",")); - if (!valueSet.isEmpty()) - valueSet.append(QString(",")); + tagSet.append(QString::fromAscii("\"")); if (!((lineBreaker++)%2)) valueSet.append(QString("\n ")); else @@ -399,8 +407,8 @@ QString generateCastDef<qsreal>(const QList<QPair<QString, qsreal> >& list) " initScriptValues();\n"\ "}\n"\ "\n"\ - "static QString qscriptvalue_cast%1_tagArray [] = {%2};\n"\ - "static %1 qscriptvalue_cast%1_valueArray [] = {%3};\n"\ + "static QString qscriptvalue_cast%1_tagArray[] = {%2};\n"\ + "static %1 qscriptvalue_cast%1_valueArray[] = {%3};\n"\ "void tst_QScriptValue::qscriptvalue_cast%1_makeData(const char* expr)\n"\ "{\n"\ " static QHash<QString, %1> value;\n"\ @@ -434,16 +442,18 @@ QString generateCastDef<qsreal>(const QList<QPair<QString, qsreal> >& list) QList<QPair<QString, qsreal> >::const_iterator i = list.constBegin(); QStringList tagSet, valueSet; - tagSet.reserve(list.count()); - valueSet.reserve(list.count()); + tagSet.reserve(4 * list.count()); + valueSet.reserve(3 * list.count()); for(int lineBreaker = 0; i != list.constEnd(); ++i) { QPair<QString, qsreal> t = *i; t.first = escape(t.first); + if (!valueSet.isEmpty()) { + valueSet.append(QString(",")); + tagSet.append(QString::fromAscii(",")); + } tagSet.append(QString("\n \"")); tagSet.append(t.first); - tagSet.append(QString::fromAscii("\",")); - if (!valueSet.isEmpty()) - valueSet.append(QString(",")); + tagSet.append(QString::fromAscii("\"")); if (!((lineBreaker++)%10)) valueSet.append(QString("\n ")); else @@ -466,7 +476,7 @@ static QString generateCompareDef(const QString& comparisionType, const QList<QS " initScriptValues();\n"\ "}\n"\ "\n"\ - "static QString %1_array [] = {%2};\n\n"\ + "static QString %1_array[] = {%2};\n\n"\ "void tst_QScriptValue::%1_makeData(const char *expr)\n"\ "{\n"\ " static QSet<QString> equals;\n"\ @@ -497,9 +507,13 @@ static QString generateCompareDef(const QString& comparisionType, const QList<QS QString result = templ; QStringList set; - set.reserve(tags.count()); + set.reserve(4 * tags.count()); foreach(const QString& tmp, tags) { - set.append("\n \"" + escape(tmp) + "\","); + if (!set.isEmpty()) + set.append(","); + set.append("\n \""); + set.append(escape(tmp)); + set.append("\""); } return result.arg(comparisionType, set.join(""), QString::number(tags.count())); } @@ -509,7 +523,7 @@ static QString generateInitDef(const QVector<QString>& allDataTags) static const QString templ = "void tst_QScriptValue::initScriptValues()\n"\ "{\n"\ " m_values.clear();\n"\ - " if (engine) \n"\ + " if (engine)\n"\ " delete engine;\n"\ " engine = new QScriptEngine;\n"\ "%1\n}\n\n"; |