diff options
author | Ahmad Samir <a.samirh78@gmail.com> | 2021-02-23 16:23:22 +0200 |
---|---|---|
committer | Ahmad Samir <a.samirh78@gmail.com> | 2021-03-06 01:35:09 +0200 |
commit | 23f55a865bdc1b5f7f462b35e8788ea3e2cbc121 (patch) | |
tree | ec343b3df49555d6264d011d35cdf1303b82e4d2 /src/kconfig_compiler | |
parent | 9d87348260316af729892c58bc29f159a173abf1 (diff) | |
download | kconfig-23f55a865bdc1b5f7f462b35e8788ea3e2cbc121.tar.gz kconfig-23f55a865bdc1b5f7f462b35e8788ea3e2cbc121.tar.bz2 |
kconfig_compiler: change how paramString() creates strings
Now it creates C++ code that uses QString::arg(Args...) instead of
arg().arg().
AFAICS, the type of the "Args" is QString, so this should work.
Diffstat (limited to 'src/kconfig_compiler')
-rw-r--r-- | src/kconfig_compiler/kconfig_compiler.cpp | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/kconfig_compiler/kconfig_compiler.cpp b/src/kconfig_compiler/kconfig_compiler.cpp index 50c54f8f..d278414e 100644 --- a/src/kconfig_compiler/kconfig_compiler.cpp +++ b/src/kconfig_compiler/kconfig_compiler.cpp @@ -490,19 +490,30 @@ QString paramString(const QString &group, const QList<Param> ¶meters) QString paramString = group; QString arguments; int i = 1; + bool firstArg = true; for (const auto ¶m : parameters) { const QString paramName = param.name; const QString str = QLatin1String{"$("} + paramName + QLatin1Char{')'}; if (paramString.contains(str)) { const QString tmp = QStringLiteral("%%1").arg(i++); paramString.replace(str, tmp); - // TODO: change the code here to get C++ code generated by KConfig to use - // QString::arg(QString, QString, QString) instead of QString().arg().arg() - arguments += QLatin1String{".arg( mParam"} + paramName + QLatin1String{" )"}; + + if (firstArg) { + arguments += QLatin1String{".arg( "}; + firstArg = false; + } + + arguments += QLatin1String{"mParam"} + paramName + QLatin1String{", "}; } } - if (arguments.isEmpty()) { + if (!arguments.isEmpty()) { + // Remove the last ", " + arguments.chop(2); + + // Close the ".arg( " + arguments += QLatin1String{" )"}; + } else { return QLatin1String{"QStringLiteral( \""} + group + QLatin1String{"\" )"}; } |