From 0c6973b15cc3884f35d7d414ab7d23d365c768e8 Mon Sep 17 00:00:00 2001 From: Jedrzej Nowacki Date: Wed, 12 May 2010 17:07:42 +0200 Subject: 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 --- tests/auto/qscriptvalue/testgen/testgenerator.cpp | 82 +++++++++++++---------- 1 file 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& 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 %1;\n"\ @@ -193,9 +193,11 @@ static QString generateIsXXXDef(const QString& name, const QList& 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 %1;\n"\ @@ -236,16 +238,18 @@ static QString generateToXXXDef(const QString& name, const QList >::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 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(const QString& name, const QList %1;\n"\ @@ -301,16 +305,18 @@ QString generateToXXXDef(const QString& name, const QList >::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 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 >& 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 value;\n"\ @@ -370,16 +376,18 @@ static QString generateCastDef(const QList >& list) typename QList >::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 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(const QList >& 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 value;\n"\ @@ -434,16 +442,18 @@ QString generateCastDef(const QList >& list) QList >::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 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 equals;\n"\ @@ -497,9 +507,13 @@ static QString generateCompareDef(const QString& comparisionType, const QList& 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"; -- cgit v0.12