From 094c91f86baf1e82e55b435c07c5ba37ff107dd9 Mon Sep 17 00:00:00 2001 From: Montel Laurent Date: Mon, 9 Mar 2015 21:55:24 +0100 Subject: Allow to generate qloggingcategories support. Add new variable to specify it in *.kcfgc : "CategoryLoggingName" CHANGELOG: Allow to generate file with qloggingcategories support. REVIEW: 122931 --- src/kconfig_compiler/kconfig_compiler.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'src/kconfig_compiler/kconfig_compiler.cpp') diff --git a/src/kconfig_compiler/kconfig_compiler.cpp b/src/kconfig_compiler/kconfig_compiler.cpp index 28b151c5..7be74226 100644 --- a/src/kconfig_compiler/kconfig_compiler.cpp +++ b/src/kconfig_compiler/kconfig_compiler.cpp @@ -96,7 +96,6 @@ public: allDefaultGetters = (defaultGetters.count() == 1) && (defaultGetters.at(0).toLower() == "true"); globalEnums = codegenConfig.value("GlobalEnums", false).toBool(); useEnumTypes = codegenConfig.value("UseEnumTypes", false).toBool(); - const QString trString = codegenConfig.value("TranslationSystem").toString().toLower(); if (trString == "kde") { translationSystem = KdeTranslation; @@ -106,6 +105,7 @@ public: } translationSystem = QtTranslation; } + qCategoryLoggingName = codegenConfig.value("CategoryLoggingName", QString()).toString(); } public: @@ -128,6 +128,7 @@ public: QStringList sourceIncludes; QStringList mutators; QStringList defaultGetters; + QString qCategoryLoggingName; bool allMutators; bool setUserTexts; bool allDefaultGetters; @@ -1364,6 +1365,16 @@ QString memberAccessorBody(CfgEntry *e, bool globalEnums, const CfgConfig &cfg) // returns the member mutator implementation // which should go in the h file if inline // or the cpp file if not inline + +void addDebugMethod(QTextStream &out, const CfgConfig &cfg, const QString &n) +{ + if (cfg.qCategoryLoggingName.isEmpty()) { + out << " qDebug() << \"" << setFunction(n); + } else { + out << " qCDebug(" << cfg.qCategoryLoggingName << ") << \"" << setFunction(n); + } +} + QString memberMutatorBody(CfgEntry *e, const CfgConfig &cfg) { QString result; @@ -1375,7 +1386,7 @@ QString memberMutatorBody(CfgEntry *e, const CfgConfig &cfg) if (e->minValue() != "0" || !isUnsigned(t)) { // skip writing "if uint<0" (#187579) out << "if (v < " << e->minValue() << ")" << endl; out << "{" << endl; - out << " qDebug() << \"" << setFunction(n); + addDebugMethod(out, cfg, n); out << ": value \" << v << \" is less than the minimum value of "; out << e->minValue() << "\";" << endl; out << " v = " << e->minValue() << ";" << endl; @@ -1386,7 +1397,7 @@ QString memberMutatorBody(CfgEntry *e, const CfgConfig &cfg) if (!e->maxValue().isEmpty()) { out << endl << "if (v > " << e->maxValue() << ")" << endl; out << "{" << endl; - out << " qDebug() << \"" << setFunction(n); + addDebugMethod(out, cfg, n); out << ": value \" << v << \" is greater than the maximum value of "; out << e->maxValue() << "\";" << endl; out << " v = " << e->maxValue() << ";" << endl; -- cgit v1.2.1