diff options
author | Ahmad Samir <a.samirh78@gmail.com> | 2021-02-22 17:38:09 +0200 |
---|---|---|
committer | Ahmad Samir <a.samirh78@gmail.com> | 2021-02-22 17:38:09 +0200 |
commit | 8bed00ab34e31f2b9c70026d418d923913325798 (patch) | |
tree | f289c15575415a36bc19c047a2037998e9b11ce8 /src/kconfig_compiler | |
parent | 186755fd56b58dc97250846c5305ef89f9487f86 (diff) | |
download | kconfig-8bed00ab34e31f2b9c70026d418d923913325798.tar.gz kconfig-8bed00ab34e31f2b9c70026d418d923913325798.tar.bz2 |
Run clang-format on all cpp/h files
NO_CHANGELOG
Diffstat (limited to 'src/kconfig_compiler')
-rw-r--r-- | src/kconfig_compiler/KConfigCodeGeneratorBase.cpp | 30 | ||||
-rw-r--r-- | src/kconfig_compiler/KConfigCodeGeneratorBase.h | 70 | ||||
-rw-r--r-- | src/kconfig_compiler/KConfigCommonStructs.h | 52 | ||||
-rw-r--r-- | src/kconfig_compiler/KConfigHeaderGenerator.cpp | 46 | ||||
-rw-r--r-- | src/kconfig_compiler/KConfigHeaderGenerator.h | 13 | ||||
-rw-r--r-- | src/kconfig_compiler/KConfigParameters.h | 10 | ||||
-rw-r--r-- | src/kconfig_compiler/KConfigSourceGenerator.cpp | 74 | ||||
-rw-r--r-- | src/kconfig_compiler/KConfigSourceGenerator.h | 11 | ||||
-rw-r--r-- | src/kconfig_compiler/KConfigXmlParser.cpp | 69 | ||||
-rw-r--r-- | src/kconfig_compiler/KConfigXmlParser.h | 2 | ||||
-rw-r--r-- | src/kconfig_compiler/kconfig_compiler.cpp | 99 |
11 files changed, 233 insertions, 243 deletions
diff --git a/src/kconfig_compiler/KConfigCodeGeneratorBase.cpp b/src/kconfig_compiler/KConfigCodeGeneratorBase.cpp index 3f308cbb..27a96488 100644 --- a/src/kconfig_compiler/KConfigCodeGeneratorBase.cpp +++ b/src/kconfig_compiler/KConfigCodeGeneratorBase.cpp @@ -13,21 +13,24 @@ #include "KConfigCodeGeneratorBase.h" -#include <QLatin1Char> #include <QFileInfo> +#include <QLatin1Char> -#include <ostream> #include <QDebug> +#include <ostream> #include <iostream> -KConfigCodeGeneratorBase::KConfigCodeGeneratorBase( - const QString &inputFile, - const QString &baseDir, - const QString &fileName, - const KConfigParameters ¶meters, - ParseResult &parseResult) - : parseResult(parseResult), m_inputFile(inputFile), m_baseDir(baseDir), m_fileName(fileName), m_cfg(parameters) +KConfigCodeGeneratorBase::KConfigCodeGeneratorBase(const QString &inputFile, + const QString &baseDir, + const QString &fileName, + const KConfigParameters ¶meters, + ParseResult &parseResult) + : parseResult(parseResult) + , m_inputFile(inputFile) + , m_baseDir(baseDir) + , m_fileName(fileName) + , m_cfg(parameters) { m_file.setFileName(m_fileName); if (!m_file.open(QIODevice::WriteOnly)) { @@ -54,7 +57,7 @@ void KConfigCodeGeneratorBase::save() m_file.close(); } -//TODO: Remove this weird logic and adapt the testcases +// TODO: Remove this weird logic and adapt the testcases void KConfigCodeGeneratorBase::indent() { if (m_indentLevel >= 4) { @@ -102,7 +105,8 @@ void KConfigCodeGeneratorBase::endScope(ScopeFinalizer finalizer) void KConfigCodeGeneratorBase::start() { const QString m_fileName = QFileInfo(m_inputFile).fileName(); - m_stream << "// This file is generated by kconfig_compiler_kf5 from " << m_fileName << ".kcfg" << ".\n"; + m_stream << "// This file is generated by kconfig_compiler_kf5 from " << m_fileName << ".kcfg" + << ".\n"; m_stream << "// All changes you do to this file will be lost.\n"; } @@ -214,7 +218,6 @@ void KConfigCodeGeneratorBase::createIfSetLogic(const CfgEntry *e, const QString void KConfigCodeGeneratorBase::memberMutatorBody(const CfgEntry *e) { - // HACK: Don't open '{' manually, use startScope / endScope to automatically handle whitespace indentation. if (!e->min.isEmpty()) { if (e->min != QLatin1String("0") || !isUnsigned(e->type)) { // skip writing "if uint<0" (#187579) @@ -254,8 +257,7 @@ void KConfigCodeGeneratorBase::memberMutatorBody(const CfgEntry *e) if (signal.modify) { m_stream << whitespace() << " Q_EMIT " << m_this << signal.name << "();\n"; } else { - m_stream << whitespace() << " " << m_this << varPath(QStringLiteral("settingsChanged"), m_cfg) - << " |= " << signalEnumName(signal.name) << ";\n"; + m_stream << whitespace() << " " << m_this << varPath(QStringLiteral("settingsChanged"), m_cfg) << " |= " << signalEnumName(signal.name) << ";\n"; } } if (hasBody) { diff --git a/src/kconfig_compiler/KConfigCodeGeneratorBase.h b/src/kconfig_compiler/KConfigCodeGeneratorBase.h index e9d2a955..4a100518 100644 --- a/src/kconfig_compiler/KConfigCodeGeneratorBase.h +++ b/src/kconfig_compiler/KConfigCodeGeneratorBase.h @@ -14,28 +14,31 @@ #ifndef KCONFIGCODEGENERATORBASE_H #define KCONFIGCODEGENERATORBASE_H +#include <QFile> #include <QString> #include <QTextStream> -#include <QFile> #include <QVector> -#include "KConfigParameters.h" #include "KConfigCommonStructs.h" +#include "KConfigParameters.h" class CfgEntry; struct ParseResult; /* This class manages the base of writing a C - Based code */ -class KConfigCodeGeneratorBase { +class KConfigCodeGeneratorBase +{ public: - enum ScopeFinalizer {None, Semicolon,}; - - KConfigCodeGeneratorBase( - const QString &inputFileName, // The kcfg file - const QString &baseDir, // where we should store the generated file - const QString &fileName, // the name of the generated file - const KConfigParameters ¶meters, // parameters passed to the generator - ParseResult &parseResult // The pre processed configuration entries + enum ScopeFinalizer { + None, + Semicolon, + }; + + KConfigCodeGeneratorBase(const QString &inputFileName, // The kcfg file + const QString &baseDir, // where we should store the generated file + const QString &fileName, // the name of the generated file + const KConfigParameters ¶meters, // parameters passed to the generator + ParseResult &parseResult // The pre processed configuration entries ); virtual ~KConfigCodeGeneratorBase(); @@ -87,32 +90,53 @@ protected: /* reduce the number of spaces for the indentation level */ void unindent(); - QString inputFile() const { return m_inputFile; } - QString fileName() const { return m_fileName; } - QString baseDir() const { return m_baseDir; } - QString This() const { return m_this; } - QString Const() const { return m_const; } - KConfigParameters cfg() const { return m_cfg; } + QString inputFile() const + { + return m_inputFile; + } + QString fileName() const + { + return m_fileName; + } + QString baseDir() const + { + return m_baseDir; + } + QString This() const + { + return m_this; + } + QString Const() const + { + return m_const; + } + KConfigParameters cfg() const + { + return m_cfg; + } // Can't be const. - QTextStream& stream() { return m_stream; } + QTextStream &stream() + { + return m_stream; + } // HACK: This needs to be accesible because the HeaderGenerator actually modifies // it while running. Considering that this is a the result of the xml Parse, and not // the result of generating code, I consider this to be quite wrong - but moving the // changes away from the header generator only created more problems and I have to // investigate more. - ParseResult &parseResult; // the result of the parsed kcfg file + ParseResult &parseResult; // the result of the parsed kcfg file private: QString m_inputFile; // the base file name, input file is based on this. - QString m_baseDir; // Where we are going to save the file - QString m_fileName; // The file name + QString m_baseDir; // Where we are going to save the file + QString m_fileName; // The file name KConfigParameters m_cfg; // The parameters passed via the kcfgc file - QTextStream m_stream; // the stream that operates in the file to write data. - QFile m_file; // The file handler. + QTextStream m_stream; // the stream that operates in the file to write data. + QFile m_file; // The file handler. // Special access to `this->` and `const` thru the code. QString m_this; diff --git a/src/kconfig_compiler/KConfigCommonStructs.h b/src/kconfig_compiler/KConfigCommonStructs.h index 8ed1d22f..43e981cb 100644 --- a/src/kconfig_compiler/KConfigCommonStructs.h +++ b/src/kconfig_compiler/KConfigCommonStructs.h @@ -14,20 +14,18 @@ #ifndef KCONFIGCOMMONSTRUCTS_H #define KCONFIGCOMMONSTRUCTS_H +#include <QList> #include <QString> #include <QVector> -#include <QList> #include "KConfigParameters.h" -struct Param -{ +struct Param { QString name; QString type; }; -struct Signal -{ +struct Signal { QString name; QString label; QList<Param> arguments; @@ -53,9 +51,13 @@ public: class Choices { public: - Choices() {} + Choices() + { + } Choices(const QList<Choice> &d, const QString &n, const QString &p) - : prefix(p), choices(d), mName(n) + : prefix(p) + , choices(d) + , mName(n) { int i = n.indexOf(QLatin1String("::")); if (i >= 0) { @@ -76,6 +78,7 @@ public: { return !mExternalQual.isEmpty(); } + private: QString mName; QString mExternalQual; @@ -161,33 +164,18 @@ QString filenameOnly(const QString &path); QString itemDeclaration(const CfgEntry *e, const KConfigParameters &cfg); -QString translatedString( - const KConfigParameters &cfg, - const QString &string, - const QString &context = QString(), - const QString ¶m = QString(), - const QString ¶mValue = QString()); +QString translatedString(const KConfigParameters &cfg, + const QString &string, + const QString &context = QString(), + const QString ¶m = QString(), + const QString ¶mValue = QString()); // TODO: Sanitize those functions. -QString newItem( - const CfgEntry *entry, - const QString &key, - const QString &defaultValue, - const KConfigParameters &cfg, - const QString ¶m = QString()); - -QString newInnerItem( - const CfgEntry *entry, - const QString &key, - const QString &defaultValue, - const KConfigParameters &cfg, - const QString ¶m = QString()); - -QString userTextsFunctions( - const CfgEntry *e, - const KConfigParameters &cfg, - QString itemVarStr = QString(), - const QString &i = QString()); +QString newItem(const CfgEntry *entry, const QString &key, const QString &defaultValue, const KConfigParameters &cfg, const QString ¶m = QString()); + +QString newInnerItem(const CfgEntry *entry, const QString &key, const QString &defaultValue, const KConfigParameters &cfg, const QString ¶m = QString()); + +QString userTextsFunctions(const CfgEntry *e, const KConfigParameters &cfg, QString itemVarStr = QString(), const QString &i = QString()); QString paramString(const QString &s, const CfgEntry *e, int i); QString paramString(const QString &group, const QList<Param> ¶meters); diff --git a/src/kconfig_compiler/KConfigHeaderGenerator.cpp b/src/kconfig_compiler/KConfigHeaderGenerator.cpp index 7829ab67..d2c7e6cf 100644 --- a/src/kconfig_compiler/KConfigHeaderGenerator.cpp +++ b/src/kconfig_compiler/KConfigHeaderGenerator.cpp @@ -13,15 +13,11 @@ #include "KConfigHeaderGenerator.h" -#include <QTextStream> #include <QDebug> +#include <QTextStream> #include <iostream> -KConfigHeaderGenerator::KConfigHeaderGenerator( - const QString &inputFile, - const QString &baseDir, - const KConfigParameters &cfg, - ParseResult &result) +KConfigHeaderGenerator::KConfigHeaderGenerator(const QString &inputFile, const QString &baseDir, const KConfigParameters &cfg, ParseResult &result) : KConfigCodeGeneratorBase(inputFile, baseDir, baseDir + cfg.baseName + QLatin1Char('.') + cfg.headerExtension, cfg, result) { } @@ -78,9 +74,7 @@ void KConfigHeaderGenerator::doClassDefinition() } // Member variables - if (!cfg().memberVariables.isEmpty() - && cfg().memberVariables != QLatin1String("private") - && cfg().memberVariables != QLatin1String("dpointer")) { + if (!cfg().memberVariables.isEmpty() && cfg().memberVariables != QLatin1String("private") && cfg().memberVariables != QLatin1String("dpointer")) { stream() << " " << cfg().memberVariables << ":\n"; } @@ -212,7 +206,7 @@ void KConfigHeaderGenerator::implementEnums() implementChoiceEnums(entry, choices); implementValueEnums(entry, values); } - stream() << '\n'; + stream() << '\n'; } void KConfigHeaderGenerator::createSignals() @@ -239,19 +233,15 @@ void KConfigHeaderGenerator::createSignals() // a last comma, as it's valid c++. for (int i = 0, end = parseResult.signalList.size(); i < end; i++) { auto signal = parseResult.signalList.at(i); - stream() << whitespace() << " " << signalEnumName(signal.name) << " = 0x" - << Qt::hex - << val; - if (i != end-1) { + stream() << whitespace() << " " << signalEnumName(signal.name) << " = 0x" << Qt::hex << val; + if (i != end - 1) { stream() << ",\n"; } val <<= 1; } stream() << '\n'; - stream() << whitespace() << "};" - << Qt::dec - << "\n\n"; + stream() << whitespace() << "};" << Qt::dec << "\n\n"; stream() << " Q_SIGNALS:"; for (const Signal &signal : qAsConst(parseResult.signalList)) { @@ -364,7 +354,7 @@ void KConfigHeaderGenerator::createForwardDeclarations() } } -void KConfigHeaderGenerator::createProperties(const CfgEntry *entry, const QString& returnType) +void KConfigHeaderGenerator::createProperties(const CfgEntry *entry, const QString &returnType) { if (!cfg().generateProperties) { return; @@ -377,8 +367,8 @@ void KConfigHeaderGenerator::createProperties(const CfgEntry *entry, const QStri stream() << " WRITE " << setFunction(entry->name); stream() << " NOTIFY " << signal; - //If we have the modified signal, we'll also need - //the changed signal as well + // If we have the modified signal, we'll also need + // the changed signal as well Signal s; s.name = signal; s.modify = true; @@ -417,12 +407,10 @@ void KConfigHeaderGenerator::createSetters(const CfgEntry *entry) stream() << whitespace() << "void " << setFunction(entry->name) << "( "; if (!entry->param.isEmpty()) { - stream() <<cppType(entry->paramType) << " i, "; + stream() << cppType(entry->paramType) << " i, "; } - stream() << (cfg().useEnumTypes && entry->type == QLatin1String("Enum") - ? enumType(entry, cfg().globalEnums) - : param(entry->type)); + stream() << (cfg().useEnumTypes && entry->type == QLatin1String("Enum") ? enumType(entry, cfg().globalEnums) : param(entry->type)); stream() << " v )"; @@ -481,7 +469,7 @@ void KConfigHeaderGenerator::createImmutableGetters(const CfgEntry *entry) stream() << whitespace() << ""; stream() << "bool " << immutableFunction(entry->name) << "("; if (!entry->param.isEmpty()) { - stream() << " " << cppType(entry->paramType)<< " i "; + stream() << " " << cppType(entry->paramType) << " i "; } stream() << ")" << Const(); // function body inline only if not using dpointer @@ -506,11 +494,9 @@ void KConfigHeaderGenerator::createItemAcessors(const CfgEntry *entry, const QSt return; } stream() << whitespace() << "/**\n"; - stream() << whitespace() << " Get Item object corresponding to " << entry->name << "()" - << '\n'; + stream() << whitespace() << " Get Item object corresponding to " << entry->name << "()" << '\n'; stream() << whitespace() << "*/\n"; - stream() << whitespace() << "Item" << itemType(entry->type) << " *" - << getFunction(entry->name) << "Item("; + stream() << whitespace() << "Item" << itemType(entry->type) << " *" << getFunction(entry->name) << "Item("; if (!entry->param.isEmpty()) { stream() << " " << cppType(entry->paramType) << " i "; } @@ -530,7 +516,7 @@ void KConfigHeaderGenerator::createItemAcessors(const CfgEntry *entry, const QSt void KConfigHeaderGenerator::createDefaultValueMember(const CfgEntry *entry) { // Default value Accessor - if (! ((cfg().allDefaultGetters || cfg().defaultGetters.contains(entry->name)) && !entry->defaultValue.isEmpty())) { + if (!((cfg().allDefaultGetters || cfg().defaultGetters.contains(entry->name)) && !entry->defaultValue.isEmpty())) { return; } stream() << whitespace() << "/**\n"; diff --git a/src/kconfig_compiler/KConfigHeaderGenerator.h b/src/kconfig_compiler/KConfigHeaderGenerator.h index b93a47db..4c2e4561 100644 --- a/src/kconfig_compiler/KConfigHeaderGenerator.h +++ b/src/kconfig_compiler/KConfigHeaderGenerator.h @@ -17,23 +17,20 @@ #include "KConfigCodeGeneratorBase.h" #include "KConfigCommonStructs.h" -#include <QString> #include <QList> +#include <QString> class KConfigParameters; class CfgEntry; class QTextStream; struct ParseResult; -class KConfigHeaderGenerator : public KConfigCodeGeneratorBase { +class KConfigHeaderGenerator : public KConfigCodeGeneratorBase +{ public: - KConfigHeaderGenerator( - const QString &inputFile, - const QString &baseDir, - const KConfigParameters ¶meters, - ParseResult &parseResult); + KConfigHeaderGenerator(const QString &inputFile, const QString &baseDir, const KConfigParameters ¶meters, ParseResult &parseResult); - void start() override; + void start() override; private: void startHeaderGuards(); diff --git a/src/kconfig_compiler/KConfigParameters.h b/src/kconfig_compiler/KConfigParameters.h index f8619b2a..153b68dd 100644 --- a/src/kconfig_compiler/KConfigParameters.h +++ b/src/kconfig_compiler/KConfigParameters.h @@ -33,14 +33,14 @@ public: }; // These are read from the .kcfgc configuration file - QString nameSpace; // The namespace for the class to be generated - QString className; // The class name to be generated - QString inherits; // The class the generated class inherits (if empty, from KConfigSkeleton) + QString nameSpace; // The namespace for the class to be generated + QString className; // The class name to be generated + QString inherits; // The class the generated class inherits (if empty, from KConfigSkeleton) QString visibility; bool parentInConstructor; // The class has the optional parent parameter in its constructor bool forceStringFilename; - bool singleton; // The class will be a singleton - bool staticAccessors; // provide or not static accessors + bool singleton; // The class will be a singleton + bool staticAccessors; // provide or not static accessors bool customAddons; QString memberVariables; QStringList headerIncludes; diff --git a/src/kconfig_compiler/KConfigSourceGenerator.cpp b/src/kconfig_compiler/KConfigSourceGenerator.cpp index 663a138f..ce6378cd 100644 --- a/src/kconfig_compiler/KConfigSourceGenerator.cpp +++ b/src/kconfig_compiler/KConfigSourceGenerator.cpp @@ -50,7 +50,7 @@ void KConfigSourceGenerator::createHeaders() // TODO: Make addQuotes return a string instead of replacing it inplace. addQuotes(headerName); - addHeaders({ headerName }); + addHeaders({headerName}); stream() << '\n'; addHeaders(cfg().sourceIncludes); @@ -108,11 +108,10 @@ void KConfigSourceGenerator::createPrivateDPointerImplementation() // Create Items. for (const auto *entry : qAsConst(parseResult.entries)) { - const QString declType = entry->signalList.isEmpty() - ? QString(cfg().inherits + QStringLiteral("::Item") + itemType(entry->type)) - : QStringLiteral("KConfigCompilerSignallingItem"); + const QString declType = entry->signalList.isEmpty() ? QString(cfg().inherits + QStringLiteral("::Item") + itemType(entry->type)) + : QStringLiteral("KConfigCompilerSignallingItem"); - stream() << " " << declType << " *" << itemVar( entry, cfg() ); + stream() << " " << declType << " *" << itemVar(entry, cfg()); if (!entry->param.isEmpty()) { stream() << QStringLiteral("[%1]").arg(entry->paramMax + 1); } @@ -163,7 +162,7 @@ void KConfigSourceGenerator::createSingletonImplementation() stream() << "}\n\n"; if (parseResult.cfgFileNameArg) { - auto instance = [this] (const QString &type, const QString &arg, bool isString) { + auto instance = [this](const QString &type, const QString &arg, bool isString) { stream() << "void " << cfg().className << "::instance(" << type << " " << arg << ")\n"; stream() << "{\n"; stream() << " if (s_global" << cfg().className << "()->q) {\n"; @@ -215,8 +214,7 @@ void KConfigSourceGenerator::createConstructorParameterList() stream() << (parseResult.parameters.isEmpty() ? "" : ","); } - for (QList<Param>::ConstIterator it = parseResult.parameters.constBegin(); - it != parseResult.parameters.constEnd(); ++it) { + for (QList<Param>::ConstIterator it = parseResult.parameters.constBegin(); it != parseResult.parameters.constEnd(); ++it) { if (it != parseResult.parameters.constBegin()) { stream() << ","; } @@ -229,7 +227,6 @@ void KConfigSourceGenerator::createConstructorParameterList() } stream() << " QObject *parent"; } - } void KConfigSourceGenerator::createParentConstructorCall() @@ -239,7 +236,7 @@ void KConfigSourceGenerator::createParentConstructorCall() stream() << " QStringLiteral( \"" << parseResult.cfgFileName << "\" "; } if (parseResult.cfgFileNameArg) { - if (! cfg().forceStringFilename) { + if (!cfg().forceStringFilename) { stream() << " std::move( config ) "; } else { stream() << " config "; @@ -275,19 +272,13 @@ void KConfigSourceGenerator::createEnums(const CfgEntry *entry) stream() << " choice.name = QStringLiteral(\"" << choice.name << "\");\n"; if (cfg().setUserTexts) { if (!choice.label.isEmpty()) { - stream() << " choice.label = " - << translatedString(cfg(), choice.label, choice.context) - << ";\n"; + stream() << " choice.label = " << translatedString(cfg(), choice.label, choice.context) << ";\n"; } if (!choice.toolTip.isEmpty()) { - stream() << " choice.toolTip = " - << translatedString(cfg(), choice.toolTip, choice.context) - << ";\n"; + stream() << " choice.toolTip = " << translatedString(cfg(), choice.toolTip, choice.context) << ";\n"; } if (!choice.whatsThis.isEmpty()) { - stream() << " choice.whatsThis = " - << translatedString(cfg(), choice.whatsThis, choice.context) - << ";\n"; + stream() << " choice.whatsThis = " << translatedString(cfg(), choice.whatsThis, choice.context) << ";\n"; } } stream() << " values" << entry->name << ".append( choice );\n"; @@ -300,12 +291,10 @@ void KConfigSourceGenerator::createNormalEntry(const CfgEntry *entry, const QStr const QString itemVarStr = itemPath(entry, cfg()); const QString innerItemVarStr = innerItemVar(entry, cfg()); if (!entry->signalList.isEmpty()) { - stream() << " " << innerItemVarStr << " = " - << newInnerItem(entry, key, entry->defaultValue, cfg()) << '\n'; + stream() << " " << innerItemVarStr << " = " << newInnerItem(entry, key, entry->defaultValue, cfg()) << '\n'; } - stream() << " " << itemVarStr << " = " - << newItem(entry, key, entry->defaultValue, cfg()) << '\n'; + stream() << " " << itemVarStr << " = " << newItem(entry, key, entry->defaultValue, cfg()) << '\n'; if (!entry->min.isEmpty()) { stream() << " " << innerItemVarStr << "->setMinValue(" << entry->min << ");\n"; @@ -353,19 +342,17 @@ void KConfigSourceGenerator::createIndexedEntry(const CfgEntry *entry, const QSt const QString argBracket = QStringLiteral("[%1]").arg(i); const QString innerItemVarStr = innerItemVar(entry, cfg()) + argBracket; - const QString defaultStr = !entry->paramDefaultValues[i].isEmpty() - ? entry->paramDefaultValues[i] - : !entry->defaultValue.isEmpty() ? paramString(entry->defaultValue, entry, i) : defaultValue(entry->type); + const QString defaultStr = !entry->paramDefaultValues[i].isEmpty() ? entry->paramDefaultValues[i] + : !entry->defaultValue.isEmpty() ? paramString(entry->defaultValue, entry, i) + : defaultValue(entry->type); if (!entry->signalList.isEmpty()) { - stream() << " " << innerItemVarStr << " = " - << newInnerItem(entry, paramString(key, entry, i), defaultStr, cfg(), argBracket) << '\n'; + stream() << " " << innerItemVarStr << " = " << newInnerItem(entry, paramString(key, entry, i), defaultStr, cfg(), argBracket) << '\n'; } const QString itemVarStr = itemPath(entry, cfg()) + argBracket; - stream() << " " << itemVarStr << " = " - << newItem(entry, paramString(key, entry, i), defaultStr, cfg(), argBracket) << '\n'; + stream() << " " << itemVarStr << " = " << newItem(entry, paramString(key, entry, i), defaultStr, cfg(), argBracket) << '\n'; if (!entry->min.isEmpty()) { stream() << " " << innerItemVarStr << "->setMinValue(" << entry->min << ");\n"; @@ -376,7 +363,8 @@ void KConfigSourceGenerator::createIndexedEntry(const CfgEntry *entry, const QSt for (const CfgEntry::Choice &choice : qAsConst(entry->choices.choices)) { if (!choice.val.isEmpty()) { - stream() << " " << itemVarStr << "->setValueForChoice(QStringLiteral( \"" << choice.name << "\" ), QStringLiteral( \"" << choice.val << "\" ));\n"; + stream() << " " << itemVarStr << "->setValueForChoice(QStringLiteral( \"" << choice.name << "\" ), QStringLiteral( \"" << choice.val + << "\" ));\n"; } } @@ -419,14 +407,12 @@ void KConfigSourceGenerator::handleCurrentGroupChange(const CfgEntry *entry) if (!entry->parentGroup.isEmpty()) { QString parentGroup = QString(entry->parentGroup).remove(QRegularExpression(QStringLiteral("\\W"))); if (!mConfigGroupList.contains(parentGroup)) { - stream() << " KConfigGroup cg" << parentGroup - << "(this->config(), " << paramString(entry->parentGroup, parseResult.parameters) << ");\n"; + stream() << " KConfigGroup cg" << parentGroup << "(this->config(), " << paramString(entry->parentGroup, parseResult.parameters) << ");\n"; mConfigGroupList << parentGroup; } QString currentGroup = QString(mCurrentGroup).remove(QRegularExpression(QStringLiteral("\\W"))); if (!mConfigGroupList.contains(currentGroup)) { - stream() << " KConfigGroup cg" << currentGroup - << " = cg" << QString(entry->parentGroup).remove(QRegularExpression(QStringLiteral("\\W"))) + stream() << " KConfigGroup cg" << currentGroup << " = cg" << QString(entry->parentGroup).remove(QRegularExpression(QStringLiteral("\\W"))) << ".group(" << paramString(mCurrentGroup, parseResult.parameters) << ");\n"; mConfigGroupList << currentGroup; } @@ -470,8 +456,7 @@ void KConfigSourceGenerator::doConstructor() // this cast to base-class pointer-to-member is valid C++ // https://stackoverflow.com/questions/4272909/is-it-safe-to-upcast-a-method-pointer-and-use-it-with-base-class-pointer/ stream() << " KConfigCompilerSignallingItem::NotifyFunction notifyFunction =" - << " static_cast<KConfigCompilerSignallingItem::NotifyFunction>(&" - << cfg().className << "::itemChanged);\n"; + << " static_cast<KConfigCompilerSignallingItem::NotifyFunction>(&" << cfg().className << "::itemChanged);\n"; stream() << '\n'; } @@ -524,7 +509,8 @@ void KConfigSourceGenerator::createGetterDPointerMode(const CfgEntry *entry) void KConfigSourceGenerator::createImmutableGetterDPointerMode(const CfgEntry *entry) { stream() << whitespace() << ""; - stream() << "bool " << " " << immutableFunction(entry->name, cfg().className) << "("; + stream() << "bool " + << " " << immutableFunction(entry->name, cfg().className) << "("; if (!entry->param.isEmpty()) { stream() << " " << cppType(entry->paramType) << " i "; } @@ -569,8 +555,7 @@ void KConfigSourceGenerator::createItemGetterDPointerMode(const CfgEntry *entry) return; } stream() << '\n'; - stream() << cfg().inherits << "::Item" << itemType(entry->type) << " *" - << getFunction(entry->name, cfg().className) << "Item("; + stream() << cfg().inherits << "::Item" << itemType(entry->type) << " *" << getFunction(entry->name, cfg().className) << "Item("; if (!entry->param.isEmpty()) { stream() << " " << cppType(entry->paramType) << " i "; } @@ -637,7 +622,8 @@ void KConfigSourceGenerator::createNonModifyingSignalsHelper() if (!parseResult.hasNonModifySignals) { return; } - stream() << "bool " << cfg().className << "::" << "usrSave()\n"; + stream() << "bool " << cfg().className << "::" + << "usrSave()\n"; startScope(); stream() << " const bool res = " << cfg().inherits << "::usrSave();\n"; stream() << " if (!res) return false;\n\n"; @@ -685,7 +671,8 @@ void KConfigSourceGenerator::createSignalFlagsHandler() } stream() << '\n'; - stream() << "void " << cfg().className << "::" << "itemChanged(quint64 flags) {\n"; + stream() << "void " << cfg().className << "::" + << "itemChanged(quint64 flags) {\n"; if (parseResult.hasNonModifySignals) stream() << " " << varPath(QStringLiteral("settingsChanged"), cfg()) << " |= flags;\n"; @@ -703,7 +690,8 @@ void KConfigSourceGenerator::createSignalFlagsHandler() stream() << "}\n"; } -void KConfigSourceGenerator::includeMoc() { +void KConfigSourceGenerator::includeMoc() +{ const QString mocFileName = cfg().baseName + QStringLiteral(".moc"); if (parseResult.signalList.count() || cfg().generateProperties) { diff --git a/src/kconfig_compiler/KConfigSourceGenerator.h b/src/kconfig_compiler/KConfigSourceGenerator.h index db2c8e72..4b3ef96c 100644 --- a/src/kconfig_compiler/KConfigSourceGenerator.h +++ b/src/kconfig_compiler/KConfigSourceGenerator.h @@ -17,21 +17,18 @@ #include "KConfigCodeGeneratorBase.h" #include "KConfigCommonStructs.h" -#include <QString> #include <QList> +#include <QString> class KConfigParameters; class CfgEntry; class QTextStream; struct ParseResult; -class KConfigSourceGenerator : public KConfigCodeGeneratorBase { +class KConfigSourceGenerator : public KConfigCodeGeneratorBase +{ public: - KConfigSourceGenerator( - const QString &inputFile, - const QString &baseDir, - const KConfigParameters ¶meters, - ParseResult &parseResult); + KConfigSourceGenerator(const QString &inputFile, const QString &baseDir, const KConfigParameters ¶meters, ParseResult &parseResult); void start() override; diff --git a/src/kconfig_compiler/KConfigXmlParser.cpp b/src/kconfig_compiler/KConfigXmlParser.cpp index e1010564..97d61342 100644 --- a/src/kconfig_compiler/KConfigXmlParser.cpp +++ b/src/kconfig_compiler/KConfigXmlParser.cpp @@ -21,13 +21,15 @@ #include <QStringList> #include <QTextStream> #include <iostream> -//TODO: Move preprocessDefault to Header / CPP implementation. +// TODO: Move preprocessDefault to Header / CPP implementation. // it makes no sense for a parser to process those values and generate code. -static void preProcessDefault(QString &defaultValue, const QString &name, +static void preProcessDefault(QString &defaultValue, + const QString &name, const QString &type, const CfgEntry::Choices &choices, - QString &code, const KConfigParameters &cfg) + QString &code, + const KConfigParameters &cfg) { if (type == QLatin1String("String") && !defaultValue.isEmpty()) { defaultValue = literalString(defaultValue); @@ -64,8 +66,7 @@ static void preProcessDefault(QString &defaultValue, const QString &name, defaultValue = QLatin1String("default") + name; } else if (type == QLatin1String("Color") && !defaultValue.isEmpty()) { - const QRegularExpression colorRe(QRegularExpression::anchoredPattern( - QStringLiteral("\\d+,\\s*\\d+,\\s*\\d+(,\\s*\\d+)?"))); + const QRegularExpression colorRe(QRegularExpression::anchoredPattern(QStringLiteral("\\d+,\\s*\\d+,\\s*\\d+(,\\s*\\d+)?"))); if (colorRe.match(defaultValue).hasMatch()) { defaultValue = QLatin1String("QColor( ") + defaultValue + QLatin1String(" )"); @@ -124,7 +125,7 @@ void KConfigXmlParser::readParameterFromEntry(CfgEntry &readEntry, const QDomEle if (readEntry.param.isEmpty()) { std::cerr << "Parameter must have a name: " << qPrintable(dumpNode(e)) << std::endl; - exit (1); + exit(1); } if (readEntry.paramType.isEmpty()) { @@ -157,7 +158,7 @@ void KConfigXmlParser::readParameterFromEntry(CfgEntry &readEntry, const QDomEle readEntry.paramMax = readEntry.paramValues.count() - 1; } else { std::cerr << "Parameter '" << qPrintable(readEntry.param) << "' has type " << qPrintable(readEntry.paramType) - << " but must be of type int, uint or Enum." << std::endl; + << " but must be of type int, uint or Enum." << std::endl; exit(1); } } @@ -190,7 +191,8 @@ void KConfigXmlParser::readChoicesFromEntry(CfgEntry &readEntry, const QDomEleme if (choice.name.isEmpty()) { std::cerr << "Tag <choice> requires attribute 'name'." << std::endl; } else if (!choiceNameRegex.match(choice.name).hasMatch()) { - std::cerr << "Tag <choice> attribute 'name' must be compatible with Enum naming. name was '" << qPrintable(choice.name) << "'. You can use attribute 'value' to pass any string as the choice value." << std::endl; + std::cerr << "Tag <choice> attribute 'name' must be compatible with Enum naming. name was '" << qPrintable(choice.name) + << "'. You can use attribute 'value' to pass any string as the choice value." << std::endl; } choice.val = e2.attribute(QStringLiteral("value")); for (QDomElement e3 = e2.firstChildElement(); !e3.isNull(); e3 = e3.nextSiblingElement()) { @@ -266,7 +268,7 @@ void KConfigXmlParser::validateNameAndKey(CfgEntry &readEntry, const QDomElement bool nameIsEmpty = readEntry.name.isEmpty(); if (nameIsEmpty && readEntry.key.isEmpty()) { std::cerr << "Entry must have a name or a key: " << qPrintable(dumpNode(element)) << std::endl; - exit (1); + exit(1); } if (readEntry.key.isEmpty()) { @@ -284,12 +286,12 @@ void KConfigXmlParser::validateNameAndKey(CfgEntry &readEntry, const QDomElement if (readEntry.name.contains(QStringLiteral("$("))) { if (readEntry.param.isEmpty()) { std::cerr << "Name may not be parameterized: " << qPrintable(readEntry.name) << std::endl; - exit (1); + exit(1); } } else { if (!readEntry.param.isEmpty()) { std::cerr << "Name must contain '$(" << qPrintable(readEntry.param) << ")': " << qPrintable(readEntry.name) << std::endl; - exit (1); + exit(1); } } } @@ -324,13 +326,13 @@ void KConfigXmlParser::readParamDefaultValues(CfgEntry &readEntry, const QDomEle i = readEntry.paramValues.indexOf(index); if (i == -1) { std::cerr << "Index '" << qPrintable(index) << "' for default value is unknown." << std::endl; - exit (1); + exit(1); } } if ((i < 0) || (i > readEntry.paramMax)) { std::cerr << "Index '" << i << "' for default value is out of range [0, " << readEntry.paramMax << "]." << std::endl; - exit (1); + exit(1); } QString tmpDefaultValue = e.text(); @@ -349,7 +351,8 @@ CfgEntry *KConfigXmlParser::parseEntry(const QString &group, const QString &pare readEntry.type = element.attribute(QStringLiteral("type")); readEntry.name = element.attribute(QStringLiteral("name")); readEntry.key = element.attribute(QStringLiteral("key")); - readEntry.hidden = element.attribute(QStringLiteral("hidden")) == QLatin1String("true");; + readEntry.hidden = element.attribute(QStringLiteral("hidden")) == QLatin1String("true"); + ; readEntry.group = group; readEntry.parentGroup = parentGroup; @@ -364,29 +367,33 @@ CfgEntry *KConfigXmlParser::parseEntry(const QString &group, const QString &pare } if (readEntry.type.isEmpty()) { - readEntry.type = QStringLiteral("String"); // XXX : implicit type might be bad + readEntry.type = QStringLiteral("String"); // XXX : implicit type might be bad } readParamDefaultValues(readEntry, element); if (!mValidNameRegexp.match(readEntry.name).hasMatch()) { if (nameIsEmpty) - std::cerr << "The key '" << qPrintable(readEntry.key) << "' can not be used as name for the entry because " - "it is not a valid name. You need to specify a valid name for this entry." << std::endl; + std::cerr << "The key '" << qPrintable(readEntry.key) + << "' can not be used as name for the entry because " + "it is not a valid name. You need to specify a valid name for this entry." + << std::endl; else { std::cerr << "The name '" << qPrintable(readEntry.name) << "' is not a valid name for an entry." << std::endl; } - exit (1); + exit(1); } if (mAllNames.contains(readEntry.name)) { if (nameIsEmpty) - std::cerr << "The key '" << qPrintable(readEntry.key) << "' can not be used as name for the entry because " - "it does not result in a unique name. You need to specify a unique name for this entry." << std::endl; + std::cerr << "The key '" << qPrintable(readEntry.key) + << "' can not be used as name for the entry because " + "it does not result in a unique name. You need to specify a unique name for this entry." + << std::endl; else { std::cerr << "The name '" << qPrintable(readEntry.name) << "' is not unique." << std::endl; } - exit (1); + exit(1); } mAllNames.append(readEntry.name); @@ -433,7 +440,8 @@ CfgEntry *KConfigXmlParser::parseEntry(const QString &group, const QString &pare // TODO: Change the name of the config variable. KConfigXmlParser::KConfigXmlParser(const KConfigParameters &cfg, const QString &inputFileName) - : cfg(cfg), mInputFileName(inputFileName) + : cfg(cfg) + , mInputFileName(inputFileName) { mValidNameRegexp.setPattern(QRegularExpression::anchoredPattern(QStringLiteral("[a-zA-Z_][a-zA-Z0-9_]*"))); } @@ -447,14 +455,15 @@ void KConfigXmlParser::start() int errorCol; if (!doc.setContent(&input, &errorMsg, &errorRow, &errorCol)) { std::cerr << "Unable to load document." << std::endl; - std::cerr << "Parse error in " << qPrintable(mInputFileName) << ", line " << errorRow << ", col " << errorCol << ": " << qPrintable(errorMsg) << std::endl; - exit (1); + std::cerr << "Parse error in " << qPrintable(mInputFileName) << ", line " << errorRow << ", col " << errorCol << ": " << qPrintable(errorMsg) + << std::endl; + exit(1); } QDomElement cfgElement = doc.documentElement(); if (cfgElement.isNull()) { std::cerr << "No document in kcfg file" << std::endl; - exit (1); + exit(1); } for (QDomElement element = cfgElement.firstChildElement(); !element.isNull(); element = element.nextSiblingElement()) { @@ -490,7 +499,7 @@ void KConfigXmlParser::readGroupTag(const QDomElement &e) QString group = e.attribute(QStringLiteral("name")); if (group.isEmpty()) { std::cerr << "Group without name" << std::endl; - exit (1); + exit(1); } const QString parentGroup = e.attribute(QStringLiteral("parentGroupName")); @@ -504,7 +513,7 @@ void KConfigXmlParser::readGroupTag(const QDomElement &e) mParseResult.entries.append(entry); } else { std::cerr << "Can not parse entry." << std::endl; - exit (1); + exit(1); } } } @@ -531,7 +540,7 @@ void KConfigXmlParser::readSignalTag(const QDomElement &e) QString signalName = e.attribute(QStringLiteral("name")); if (signalName.isEmpty()) { std::cerr << "Signal without name." << std::endl; - exit (1); + exit(1); } Signal theSignal; theSignal.name = signalName; @@ -542,9 +551,9 @@ void KConfigXmlParser::readSignalTag(const QDomElement &e) argument.type = e2.attribute(QStringLiteral("type")); if (argument.type.isEmpty()) { std::cerr << "Signal argument without type." << std::endl; - exit (1); + exit(1); } - argument.name= e2.text(); + argument.name = e2.text(); theSignal.arguments.append(argument); } else if (e2.tagName() == QLatin1String("label")) { theSignal.label = e2.text(); diff --git a/src/kconfig_compiler/KConfigXmlParser.h b/src/kconfig_compiler/KConfigXmlParser.h index 742cb496..58c2ed58 100644 --- a/src/kconfig_compiler/KConfigXmlParser.h +++ b/src/kconfig_compiler/KConfigXmlParser.h @@ -15,8 +15,8 @@ #define KCONFIGXMLPARSER_H #include <QDomDocument> -#include <QString> #include <QRegularExpression> +#include <QString> #include "KConfigCommonStructs.h" #include "KConfigParameters.h" diff --git a/src/kconfig_compiler/kconfig_compiler.cpp b/src/kconfig_compiler/kconfig_compiler.cpp index dd7b793c..449d437a 100644 --- a/src/kconfig_compiler/kconfig_compiler.cpp +++ b/src/kconfig_compiler/kconfig_compiler.cpp @@ -10,26 +10,26 @@ SPDX-License-Identifier: LGPL-2.0-or-later */ +#include <QCommandLineOption> +#include <QCommandLineParser> #include <QCoreApplication> +#include <QDomAttr> #include <QFile> #include <QFileInfo> -#include <QSettings> -#include <QTextStream> -#include <QDomAttr> #include <QRegularExpression> +#include <QSettings> #include <QStringList> -#include <QCommandLineParser> -#include <QCommandLineOption> +#include <QTextStream> -#include <ostream> +#include <algorithm> #include <iostream> +#include <ostream> #include <stdlib.h> -#include <algorithm> #include "../../kconfig_version.h" -#include "KConfigParameters.h" #include "KConfigCommonStructs.h" #include "KConfigHeaderGenerator.h" +#include "KConfigParameters.h" #include "KConfigSourceGenerator.h" #include "KConfigXmlParser.h" @@ -114,12 +114,12 @@ QString setFunction(const QString &n, const QString &className) QString changeSignalName(const QString &n) { - return n+QStringLiteral("Changed"); + return n + QStringLiteral("Changed"); } QString getDefaultFunction(const QString &n, const QString &className) { - QString result = QLatin1String("default") + n + QLatin1String("Value"); + QString result = QLatin1String("default") + n + QLatin1String("Value"); result[7] = result.at(7).toUpper(); if (!className.isEmpty()) { @@ -173,7 +173,9 @@ static QString quoteString(const QString &s) QString literalString(const QString &str) { - const bool isAscii = std::none_of(str.cbegin(), str.cend(), [](const QChar ch) { return ch.unicode() > 127; }); + const bool isAscii = std::none_of(str.cbegin(), str.cend(), [](const QChar ch) { + return ch.unicode() > 127; + }); if (isAscii) { return QLatin1String{"QStringLiteral( "} + quoteString(str) + QLatin1String{" )"}; @@ -246,7 +248,7 @@ QString param(const QString &t) return QStringLiteral("const QList<QUrl> &"); } else { std::cerr << "kconfig_compiler_kf5 does not support type \"" << qPrintable(type) << "\"" << std::endl; - return QStringLiteral("QString"); //For now, but an assert would be better + return QStringLiteral("QString"); // For now, but an assert would be better } } @@ -300,7 +302,7 @@ QString cppType(const QString &t) return QStringLiteral("QList<QUrl>"); } else { std::cerr << "kconfig_compiler_kf5 does not support type \"" << qPrintable(type) << "\"" << std::endl; - return QStringLiteral("QString"); //For now, but an assert would be better + return QStringLiteral("QString"); // For now, but an assert would be better } } @@ -308,7 +310,7 @@ QString defaultValue(const QString &t) { const QString type = t.toLower(); if (type == QLatin1String("string")) { - return QStringLiteral("\"\""); // Use empty string, not null string! + return QStringLiteral("\"\""); // Use empty string, not null string! } else if (type == QLatin1String("stringlist")) { return QStringLiteral("QStringList()"); } else if (type == QLatin1String("font")) { @@ -340,18 +342,18 @@ QString defaultValue(const QString &t) } else if (type == QLatin1String("enum")) { return QStringLiteral("0"); } else if (type == QLatin1String("path")) { - return QStringLiteral("\"\""); // Use empty string, not null string! + return QStringLiteral("\"\""); // Use empty string, not null string! } else if (type == QLatin1String("pathlist")) { return QStringLiteral("QStringList()"); } else if (type == QLatin1String("password")) { - return QStringLiteral("\"\""); // Use empty string, not null string! + return QStringLiteral("\"\""); // Use empty string, not null string! } else if (type == QLatin1String("url")) { return QStringLiteral("QUrl()"); } else if (type == QLatin1String("urllist")) { return QStringLiteral("QList<QUrl>()"); } else { std::cerr << "Error, kconfig_compiler_kf5 does not support the \"" << qPrintable(type) << "\" type!" << std::endl; - return QStringLiteral("QString"); //For now, but an assert would be better + return QStringLiteral("QString"); // For now, but an assert would be better } } @@ -381,8 +383,8 @@ QString itemDeclaration(const CfgEntry *e, const KConfigParameters &cfg) QString result; if (!cfg.itemAccessors && !cfg.dpointer) { - result += QLatin1String{" "} + (!e->signalList.isEmpty() ? QStringLiteral("KConfigCompilerSignallingItem") : type) - + QLatin1String{" *item"} + fCap + argSuffix + QLatin1String{";\n"}; + result += QLatin1String{" "} + (!e->signalList.isEmpty() ? QStringLiteral("KConfigCompilerSignallingItem") : type) + QLatin1String{" *item"} + fCap + + argSuffix + QLatin1String{";\n"}; } if (!e->signalList.isEmpty()) { @@ -434,8 +436,8 @@ QString itemPath(const CfgEntry *e, const KConfigParameters &cfg) QString newInnerItem(const CfgEntry *entry, const QString &key, const QString &defaultValue, const KConfigParameters &cfg, const QString ¶m) { - QString t = QLatin1String{"new "} + cfg.inherits + QLatin1String{"::Item"} + itemType(entry->type) - + QLatin1String{"( currentGroup(), "} + key + QLatin1String{", "} + varPath( entry->name, cfg ) + param; + QString t = QLatin1String{"new "} + cfg.inherits + QLatin1String{"::Item"} + itemType(entry->type) + QLatin1String{"( currentGroup(), "} + key + + QLatin1String{", "} + varPath(entry->name, cfg) + param; if (entry->type == QLatin1String("Enum")) { t += QLatin1String{", values"} + entry->name; @@ -523,8 +525,7 @@ QString translatedString(const KConfigParameters &cfg, const QString &string, co case KConfigParameters::KdeTranslation: if (!cfg.translationDomain.isEmpty() && !context.isEmpty()) { - result += QLatin1String{"i18ndc("} + quoteString(cfg.translationDomain) + QLatin1String{", "} - + quoteString(context) + QLatin1String{", "}; + result += QLatin1String{"i18ndc("} + quoteString(cfg.translationDomain) + QLatin1String{", "} + quoteString(context) + QLatin1String{", "}; } else if (!cfg.translationDomain.isEmpty()) { result += QLatin1String{"i18nd("} + quoteString(cfg.translationDomain) + QLatin1String{", "}; } else if (!context.isEmpty()) { @@ -573,21 +574,19 @@ QString userTextsFunctions(const CfgEntry *e, const KConfigParameters &cfg, QStr return txt; } - // returns the member mutator implementation // which should go in the h file if inline // or the cpp file if not inline -//TODO: Fix add Debug Method, it should also take the debug string. +// TODO: Fix add Debug Method, it should also take the debug string. void addDebugMethod(QTextStream &out, const KConfigParameters &cfg, const QString &n) { if (cfg.qCategoryLoggingName.isEmpty()) { - out << " qDebug() << \"" << setFunction(n); + out << " qDebug() << \"" << setFunction(n); } else { - out << " qCDebug(" << cfg.qCategoryLoggingName << ") << \"" << setFunction(n); + out << " qCDebug(" << cfg.qCategoryLoggingName << ") << \"" << setFunction(n); } } - // returns the member get default implementation // which should go in the h file if inline // or the cpp file if not inline @@ -633,7 +632,7 @@ QString itemAccessorBody(const CfgEntry *e, const KConfigParameters &cfg) return result; } -//indents text adding X spaces per line +// indents text adding X spaces per line QString indent(QString text, int spaces) { QString result; @@ -651,7 +650,7 @@ QString indent(QString text, int spaces) return result; } -bool hasErrors(KConfigXmlParser &parser, const ParseResult& parseResult, const KConfigParameters &cfg) +bool hasErrors(KConfigXmlParser &parser, const ParseResult &parseResult, const KConfigParameters &cfg) { Q_UNUSED(parser) @@ -671,18 +670,18 @@ bool hasErrors(KConfigXmlParser &parser, const ParseResult& parseResult, const K } /* TODO: For some reason some configuration files prefer to have *no* entries - * at all in it, and the generated code is mostly bogus as KConfigXT will not - * handle save / load / properties, etc, nothing. - * - * The first of those files that I came across are qmakebuilderconfig.kcfg from the KDevelop - * project. - * I think we should remove the possibility of creating configuration classes from configuration - * files that don't really have configuration in it. but I'm changing this right now to allow - * kdevelop files to pass. - * - * Remove for KDE 6 - * (to make things more interesting, it failed in a code that's never used within KDevelop... ) - */ + * at all in it, and the generated code is mostly bogus as KConfigXT will not + * handle save / load / properties, etc, nothing. + * + * The first of those files that I came across are qmakebuilderconfig.kcfg from the KDevelop + * project. + * I think we should remove the possibility of creating configuration classes from configuration + * files that don't really have configuration in it. but I'm changing this right now to allow + * kdevelop files to pass. + * + * Remove for KDE 6 + * (to make things more interesting, it failed in a code that's never used within KDevelop... ) + */ if (parseResult.entries.isEmpty()) { std::cerr << "No entries." << std::endl; return false; @@ -699,13 +698,13 @@ int main(int argc, char **argv) QString inputFilename, codegenFilename; - QCommandLineOption targetDirectoryOption(QStringList { QStringLiteral("d"), QStringLiteral("directory") }, - QCoreApplication::translate("main", "Directory to generate files in [.]"), - QCoreApplication::translate("main", "directory"), QStringLiteral(".")); + QCommandLineOption targetDirectoryOption(QStringList{QStringLiteral("d"), QStringLiteral("directory")}, + QCoreApplication::translate("main", "Directory to generate files in [.]"), + QCoreApplication::translate("main", "directory"), + QStringLiteral(".")); - QCommandLineOption licenseOption ( - QStringList { QStringLiteral("l"), QStringLiteral("license") }, - QCoreApplication::translate("main", "Display software license.")); + QCommandLineOption licenseOption(QStringList{QStringLiteral("l"), QStringLiteral("license")}, + QCoreApplication::translate("main", "Display software license.")); QCommandLineParser parser; @@ -713,7 +712,7 @@ int main(int argc, char **argv) parser.addPositionalArgument(QStringLiteral("file.kcfgc"), QStringLiteral("Code generation options file")); parser.addOption(targetDirectoryOption); - parser.addOption (licenseOption); + parser.addOption(licenseOption); parser.addVersionOption(); parser.addHelpOption(); @@ -732,7 +731,7 @@ int main(int argc, char **argv) const QStringList args = parser.positionalArguments(); if (args.count() < 2) { std::cerr << "Too few arguments." << std::endl; - return 1; + return 1; } if (args.count() > 2) { |