diff options
author | Henri Chain <henri.chain@enioka.com> | 2020-02-18 23:21:30 +0100 |
---|---|---|
committer | Henri Chain <henri.chain@enioka.com> | 2020-02-25 15:46:53 +0100 |
commit | d218b93a535085c85889164d45a83c3a519f9f4b (patch) | |
tree | b9c051db2691321c6ef604cd138342b0f3e39fea /src/kconfig_compiler/KConfigSourceGenerator.cpp | |
parent | c8bf5e96cf2f25bb85330cf2587e2e365e6f0f71 (diff) | |
download | kconfig-d218b93a535085c85889164d45a83c3a519f9f4b.tar.gz kconfig-d218b93a535085c85889164d45a83c3a519f9f4b.tar.bz2 |
Fix code generation for entries with min/max
Summary:
- When GenerateProperties and Mutators are activated, the generated code
did not handle min/max properly
- In the case of a parameterized entry, generated code also did not
handle min/max
BUG: 418146
Test Plan: - auto tests included
Reviewers: meven, crossi, ervin, bport, tcanabrava
Reviewed By: meven, ervin
Subscribers: kde-frameworks-devel
Tags: #frameworks
Differential Revision: https://phabricator.kde.org/D27497
Diffstat (limited to 'src/kconfig_compiler/KConfigSourceGenerator.cpp')
-rw-r--r-- | src/kconfig_compiler/KConfigSourceGenerator.cpp | 46 |
1 files changed, 33 insertions, 13 deletions
diff --git a/src/kconfig_compiler/KConfigSourceGenerator.cpp b/src/kconfig_compiler/KConfigSourceGenerator.cpp index 63f5b6b4..33e0ed69 100644 --- a/src/kconfig_compiler/KConfigSourceGenerator.cpp +++ b/src/kconfig_compiler/KConfigSourceGenerator.cpp @@ -313,14 +313,21 @@ void KConfigSourceGenerator::createEnums(const CfgEntry *entry) void KConfigSourceGenerator::createNormalEntry(const CfgEntry *entry, const QString &key) { - stream() << " " << itemPath(entry, cfg()) << " = " + const QString innerItemVarStr = innerItemVar(entry, cfg()); + if (!entry->signalList.isEmpty()) { + stream() << " " << innerItemVarStr << " = " + << newInnerItem(entry, key, entry->defaultValue, cfg()) << '\n'; + } + + stream() << " " << itemPath(entry, cfg()) << " = " << newItem(entry, key, entry->defaultValue, cfg()) << '\n'; if (!entry->min.isEmpty()) { - stream() << " " << itemPath(entry, cfg()) << "->setMinValue(" << entry->min << ");\n"; + stream() << " " << innerItemVarStr << "->setMinValue(" << entry->min << ");\n"; } + if (!entry->max.isEmpty()) { - stream() << " " << itemPath(entry, cfg()) << "->setMaxValue(" << entry->max << ");\n"; + stream() << " " << innerItemVarStr << "->setMaxValue(" << entry->max << ");\n"; } if (cfg().setUserTexts) { @@ -343,14 +350,29 @@ void KConfigSourceGenerator::createNormalEntry(const CfgEntry *entry, const QStr void KConfigSourceGenerator::createIndexedEntry(const CfgEntry *entry, const QString &key) { for (int i = 0; i <= entry->paramMax; i++) { - QString itemVarStr(itemPath(entry, cfg()) + QStringLiteral("[%1]").arg(i)); + 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); + + if (!entry->signalList.isEmpty()) { + stream() << " " << innerItemVarStr << " = " + << newInnerItem(entry, paramString(key, entry, i), defaultStr, cfg(), argBracket) << '\n'; + } + + const QString itemVarStr = itemPath(entry, cfg()) + argBracket; - QString defaultStr = !entry->paramDefaultValues[i].isEmpty() ? entry->paramDefaultValues[i] - : !entry->defaultValue.isEmpty() ? paramString(entry->defaultValue, entry, i) - : defaultValue(entry->type); - stream() << " " << itemVarStr << " = " - << newItem(entry, paramString(key, entry, i), defaultStr, cfg(), QStringLiteral("[%1]").arg(i)) << '\n'; + << newItem(entry, paramString(key, entry, i), defaultStr, cfg(), argBracket) << '\n'; + + if (!entry->min.isEmpty()) { + stream() << " " << innerItemVarStr << "->setMinValue(" << entry->min << ");\n"; + } + if (!entry->max.isEmpty()) { + stream() << " " << innerItemVarStr << "->setMaxValue(" << entry->max << ");\n"; + } if (cfg().setUserTexts) { stream() << userTextsFunctions(entry, cfg(), itemVarStr, entry->paramName); @@ -366,7 +388,7 @@ void KConfigSourceGenerator::createIndexedEntry(const CfgEntry *entry, const QSt QString paramName = entry->paramName; stream() << " addItem( " << itemVarStr << ", QStringLiteral( \""; - stream() << paramName.replace(QStringLiteral("$(") + entry->param + QLatin1Char(')'), QLatin1String("%1")).arg( arg ); + stream() << paramName.replace(QStringLiteral("$(") + entry->param + QLatin1Char(')'), QLatin1String("%1")).arg(arg); stream() << "\" ) );\n"; } } @@ -440,9 +462,7 @@ void KConfigSourceGenerator::doConstructor() } createEnums(entry); - if (!cfg().dpointer) { - stream() << itemDeclaration(entry, cfg()); - } + stream() << itemDeclaration(entry, cfg()); if (entry->param.isEmpty()) { createNormalEntry(entry, key); |