aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2016-09-12 15:35:58 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2016-09-12 14:37:02 +0000
commit4c3ee6ee545635d93f00fa04981b3486b5e84925 (patch)
treec3c6de4a82938e4feab21b395c0be8c603cd34dc
parent866cb949cdf78600acb1bde6cbd824a9f2e28dc4 (diff)
Introduce the Qt 5 logging system
Define a logging category and use that to output debug messages and warnings. All of this now goes to standard error and can be conveniently captured from there without disturbance by the progress messages. Also, message formatting can now be controlled for example to output file and line numbers. Change-Id: If0de8776d4f5b6e418c70d4fe0931d2882b36ab8 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
-rw-r--r--ApiExtractor/abstractmetabuilder.cpp196
-rw-r--r--ApiExtractor/abstractmetalang.cpp40
-rw-r--r--ApiExtractor/apiextractor.cpp1
-rw-r--r--ApiExtractor/fileout.cpp15
-rw-r--r--ApiExtractor/reporthandler.cpp58
-rw-r--r--ApiExtractor/reporthandler.h28
-rw-r--r--ApiExtractor/typedatabase.cpp10
-rw-r--r--ApiExtractor/typesystem.cpp57
-rw-r--r--generator/generator.cpp12
-rw-r--r--generator/main.cpp7
-rw-r--r--generator/shiboken2/cppgenerator.cpp70
-rw-r--r--generator/shiboken2/headergenerator.cpp3
-rw-r--r--generator/shiboken2/overloaddata.cpp4
-rw-r--r--generator/shiboken2/shibokengenerator.cpp22
14 files changed, 266 insertions, 257 deletions
diff --git a/ApiExtractor/abstractmetabuilder.cpp b/ApiExtractor/abstractmetabuilder.cpp
index f956d7c08..9fc035d9c 100644
--- a/ApiExtractor/abstractmetabuilder.cpp
+++ b/ApiExtractor/abstractmetabuilder.cpp
@@ -155,13 +155,9 @@ void AbstractMetaBuilder::checkFunctionModifications()
}
if (!found) {
- QString warning
- = QString("signature '%1' for function modification in '%2' not found. Possible candidates: %3")
- .arg(signature)
- .arg(clazz->qualifiedCppName())
- .arg(possibleSignatures.join(", "));
-
- ReportHandler::warning(warning);
+ qCWarning(lcShiboken).noquote().nospace()
+ << QStringLiteral("signature '%1' for function modification in '%2' not found. Possible candidates: %3")
+ .arg(signature, clazz->qualifiedCppName(), possibleSignatures.join(QLatin1String(", ")));
}
}
}
@@ -411,7 +407,6 @@ bool AbstractMetaBuilder::build(QIODevice* input)
addAbstractMetaClass(cls);
}
- ReportHandler::flush();
// We need to know all global enums
ReportHandler::setProgressReference(m_dom->enumMap());
@@ -423,7 +418,6 @@ bool AbstractMetaBuilder::build(QIODevice* input)
m_globalEnums << metaEnum;
}
}
- ReportHandler::flush();
QHash<QString, NamespaceModelItem> namespaceMap = m_dom->namespaceMap();
NamespaceList namespaceTypeValues = namespaceMap.values();
@@ -438,7 +432,6 @@ bool AbstractMetaBuilder::build(QIODevice* input)
if (metaClass)
m_metaClasses << metaClass;
}
- ReportHandler::flush();
// Go through all typedefs to see if we have defined any
// specific typedefs to be used as classes.
@@ -449,7 +442,6 @@ bool AbstractMetaBuilder::build(QIODevice* input)
AbstractMetaClass* cls = traverseTypeAlias(typeAlias);
addAbstractMetaClass(cls);
}
- ReportHandler::flush();
figureOutEnumValues();
@@ -493,7 +485,6 @@ bool AbstractMetaBuilder::build(QIODevice* input)
if (!cls->isInterface() && !cls->isNamespace())
setupInheritance(cls);
}
- ReportHandler::flush();
ReportHandler::setProgressReference(m_metaClasses);
foreach (AbstractMetaClass* cls, m_metaClasses) {
@@ -501,8 +492,9 @@ bool AbstractMetaBuilder::build(QIODevice* input)
cls->fixFunctions();
if (!cls->typeEntry()) {
- ReportHandler::warning(QString("class '%1' does not have an entry in the type system")
- .arg(cls->name()));
+ qCWarning(lcShiboken).noquote().nospace()
+ << QStringLiteral("class '%1' does not have an entry in the type system")
+ .arg(cls->name());
} else {
bool couldAddDefaultCtors = !cls->isFinalInCpp() && !cls->isInterface() && !cls->isNamespace();
if (couldAddDefaultCtors) {
@@ -516,8 +508,6 @@ bool AbstractMetaBuilder::build(QIODevice* input)
if (cls->isAbstract() && !cls->isInterface())
cls->typeEntry()->setLookupName(cls->typeEntry()->targetLangName() + "$ConcreteWrapper");
}
- ReportHandler::flush();
-
TypeEntryHash allEntries = types->allEntries();
ReportHandler::progress("Detecting inconsistencies in typesystem...");
foreach (QList<TypeEntry*> entries, allEntries) {
@@ -533,8 +523,9 @@ bool AbstractMetaBuilder::build(QIODevice* input)
&& !entry->isCustom()
&& !entry->isVariant()
&& !m_metaClasses.findClass(entry->qualifiedCppName())) {
- ReportHandler::warning(QString("type '%1' is specified in typesystem, but not defined. This could potentially lead to compilation errors.")
- .arg(entry->qualifiedCppName()));
+ qCWarning(lcShiboken).noquote().nospace()
+ << QStringLiteral("type '%1' is specified in typesystem, but not defined. This could potentially lead to compilation errors.")
+ .arg(entry->qualifiedCppName());
} else if (entry->generateCode() && entry->type() == TypeEntry::FunctionType) {
const FunctionTypeEntry* fte = static_cast<const FunctionTypeEntry*>(entry);
foreach (QString signature, fte->signatures()) {
@@ -546,8 +537,9 @@ bool AbstractMetaBuilder::build(QIODevice* input)
}
}
if (!ok) {
- ReportHandler::warning(QString("Global function '%1' is specified in typesystem, but not defined. This could potentially lead to compilation errors.")
- .arg(signature));
+ qCWarning(lcShiboken).noquote().nospace()
+ << QStringLiteral("Global function '%1' is specified in typesystem, but not defined. This could potentially lead to compilation errors.")
+ .arg(signature);
}
}
} else if (entry->isEnum()) {
@@ -567,14 +559,14 @@ bool AbstractMetaBuilder::build(QIODevice* input)
}
if (!enumFound) {
entry->setCodeGeneration(TypeEntry::GenerateNothing);
- ReportHandler::warning(QString("enum '%1' is specified in typesystem, but not declared")
- .arg(entry->qualifiedCppName()));
+ qCWarning(lcShiboken).noquote().nospace()
+ << QStringLiteral("enum '%1' is specified in typesystem, but not declared")
+ .arg(entry->qualifiedCppName());
}
}
}
}
- ReportHandler::flush();
{
FunctionList hashFunctions = m_dom->findFunctions("qHash");
@@ -670,7 +662,8 @@ void AbstractMetaBuilder::addAbstractMetaClass(AbstractMetaClass *cls)
if (cls->typeEntry()->designatedInterface()) {
AbstractMetaClass* interface = cls->extractInterface();
m_metaClasses << interface;
- ReportHandler::debugSparse(QString(" -> interface '%1'").arg(interface->name()));
+ if (ReportHandler::isDebug(ReportHandler::SparseDebug))
+ qCDebug(lcShiboken) << QStringLiteral(" -> interface '%1'").arg(interface->name());
}
}
}
@@ -686,7 +679,8 @@ AbstractMetaClass* AbstractMetaBuilder::traverseNamespace(NamespaceModelItem nam
}
if (!type) {
- ReportHandler::warning(QString("namespace '%1' does not have a type entry").arg(namespaceName));
+ qCWarning(lcShiboken).noquote().nospace()
+ << QStringLiteral("namespace '%1' does not have a type entry").arg(namespaceName);
return 0;
}
@@ -697,9 +691,10 @@ AbstractMetaClass* AbstractMetaBuilder::traverseNamespace(NamespaceModelItem nam
m_currentClass = metaClass;
- ReportHandler::debugSparse(QString("namespace '%1.%2'")
- .arg(metaClass->package())
- .arg(namespaceItem->name()));
+ if (ReportHandler::isDebug(ReportHandler::SparseDebug)) {
+ qCDebug(lcShiboken)
+ << QStringLiteral("namespace '%1.%2'").arg(metaClass->package(), namespaceItem->name());
+ }
traverseEnums(model_dynamic_cast<ScopeModelItem>(namespaceItem), metaClass, namespaceItem->enumsDeclarations());
@@ -851,12 +846,13 @@ int AbstractMetaBuilder::figureOutEnumValue(const QString &stringValue,
v = findOutValueFromString(s, matched);
if (!matched) {
QString enclosingClass = QString(metaEnum->enclosingClass() ? metaEnum->enclosingClass()->name() + "::" : QString());
- ReportHandler::warning("unhandled enum value: " + s + " in "
- + enclosingClass + metaEnum->name()
- + " from header '" + metaEnum->typeEntry()->include().name() + "'");
+ qCWarning(lcShiboken).noquote().nospace()
+ << "unhandled enum value: " << s << " in "
+ << enclosingClass << metaEnum->name() << " from header '"
+ << metaEnum->typeEntry()->include().name() << '\'';
}
} else {
- ReportHandler::warning("unhandled enum value: Unknown enum");
+ qCWarning(lcShiboken) << "unhandled enum value: Unknown enum";
}
}
@@ -874,7 +870,7 @@ int AbstractMetaBuilder::figureOutEnumValue(const QString &stringValue,
}
warn += " from header '" + metaEnum->typeEntry()->include().name() + "'";
- ReportHandler::warning(warn);
+ qCWarning(lcShiboken).noquote().nospace() << warn;
returnValue = oldValuevalue;
}
@@ -895,7 +891,7 @@ void AbstractMetaBuilder::figureOutEnumValuesForClass(AbstractMetaClass* metaCla
AbstractMetaEnumList enums = metaClass->enums();
foreach (AbstractMetaEnum* e, enums) {
if (!e) {
- ReportHandler::warning("bad enum in class " + metaClass->name());
+ qCWarning(lcShiboken).noquote().nospace() << "bad enum in class " << metaClass->name();
continue;
}
AbstractMetaEnumValueList lst = e->values();
@@ -992,8 +988,9 @@ AbstractMetaEnum* AbstractMetaBuilder::traverseEnum(EnumModelItem enumItem, Abst
}
if (!typeEntry || !typeEntry->isEnum()) {
- ReportHandler::warning(QString("enum '%1' does not have a type entry or is not an enum")
- .arg(qualifiedName));
+ qCWarning(lcShiboken).noquote().nospace()
+ << QStringLiteral("enum '%1' does not have a type entry or is not an enum")
+ .arg(qualifiedName);
m_rejectedEnums.insert(qualifiedName, NotInTypeSystem);
return 0;
}
@@ -1020,7 +1017,8 @@ AbstractMetaEnum* AbstractMetaBuilder::traverseEnum(EnumModelItem enumItem, Abst
break;
}
- ReportHandler::debugMedium(QString(" - traversing enum %1").arg(metaEnum->fullName()));
+ if (ReportHandler::isDebug(ReportHandler::MediumDebug))
+ qCDebug(lcShiboken) << " - traversing enum " << metaEnum->fullName();
foreach (EnumeratorModelItem value, enumItem->enumerators()) {
@@ -1031,8 +1029,10 @@ AbstractMetaEnum* AbstractMetaBuilder::traverseEnum(EnumModelItem enumItem, Abst
metaEnumValue->setStringValue(value->value());
metaEnum->addEnumValue(metaEnumValue);
- ReportHandler::debugFull(" - " + metaEnumValue->name() + " = "
- + metaEnumValue->value());
+ if (ReportHandler::isDebug(ReportHandler::FullDebug)) {
+ qCDebug(lcShiboken) << " - " << metaEnumValue->name() << " = "
+ << metaEnumValue->value() << " = " << metaEnumValue->value();
+ }
// Add into global register...
if (enclosing)
@@ -1162,10 +1162,12 @@ AbstractMetaClass* AbstractMetaBuilder::traverseClass(ClassModelItem classItem)
AbstractMetaClass* oldCurrentClass = m_currentClass;
m_currentClass = metaClass;
- if (type->isContainer())
- ReportHandler::debugSparse(QString("container: '%1'").arg(fullClassName));
- else
- ReportHandler::debugSparse(QString("class: '%1'").arg(metaClass->fullName()));
+ if (ReportHandler::isDebug(ReportHandler::SparseDebug)) {
+ const QString message = type->isContainer()
+ ? QStringLiteral("container: '%1'").arg(fullClassName)
+ : QStringLiteral("class: '%1'").arg(metaClass->fullName());
+ qCDebug(lcShiboken) << message;
+ }
TemplateParameterList template_parameters = classItem->templateParameters();
QList<TypeEntry *> template_args;
@@ -1312,10 +1314,10 @@ AbstractMetaField* AbstractMetaBuilder::traverseField(VariableModelItem field, c
AbstractMetaType *metaType = translateType(fieldType, &ok);
if (!metaType || !ok) {
- ReportHandler::warning(QString("skipping field '%1::%2' with unmatched type '%3'")
- .arg(m_currentClass->name())
- .arg(fieldName)
- .arg(TypeInfo::resolveType(fieldType, currentScope()->toItem()).qualifiedName().join("::")));
+ const QString type = TypeInfo::resolveType(fieldType, currentScope()->toItem()).qualifiedName().join(QLatin1String("::"));
+ qCWarning(lcShiboken).noquote().nospace()
+ << QStringLiteral("skipping field '%1::%2' with unmatched type '%3'")
+ .arg(m_currentClass->name(), fieldName, type);
delete metaField;
return 0;
}
@@ -1542,15 +1544,15 @@ void AbstractMetaBuilder::traverseFunctions(ScopeModelItem scopeItem, AbstractMe
setupFunctionDefaults(metaFunction, metaClass);
if (metaFunction->isSignal() && metaClass->hasSignal(metaFunction)) {
- QString warn = QString("signal '%1' in class '%2' is overloaded.")
- .arg(metaFunction->name()).arg(metaClass->name());
- ReportHandler::warning(warn);
+ qCWarning(lcShiboken).noquote().nospace()
+ << QStringLiteral("signal '%1' in class '%2' is overloaded.")
+ .arg(metaFunction->name(), metaClass->name());
}
if (metaFunction->isSignal() && !metaClass->isQObject()) {
- QString warn = QString("signal '%1' in non-QObject class '%2'")
- .arg(metaFunction->name()).arg(metaClass->name());
- ReportHandler::warning(warn);
+ qCWarning(lcShiboken).noquote().nospace()
+ << QStringLiteral("signal '%1' in non-QObject class '%2'")
+ .arg(metaFunction->name(), metaClass->name());
}
if (metaFunction->isConversionOperator())
@@ -1645,9 +1647,9 @@ bool AbstractMetaBuilder::setupInheritance(AbstractMetaClass *metaClass)
return true;
}
- ReportHandler::warning(QString("template baseclass '%1' of '%2' is not known")
- .arg(baseClasses.first())
- .arg(metaClass->name()));
+ qCWarning(lcShiboken).noquote().nospace()
+ << QStringLiteral("template baseclass '%1' of '%2' is not known")
+ .arg(baseClasses.first(), metaClass->name());
return false;
}
@@ -1661,12 +1663,11 @@ bool AbstractMetaBuilder::setupInheritance(AbstractMetaClass *metaClass)
continue;
TypeEntry* baseClassEntry = types->findType(baseClasses.at(i));
- if (!baseClassEntry)
- ReportHandler::warning(QString("class '%1' inherits from unknown base class '%2'")
- .arg(metaClass->name()).arg(baseClasses.at(i)));
-
- // true for primary base class
- else if (!baseClassEntry->designatedInterface()) {
+ if (!baseClassEntry) {
+ qCWarning(lcShiboken).noquote().nospace()
+ << QStringLiteral("class '%1' inherits from unknown base class '%2'")
+ .arg(metaClass->name(), baseClasses.at(i));
+ } else if (!baseClassEntry->designatedInterface()) { // true for primary base class
primaries++;
primary = i;
}
@@ -1675,9 +1676,9 @@ bool AbstractMetaBuilder::setupInheritance(AbstractMetaClass *metaClass)
if (primary >= 0) {
AbstractMetaClass* baseClass = m_metaClasses.findClass(baseClasses.at(primary));
if (!baseClass) {
- ReportHandler::warning(QString("unknown baseclass for '%1': '%2'")
- .arg(metaClass->name())
- .arg(baseClasses.at(primary)));
+ qCWarning(lcShiboken).noquote().nospace()
+ << QStringLiteral("unknown baseclass for '%1': '%2'")
+ .arg(metaClass->name(), baseClasses.at(primary));
return false;
}
metaClass->setBaseClass(baseClass);
@@ -1690,7 +1691,8 @@ bool AbstractMetaBuilder::setupInheritance(AbstractMetaClass *metaClass)
if (i != primary) {
AbstractMetaClass* baseClass = m_metaClasses.findClass(baseClasses.at(i));
if (!baseClass) {
- ReportHandler::warning(QString("class not found for setup inheritance '%1'").arg(baseClasses.at(i)));
+ qCWarning(lcShiboken).noquote().nospace()
+ << QStringLiteral("class not found for setup inheritance '%1'").arg(baseClasses.at(i));
return false;
}
@@ -1699,9 +1701,8 @@ bool AbstractMetaBuilder::setupInheritance(AbstractMetaClass *metaClass)
QString interfaceName = baseClass->isInterface() ? InterfaceTypeEntry::interfaceName(baseClass->name()) : baseClass->name();
AbstractMetaClass* iface = m_metaClasses.findClass(interfaceName);
if (!iface) {
- ReportHandler::warning(QString("unknown interface for '%1': '%2'")
- .arg(metaClass->name())
- .arg(interfaceName));
+ qCWarning(lcShiboken).noquote().nospace()
+ << QStringLiteral("unknown interface for '%1': '%2'").arg(metaClass->name(), interfaceName);
return false;
}
metaClass->addInterface(iface);
@@ -1764,7 +1765,7 @@ AbstractMetaFunction* AbstractMetaBuilder::traverseFunction(const AddedFunction&
metaFunction->setArguments(metaArguments);
if (metaFunction->isOperatorOverload() && !metaFunction->isCallOperator()) {
if (metaArguments.size() > 2) {
- ReportHandler::warning("An operator overload need to have 0, 1 or 2 arguments if it's reverse.");
+ qCWarning(lcShiboken) << "An operator overload need to have 0, 1 or 2 arguments if it's reverse.";
} else if (metaArguments.size() == 2) {
// Check if it's a reverse operator
if (metaArguments[1]->type()->typeEntry() == metaClass->typeEntry()) {
@@ -1776,7 +1777,7 @@ AbstractMetaFunction* AbstractMetaBuilder::traverseFunction(const AddedFunction&
metaArguments.removeLast();
metaFunction->setArguments(metaArguments);
} else {
- ReportHandler::warning("Operator overload can have two arguments only if it's a reverse operator!");
+ qCWarning(lcShiboken) << "Operator overload can have two arguments only if it's a reverse operator!";
}
}
}
@@ -1883,7 +1884,8 @@ AbstractMetaFunction* AbstractMetaBuilder::traverseFunction(FunctionModelItem fu
AbstractMetaFunction* metaFunction = createMetaFunction();
metaFunction->setConstant(functionItem->isConstant());
- ReportHandler::debugMedium(QString(" - %2()").arg(functionName));
+ if (ReportHandler::isDebug(ReportHandler::MediumDebug))
+ qCDebug(lcShiboken).noquote().nospace() << " - " << functionName << "()";
metaFunction->setName(functionName);
metaFunction->setOriginalName(functionItem->name());
@@ -1933,10 +1935,9 @@ AbstractMetaFunction* AbstractMetaBuilder::traverseFunction(FunctionModelItem fu
if (!ok) {
Q_ASSERT(type == 0);
- ReportHandler::warning(QString("skipping function '%1::%2', unmatched return type '%3'")
- .arg(className)
- .arg(functionItem->name())
- .arg(functionItem->type().toString()));
+ qCWarning(lcShiboken).noquote().nospace()
+ << QStringLiteral("skipping function '%1::%2', unmatched return type '%3'")
+ .arg(className, functionItem->name(), functionItem->type().toString());
m_rejectedFunctions[className + "::" + functionName] =
UnmatchedReturnType;
metaFunction->setInvalid(true);
@@ -1969,11 +1970,9 @@ AbstractMetaFunction* AbstractMetaBuilder::traverseFunction(FunctionModelItem fu
AbstractMetaType* metaType = translateType(arg->type(), &ok);
if (!ok) {
Q_ASSERT(metaType == 0);
- ReportHandler::warning(QString("skipping function '%1::%2', "
- "unmatched parameter type '%3'")
- .arg(className)
- .arg(functionItem->name())
- .arg(arg->type().toString()));
+ qCWarning(lcShiboken).noquote().nospace()
+ << QStringLiteral("skipping function '%1::%2', unmatched parameter type '%3'")
+ .arg(className, functionItem->name(), arg->type().toString());
m_rejectedFunctions[className + "::" + functionName] =
UnmatchedArgumentType;
metaFunction->setInvalid(true);
@@ -2033,7 +2032,9 @@ AbstractMetaFunction* AbstractMetaBuilder::traverseFunction(FunctionModelItem fu
&& !metaFunction->isOperatorOverload()
&& !metaFunction->isSignal()
&& metaFunction->argumentName(i+1, false, m_currentClass).isEmpty()) {
- ReportHandler::warning(QString("Argument %1 on function '%2::%3' has default expression but does not have name.").arg(i+1).arg(className).arg(metaFunction->minimalSignature()));
+ qCWarning(lcShiboken).noquote().nospace()
+ << QStringLiteral("Argument %1 on function '%2::%3' has default expression but does not have name.")
+ .arg(i+1).arg(className, metaFunction->minimalSignature());
}
}
@@ -2061,7 +2062,8 @@ AbstractMetaType* AbstractMetaBuilder::translateType(double vr, const AddedFunct
if (!type && typeInfo.name.contains('<')) {
const QStringList& parsedType = parseTemplateType(typeInfo.name);
if (parsedType.isEmpty()) {
- ReportHandler::warning(QString("Template type parsing failed for '%1'").arg(typeInfo.name));
+ qCWarning(lcShiboken).noquote().nospace()
+ << QStringLiteral("Template type parsing failed for '%1'").arg(typeInfo.name);
} else {
templateArgs = parsedType.mid(1);
isTemplate = (type = typeDb->findContainerType(parsedType[0]));
@@ -2204,7 +2206,8 @@ AbstractMetaType* AbstractMetaBuilder::translateType(const TypeInfo& _typei, boo
QStringList qualifierList = typeInfo.qualified_name;
if (qualifierList.isEmpty()) {
- ReportHandler::warning(QString("horribly broken type '%1'").arg(_typei.toString()));
+ qCWarning(lcShiboken).noquote().nospace()
+ << QStringLiteral("horribly broken type '%1'").arg(_typei.toString());
*ok = false;
return 0;
}
@@ -2445,9 +2448,10 @@ QString AbstractMetaBuilder::fixDefaultValue(ArgumentModelItem item, AbstractMet
}
}
} else {
- QString warn = QString("undefined type for default value '%3' of argument in function '%1', class '%2'")
- .arg(functionName).arg(className).arg(item->defaultValueExpression());
- ReportHandler::warning(warn);
+ qCWarning(lcShiboken).noquote().nospace()
+ << QStringLiteral("undefined type for default value '%3' of argument in function '%1', class '%2'")
+ .arg(functionName, className, item->defaultValueExpression());
+
expr = QString();
}
@@ -2650,7 +2654,9 @@ bool AbstractMetaBuilder::inheritTemplate(AbstractMetaClass* subclass,
temporaryType->decideUsagePattern();
templateTypes << temporaryType;
} else {
- ReportHandler::warning("Ignoring template parameter " + templateParamName + " from " + info.instantiationName() + ", because I don't know what it is.");
+ qCWarning(lcShiboken).noquote().nospace()
+ << "Ignoring template parameter " << templateParamName << " from "
+ << info.instantiationName() << ", because I don't know what it is.";
}
}
@@ -2775,8 +2781,9 @@ void AbstractMetaBuilder::parseQ_Property(AbstractMetaClass* metaClass, const QS
}
if (!type || !ok) {
- ReportHandler::warning(QString("Unable to decide type of property: '%1' in class '%2'")
- .arg(l.at(0)).arg(metaClass->name()));
+ qCWarning(lcShiboken).noquote().nospace()
+ << QStringLiteral("Unable to decide type of property: '%1' in class '%2'")
+ .arg(l.at(0), metaClass->name());
continue;
}
@@ -2868,8 +2875,9 @@ static void writeRejectLogFile(const QString &name,
{
QFile f(name);
if (!f.open(QIODevice::WriteOnly | QIODevice::Text)) {
- ReportHandler::warning(QString("failed to write log file: '%1'")
- .arg(f.fileName()));
+ qCWarning(lcShiboken).noquote().nospace()
+ << QStringLiteral("failed to write log file: '%1'")
+ .arg(QDir::toNativeSeparators(f.fileName()));
return;
}
@@ -3012,7 +3020,9 @@ AbstractMetaClassList AbstractMetaBuilder::classesTopologicalSorted(const Abstra
for (; it != map.end(); ++it)
hash[it.value()] = it.key();
graph.dumpDot(hash, tempFile.fileName());
- ReportHandler::warning("Cyclic dependency found! Graph can be found at "+tempFile.fileName());
+ qCWarning(lcShiboken).noquote().nospace()
+ << "Cyclic dependency found! Graph can be found at "
+ << QDir::toNativeSeparators(tempFile.fileName());
} else {
foreach (int i, unmappedResult) {
Q_ASSERT(reverseMap.contains(i));
diff --git a/ApiExtractor/abstractmetalang.cpp b/ApiExtractor/abstractmetalang.cpp
index 21e77934d..290fae201 100644
--- a/ApiExtractor/abstractmetalang.cpp
+++ b/ApiExtractor/abstractmetalang.cpp
@@ -197,8 +197,10 @@ void AbstractMetaType::decideUsagePattern()
}
} else {
setTypeUsagePattern(AbstractMetaType::NativePointerPattern);
- ReportHandler::debugFull(QString("native pointer pattern for '%1'")
- .arg(cppSignature()));
+ if (ReportHandler::isDebug(ReportHandler::FullDebug)) {
+ qCDebug(lcShiboken)
+ << QStringLiteral("native pointer pattern for '%1'").arg(cppSignature());
+ }
}
}
@@ -1406,9 +1408,9 @@ void AbstractMetaClass::setFunctions(const AbstractMetaFunctionList &functions)
foreach (AbstractMetaFunction *final_function, finalFunctions) {
*final_function += AbstractMetaAttributes::ForceShellImplementation;
- QString warn = QString("hiding of function '%1' in class '%2'")
- .arg(final_function->name()).arg(name());
- ReportHandler::warning(warn);
+ qCWarning(lcShiboken).noquote().nospace()
+ << QStringLiteral("hiding of function '%1' in class '%2'")
+ .arg(final_function->name(), name());
}
}
@@ -2090,7 +2092,8 @@ void AbstractMetaClass::fixFunctions()
if (superClass) {
// Super classes can never be final
if (superClass->isFinalInTargetLang()) {
- ReportHandler::warning("Final class '" + superClass->name() + "' set to non-final, as it is extended by other classes");
+ qCWarning(lcShiboken).noquote().nospace()
+ << "Final class '" << superClass->name() << "' set to non-final, as it is extended by other classes";
*superClass -= AbstractMetaAttributes::FinalInTargetLang;
}
superFuncs = superClass->queryFunctions(AbstractMetaClass::ClassImplements);
@@ -2141,9 +2144,9 @@ void AbstractMetaClass::fixFunctions()
f->setFunctionType(AbstractMetaFunction::EmptyFunction);
f->setVisibility(AbstractMetaAttributes::Protected);
*f += AbstractMetaAttributes::FinalInTargetLang;
- ReportHandler::warning(QString("private virtual function '%1' in '%2'")
- .arg(f->signature())
- .arg(f->implementingClass()->name()));
+ qCWarning(lcShiboken).noquote().nospace()
+ << QStringLiteral("private virtual function '%1' in '%2'")
+ .arg(f->signature(), f->implementingClass()->name());
}
#endif
}
@@ -2152,7 +2155,7 @@ void AbstractMetaClass::fixFunctions()
if (f->visibility() != sf->visibility()) {
QString warn = QString("visibility of function '%1' modified in class '%2'")
.arg(f->name()).arg(name());
- ReportHandler::warning(warn);
+ qCWarning(lcShiboken).noquote().nospace() << warn;
#if 0
// If new visibility is private, we can't
// do anything. If it isn't, then we
@@ -2195,11 +2198,10 @@ void AbstractMetaClass::fixFunctions()
}
if (!hasNonFinalModifier && !isBaseImplPrivate) {
- ReportHandler::warning(QString::fromLatin1("Shadowing: %1::%2 and %3::%4")
- .arg(sf->implementingClass()->name())
- .arg(sf->signature())
- .arg(f->implementingClass()->name())
- .arg(f->signature()));
+ qCWarning(lcShiboken).noquote().nospace()
+ << QStringLiteral("Shadowing: %1::%2 and %3::%4")
+ .arg(sf->implementingClass()->name(), sf->signature(),
+ f->implementingClass()->name(), f->signature());
}
}
}
@@ -2349,8 +2351,9 @@ AbstractMetaEnum *AbstractMetaClassList::findEnum(const EnumTypeEntry *entry) co
AbstractMetaClass *metaClass = findClass(className);
if (!metaClass) {
- ReportHandler::warning(QString("AbstractMeta::findEnum(), unknown class '%1' in '%2'")
- .arg(className).arg(entry->qualifiedCppName()));
+ qCWarning(lcShiboken).noquote().nospace()
+ << QStringLiteral("AbstractMeta::findEnum(), unknown class '%1' in '%2'")
+ .arg(className, entry->qualifiedCppName());
return 0;
}
@@ -2387,7 +2390,8 @@ AbstractMetaEnumValue *AbstractMetaClassList::findEnumValue(const QString &name)
}
}
- ReportHandler::warning(QString("no matching enum '%1'").arg(name));
+ qCWarning(lcShiboken).noquote().nospace()
+ << QStringLiteral("no matching enum '%1'").arg(name);
return 0;
}
diff --git a/ApiExtractor/apiextractor.cpp b/ApiExtractor/apiextractor.cpp
index c042d69b2..a29a38d1d 100644
--- a/ApiExtractor/apiextractor.cpp
+++ b/ApiExtractor/apiextractor.cpp
@@ -47,7 +47,6 @@ ApiExtractor::ApiExtractor() : m_builder(0)
QString envTypesystemPaths = getenv("TYPESYSTEMPATH");
if (!envTypesystemPaths.isEmpty())
TypeDatabase::instance()->addTypesystemPath(envTypesystemPaths);
- ReportHandler::setContext("ApiExtractor");
}
ApiExtractor::~ApiExtractor()
diff --git a/ApiExtractor/fileout.cpp b/ApiExtractor/fileout.cpp
index 41b4b8257..7e731f051 100644
--- a/ApiExtractor/fileout.cpp
+++ b/ApiExtractor/fileout.cpp
@@ -181,8 +181,9 @@ bool FileOut::done()
QByteArray original;
if (info.exists() && (diff || (info.size() == tmp.size()))) {
if (!fileRead.open(QIODevice::ReadOnly)) {
- ReportHandler::warning(QString("failed to open file '%1' for reading")
- .arg(fileRead.fileName()));
+ qCWarning(lcShiboken).noquote().nospace()
+ << QStringLiteral("failed to open file '%1' for reading")
+ .arg(QDir::toNativeSeparators(fileRead.fileName()));
return false;
}
@@ -195,15 +196,17 @@ bool FileOut::done()
if (!FileOut::dummy) {
QDir dir(info.absolutePath());
if (!dir.mkpath(dir.absolutePath())) {
- ReportHandler::warning(QString("unable to create directory '%1'")
- .arg(dir.absolutePath()));
+ qCWarning(lcShiboken).noquote().nospace()
+ << QStringLiteral("unable to create directory '%1'")
+ .arg(QDir::toNativeSeparators(dir.absolutePath()));
return false;
}
QFile fileWrite(name);
if (!fileWrite.open(QIODevice::WriteOnly)) {
- ReportHandler::warning(QString("failed to open file '%1' for writing")
- .arg(fileWrite.fileName()));
+ qCWarning(lcShiboken).noquote().nospace()
+ << QStringLiteral("failed to open file '%1' for writing")
+ .arg(QDir::toNativeSeparators(fileWrite.fileName()));
return false;
}
QTextCodec *codec = QTextCodec::codecForName("UTF-8");
diff --git a/ApiExtractor/reporthandler.cpp b/ApiExtractor/reporthandler.cpp
index 40668e8dc..f3569dc7a 100644
--- a/ApiExtractor/reporthandler.cpp
+++ b/ApiExtractor/reporthandler.cpp
@@ -44,7 +44,6 @@
static bool m_silent = false;
static int m_warningCount = 0;
static int m_suppressedCount = 0;
-static QString m_context;
static ReportHandler::DebugLevel m_debugLevel = ReportHandler::NoDebug;
static QSet<QString> m_reportedWarnings;
static QString m_progressBuffer;
@@ -52,6 +51,8 @@ static int m_step_size = 0;
static int m_step = -1;
static int m_step_warning = 0;
+Q_LOGGING_CATEGORY(lcShiboken, "qt.shiboken")
+
static void printProgress()
{
std::printf("%s", m_progressBuffer.toUtf8().data());
@@ -59,16 +60,9 @@ static void printProgress()
m_progressBuffer.clear();
}
-static void printWarnings()
+void ReportHandler::install()
{
- if (m_reportedWarnings.size() > 0) {
- m_progressBuffer += "\t";
- foreach(QString msg, m_reportedWarnings)
- m_progressBuffer += msg + "\n\t";
- m_progressBuffer += "\n\n";
- m_reportedWarnings.clear();
- printProgress();
- }
+ qInstallMessageHandler(ReportHandler::messageOutput);
}
ReportHandler::DebugLevel ReportHandler::debugLevel()
@@ -81,11 +75,6 @@ void ReportHandler::setDebugLevel(ReportHandler::DebugLevel level)
m_debugLevel = level;
}
-void ReportHandler::setContext(const QString& context)
-{
- m_context = context;
-}
-
int ReportHandler::suppressedCount()
{
return m_suppressedCount;
@@ -112,21 +101,21 @@ void ReportHandler::setSilent(bool silent)
m_silent = silent;
}
-void ReportHandler::warning(const QString &text)
+void ReportHandler::messageOutput(QtMsgType type, const QMessageLogContext &context, const QString &text)
{
- if (m_silent)
- return;
-
-// Context is useless!
-// QString warningText = QString("\r" COLOR_YELLOW "WARNING(%1)" COLOR_END " :: %2").arg(m_context).arg(text);
- TypeDatabase *db = TypeDatabase::instance();
- if (db && db->isSuppressedWarning(text)) {
- ++m_suppressedCount;
- } else if (!m_reportedWarnings.contains(text)) {
+ if (type == QtWarningMsg) {
+ if (m_silent || m_reportedWarnings.contains(text))
+ return;
+ const TypeDatabase *db = TypeDatabase::instance();
+ if (db && db->isSuppressedWarning(text)) {
+ ++m_suppressedCount;
+ return;
+ }
++m_warningCount;
++m_step_warning;
- m_reportedWarnings << text;
+ m_reportedWarnings.insert(text);
}
+ fprintf(stderr, "%s\n", qPrintable(qFormatLogMessage(type, context, text)));
}
void ReportHandler::progress(const QString& str, ...)
@@ -153,20 +142,3 @@ void ReportHandler::progress(const QString& str, ...)
m_step_warning = 0;
}
}
-
-void ReportHandler::flush()
-{
- if (!m_silent)
- printWarnings();
-}
-
-void ReportHandler::debug(DebugLevel level, const QString &text)
-{
- if (m_debugLevel == NoDebug)
- return;
-
- if (level <= m_debugLevel) {
- std::printf("\r" COLOR_GREEN "DEBUG" COLOR_END " :: %-70s\n", qPrintable(text));
- printProgress();
- }
-}
diff --git a/ApiExtractor/reporthandler.h b/ApiExtractor/reporthandler.h
index 4adaac4c3..e4e7b169a 100644
--- a/ApiExtractor/reporthandler.h
+++ b/ApiExtractor/reporthandler.h
@@ -24,14 +24,17 @@
#ifndef REPORTHANDLER_H
#define REPORTHANDLER_H
-class QString;
+#include <QLoggingCategory>
+#include <QString>
+
+Q_DECLARE_LOGGING_CATEGORY(lcShiboken)
class ReportHandler
{
public:
enum DebugLevel { NoDebug, SparseDebug, MediumDebug, FullDebug };
- static void setContext(const QString &context);
+ static void install();
static DebugLevel debugLevel();
static void setDebugLevel(DebugLevel level);
@@ -40,8 +43,6 @@ public:
static int suppressedCount();
- static void warning(const QString &str);
-
template <typename T>
static void setProgressReference(T collection)
{
@@ -52,23 +53,14 @@ public:
static void progress(const QString &str, ...);
- static void debugSparse(const QString &str)
- {
- debug(SparseDebug, str);
- }
- static void debugMedium(const QString &str)
- {
- debug(MediumDebug, str);
- }
- static void debugFull(const QString &str)
- {
- debug(FullDebug, str);
- }
- static void debug(DebugLevel level, const QString &str);
+ static bool isDebug(DebugLevel level)
+ { return debugLevel() >= level; }
static bool isSilent();
static void setSilent(bool silent);
- static void flush();
+
+private:
+ static void messageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg);
};
#endif // REPORTHANDLER_H
diff --git a/ApiExtractor/typedatabase.cpp b/ApiExtractor/typedatabase.cpp
index 3d91da893..ce483b419 100644
--- a/ApiExtractor/typedatabase.cpp
+++ b/ApiExtractor/typedatabase.cpp
@@ -337,7 +337,8 @@ bool TypeDatabase::parseFile(const QString &filename, bool generate)
QFile file(filepath);
if (!file.exists()) {
- ReportHandler::warning("Can't find " + filename+", typesystem paths: "+m_typesystemPaths.join(", "));
+ qCWarning(lcShiboken).noquote().nospace()
+ << "Can't find " << filename << ", typesystem paths: " << m_typesystemPaths.join(", ");
return false;
}
@@ -346,9 +347,10 @@ bool TypeDatabase::parseFile(const QString &filename, bool generate)
m_parsedTypesystemFiles[filepath] = ok;
int newCount = m_entries.size();
- ReportHandler::debugSparse(QString::fromLatin1("Parsed: '%1', %2 new entries")
- .arg(filename)
- .arg(newCount - count));
+ if (ReportHandler::isDebug(ReportHandler::SparseDebug)) {
+ qCDebug(lcShiboken)
+ << QStringLiteral("Parsed: '%1', %2 new entries").arg(filename).arg(newCount - count);
+ }
return ok;
}
diff --git a/ApiExtractor/typesystem.cpp b/ApiExtractor/typesystem.cpp
index 618c3b077..5c115ddc7 100644
--- a/ApiExtractor/typesystem.cpp
+++ b/ApiExtractor/typesystem.cpp
@@ -122,10 +122,12 @@ void Handler::fetchAttributeValues(const QString &name, const QXmlAttributes &at
QString key = atts.localName(i).toLower();
QString val = atts.value(i);
- if (!acceptedAttributes->contains(key))
- ReportHandler::warning(QString("Unknown attribute for '%1': '%2'").arg(name).arg(key));
- else
+ if (!acceptedAttributes->contains(key)) {
+ qCWarning(lcShiboken).noquote().nospace()
+ << QStringLiteral("Unknown attribute for '%1': '%2'").arg(name, key);
+ } else {
(*acceptedAttributes)[key] = val;
+ }
}
}
@@ -401,7 +403,7 @@ bool Handler::convertBoolean(const QString &_value, const QString &attributeName
QString warn = QString("Boolean value '%1' not supported in attribute '%2'. Use 'yes' or 'no'. Defaulting to '%3'.")
.arg(value).arg(attributeName).arg(defaultValue ? "yes" : "no");
- ReportHandler::warning(warn);
+ qCWarning(lcShiboken).noquote().nospace() << warn;
return defaultValue;
}
}
@@ -568,7 +570,10 @@ bool Handler::startElement(const QString &, const QString &n,
if (m_database->shouldDropTypeEntry(identifier)) {
m_currentDroppedEntry = element;
m_currentDroppedEntryDepth = 1;
- ReportHandler::debugSparse(QString("Type system entry '%1' was intentionally dropped from generation.").arg(identifier));
+ if (ReportHandler::isDebug(ReportHandler::SparseDebug)) {
+ qCDebug(lcShiboken)
+ << QStringLiteral("Type system entry '%1' was intentionally dropped from generation.").arg(identifier);
+ }
return true;
}
}
@@ -605,7 +610,8 @@ bool Handler::startElement(const QString &, const QString &n,
&& element->type != StackElement::FunctionTypeEntry) {
TypeEntry *tmp = m_database->findType(name);
if (tmp)
- ReportHandler::warning(QString("Duplicate type entry: '%1'").arg(name));
+ qCWarning(lcShiboken).noquote().nospace()
+ << QStringLiteral("Duplicate type entry: '%1'").arg(name);
}
if (element->type == StackElement::EnumTypeEntry) {
@@ -717,9 +723,9 @@ bool Handler::startElement(const QString &, const QString &n,
QStringList lst = n.split("::");
if (QStringList(lst.mid(0, lst.size() - 1)).join("::") != m_currentEnum->targetLangQualifier()) {
- ReportHandler::warning(QString("enum %1 and flags %2 differ in qualifiers")
- .arg(m_currentEnum->targetLangQualifier())
- .arg(lst.at(0)));
+ qCWarning(lcShiboken).noquote().nospace()
+ << QStringLiteral("enum %1 and flags %2 differ in qualifiers")
+ .arg(m_currentEnum->targetLangQualifier(), lst.constFirst());
}
ftype->setFlagsName(lst.last());
@@ -866,7 +872,8 @@ bool Handler::startElement(const QString &, const QString &n,
m_database->addType(element->entry);
setTypeRevision(element->entry, attributes["revision"].toInt());
} else {
- ReportHandler::warning(QString("Type: %1 was rejected by typesystem").arg(name));
+ qCWarning(lcShiboken).noquote().nospace()
+ << QStringLiteral("Type: %1 was rejected by typesystem").arg(name);
}
} else if (element->type == StackElement::InjectDocumentation) {
@@ -1190,10 +1197,10 @@ bool Handler::startElement(const QString &, const QString &n,
if (conversionSource.open(QIODevice::ReadOnly | QIODevice::Text)) {
topElement.entry->setConversionRule(conversionFlag + QString::fromUtf8(conversionSource.readAll()));
} else {
- ReportHandler::warning("File containing conversion code for "
- + topElement.entry->name()
- + " type does not exist or is not readable: "
- + sourceFile);
+ qCWarning(lcShiboken).noquote().nospace()
+ << "File containing conversion code for "
+ << topElement.entry->name() << " type does not exist or is not readable: "
+ << sourceFile;
}
}
}
@@ -1280,7 +1287,7 @@ bool Handler::startElement(const QString &, const QString &n,
if (!m_contextStack.top()->functionMods.last().argument_mods.last().index)
m_contextStack.top()->functionMods.last().argument_mods.last().nullPointerDefaultValue = attributes["default-value"];
else if (!attributes["default-value"].isEmpty())
- ReportHandler::warning("default values for null pointer guards are only effective for return values");
+ qCWarning(lcShiboken) << "default values for null pointer guards are only effective for return values";
}
break;
@@ -1322,7 +1329,7 @@ bool Handler::startElement(const QString &, const QString &n,
break;
case StackElement::SuppressedWarning:
if (attributes["text"].isEmpty())
- ReportHandler::warning("Suppressed warning with no text specified");
+ qCWarning(lcShiboken) << "Suppressed warning with no text specified";
else
m_database->addSuppressedWarning(attributes["text"]);
break;
@@ -1347,14 +1354,14 @@ bool Handler::startElement(const QString &, const QString &n,
QString meta_name = attributes["meta-name"];
if (meta_name.isEmpty())
- ReportHandler::warning("Empty meta name in argument map");
+ qCWarning(lcShiboken) << "Empty meta name in argument map";
if (topElement.type == StackElement::InjectCodeInFunction)
m_contextStack.top()->functionMods.last().snips.last().argumentMap[pos] = meta_name;
else {
- ReportHandler::warning("Argument maps are only useful for injection of code "
- "into functions.");
+ qCWarning(lcShiboken) << "Argument maps are only useful for injection of code "
+ "into functions.";
}
}
break;
@@ -1735,8 +1742,10 @@ bool Handler::startElement(const QString &, const QString &n,
snip.addCode(content);
in_file = true;
}
- } else
- ReportHandler::warning("File for inject code not exist: " + file_name);
+ } else {
+ qCWarning(lcShiboken).noquote().nospace()
+ << "File for inject code not exist: " << QDir::toNativeSeparators(file_name);
+ }
}
@@ -2021,8 +2030,10 @@ QString TemplateInstance::expandCode() const
res.replace(key, replaceRules[key]);
return "// TEMPLATE - " + m_name + " - START" + res + "// TEMPLATE - " + m_name + " - END";
- } else
- ReportHandler::warning("insert-template referring to non-existing template '" + m_name + "'");
+ } else {
+ qCWarning(lcShiboken).noquote().nospace()
+ << "insert-template referring to non-existing template '" << m_name << '\'';
+ }
return QString();
}
diff --git a/generator/generator.cpp b/generator/generator.cpp
index 2d2456a10..dc25a88a7 100644
--- a/generator/generator.cpp
+++ b/generator/generator.cpp
@@ -75,7 +75,7 @@ bool Generator::setup(const ApiExtractor& extractor, const QMap< QString, QStrin
if (entryFound)
m_d->packageName = entryFound->name();
else
- ReportHandler::warning("Couldn't find the package name!!");
+ qCWarning(lcShiboken) << "Couldn't find the package name!!";
collectInstantiatedContainers();
@@ -253,7 +253,8 @@ void Generator::generate()
QString fileName = fileNameForClass(cls);
if (fileName.isNull())
continue;
- ReportHandler::debugSparse(QString("generating: %1").arg(fileName));
+ if (ReportHandler::isDebug(ReportHandler::SparseDebug))
+ qCDebug(lcShiboken) << "generating: " << fileName;
FileOut fileOut(outputDirectory() + '/' + subDirectoryForClass(cls) + '/' + fileName);
generateClass(fileOut.stream, cls);
@@ -279,9 +280,10 @@ void verifyDirectoryFor(const QFile &file)
{
QDir dir = QFileInfo(file).dir();
if (!dir.exists()) {
- if (!dir.mkpath(dir.absolutePath()))
- ReportHandler::warning(QString("unable to create directory '%1'")
- .arg(dir.absolutePath()));
+ if (!dir.mkpath(dir.absolutePath())) {
+ qCWarning(lcShiboken).noquote().nospace()
+ << QStringLiteral("unable to create directory '%1'").arg(dir.absolutePath());
+ }
}
}
diff --git a/generator/main.cpp b/generator/main.cpp
index aafeaa789..a03fd3aae 100644
--- a/generator/main.cpp
+++ b/generator/main.cpp
@@ -291,6 +291,7 @@ int main(int argc, char *argv[])
{
// needed by qxmlpatterns
QCoreApplication app(argc, argv);
+ ReportHandler::install();
// Store command arguments in a map
QMap<QString, QString> args = getCommandLineArgs();
@@ -347,7 +348,8 @@ int main(int argc, char *argv[])
if (!QDir(outputDirectory).exists()) {
if (!QDir().mkpath(outputDirectory)) {
- ReportHandler::warning("Can't create output directory: "+outputDirectory);
+ qCWarning(lcShiboken).noquote().nospace()
+ << "Can't create output directory: " << QDir::toNativeSeparators(outputDirectory);
return EXIT_FAILURE;
}
}
@@ -431,7 +433,7 @@ int main(int argc, char *argv[])
return EXIT_FAILURE;
if (!extractor.classCount())
- ReportHandler::warning("No C++ classes found!");
+ qCWarning(lcShiboken) << "No C++ classes found!";
foreach (Generator* g, generators) {
g->setOutputDirectory(outputDirectory);
@@ -441,7 +443,6 @@ int main(int argc, char *argv[])
}
qDeleteAll(generators);
- ReportHandler::flush();
std::cout << "Done, " << ReportHandler::warningCount();
std::cout << " warnings (" << ReportHandler::suppressedCount() << " known issues)";
std::cout << std::endl;
diff --git a/generator/shiboken2/cppgenerator.cpp b/generator/shiboken2/cppgenerator.cpp
index 00355263a..c3defd3a4 100644
--- a/generator/shiboken2/cppgenerator.cpp
+++ b/generator/shiboken2/cppgenerator.cpp
@@ -152,7 +152,8 @@ bool CppGenerator::hasBoolCast(const AbstractMetaClass* metaClass) const
*/
void CppGenerator::generateClass(QTextStream &s, const AbstractMetaClass *metaClass)
{
- ReportHandler::debugSparse("Generating wrapper implementation for " + metaClass->fullName());
+ if (ReportHandler::isDebug(ReportHandler::SparseDebug))
+ qCDebug(lcShiboken) << "Generating wrapper implementation for " << metaClass->fullName();
// write license comment
s << licenseComment() << endl;
@@ -542,7 +543,7 @@ void CppGenerator::writeVirtualMethodNative(QTextStream&s, const AbstractMetaFun
while ((offset = regex.indexIn(defaultReturnExpr, offset)) != -1) {
int argId = regex.cap(1).toInt() - 1;
if (argId < 0 || argId > func->arguments().count()) {
- ReportHandler::warning("The expression used in return value contains an invalid index.");
+ qCWarning(lcShiboken) << "The expression used in return value contains an invalid index.";
break;
}
defaultReturnExpr.replace(regex.cap(0), func->arguments()[argId]->name());
@@ -554,16 +555,16 @@ void CppGenerator::writeVirtualMethodNative(QTextStream&s, const AbstractMetaFun
defaultReturnExpr = minimalConstructor(func->type());
if (defaultReturnExpr.isEmpty()) {
QString errorMsg = QString(MIN_CTOR_ERROR_MSG).arg(func->type()->cppSignature());
- ReportHandler::warning(errorMsg);
+ qCWarning(lcShiboken).noquote().nospace() << errorMsg;
s << endl << INDENT << "#error " << errorMsg << endl;
}
}
if (func->isAbstract() && func->isModifiedRemoved()) {
- ReportHandler::warning(QString("Pure virtual method '%1::%2' must be implement but was "\
- "completely removed on type system.")
- .arg(func->ownerClass()->name())
- .arg(func->minimalSignature()));
+ qCWarning(lcShiboken).noquote().nospace()
+ << QString::fromLatin1("Pure virtual method '%1::%2' must be implement but was "\
+ "completely removed on type system.")
+ .arg(func->ownerClass()->name(), func->minimalSignature());
s << INDENT << "return " << defaultReturnExpr << ';' << endl;
s << '}' << endl << endl;
return;
@@ -1855,12 +1856,11 @@ static void checkTypeViability(const AbstractMetaFunction* func, const AbstractM
QString prefix;
if (func->ownerClass())
prefix = QString("%1::").arg(func->ownerClass()->qualifiedCppName());
- ReportHandler::warning(QString("There's no user provided way (conversion rule, argument removal, custom code, etc) "
- "to handle the primitive %1 type '%2' in function '%3%4'.")
- .arg(argIdx == 0 ? "return" : "argument")
- .arg(type->cppSignature())
- .arg(prefix)
- .arg(func->signature()));
+ qCWarning(lcShiboken).noquote().nospace()
+ << QString::fromLatin1("There's no user provided way (conversion rule, argument removal, custom code, etc) "
+ "to handle the primitive %1 type '%2' in function '%3%4'.")
+ .arg(argIdx == 0 ? QStringLiteral("return") : QStringLiteral("argument"),
+ type->cppSignature(), prefix, func->signature());
}
static void checkTypeViability(const AbstractMetaFunction* func)
@@ -1916,7 +1916,8 @@ void CppGenerator::writeArgumentConversion(QTextStream& s,
const AbstractMetaType* CppGenerator::getArgumentType(const AbstractMetaFunction* func, int argPos)
{
if (argPos < 0 || argPos > func->arguments().size()) {
- ReportHandler::warning(QString("Argument index for function '%1' out of range.").arg(func->signature()));
+ qCWarning(lcShiboken).noquote().nospace()
+ << QStringLiteral("Argument index for function '%1' out of range.").arg(func->signature());
return 0;
}
@@ -1927,10 +1928,10 @@ const AbstractMetaType* CppGenerator::getArgumentType(const AbstractMetaFunction
else
argType = buildAbstractMetaTypeFromString(typeReplaced);
if (!argType && !m_knownPythonTypes.contains(typeReplaced)) {
- ReportHandler::warning(QString("Unknown type '%1' used as argument type replacement "\
- "in function '%2', the generated code may be broken.")
- .arg(typeReplaced)
- .arg(func->signature()));
+ qCWarning(lcShiboken).noquote().nospace()
+ << QString::fromLatin1("Unknown type '%1' used as argument type replacement "\
+ "in function '%2', the generated code may be broken.")
+ .arg(typeReplaced, func->signature());
}
return argType;
}
@@ -2680,7 +2681,7 @@ QString CppGenerator::argumentNameFromIndex(const AbstractMetaFunction* func, in
if (const AbstractMetaClass *declaringClass = func->declaringClass())
message += declaringClass->name() + QLatin1String("::");
message += func->name() + QLatin1String("()");
- ReportHandler::warning(message);
+ qCWarning(lcShiboken).noquote().nospace() << message;
}
} else {
int realIndex = argIndex - 1 - OverloadData::numberOfRemovedArguments(func, argIndex - 1);
@@ -3040,7 +3041,7 @@ void CppGenerator::writeMethodCall(QTextStream& s, const AbstractMetaFunction* f
if (refCount.action != ReferenceCount::Set
&& refCount.action != ReferenceCount::Remove
&& refCount.action != ReferenceCount::Add) {
- ReportHandler::warning("\"set\", \"add\" and \"remove\" are the only values supported by Shiboken for action attribute of reference-count tag.");
+ qCWarning(lcShiboken) << "\"set\", \"add\" and \"remove\" are the only values supported by Shiboken for action attribute of reference-count tag.";
continue;
}
const AbstractMetaClass* wrappedClass = 0;
@@ -4096,8 +4097,11 @@ void CppGenerator::writeSignalInitialization(QTextStream& s, const AbstractMetaC
AbstractMetaType* metaType = arg->type();
QByteArray origType = SBK_NORMALIZED_TYPE(qPrintable(metaType->originalTypeDescription()));
QByteArray cppSig = SBK_NORMALIZED_TYPE(qPrintable(metaType->cppSignature()));
- if ((origType != cppSig) && (!metaType->isFlags()))
- ReportHandler::warning("Typedef used on signal " + metaClass->qualifiedCppName() + "::" + cppSignal->signature());
+ if ((origType != cppSig) && (!metaType->isFlags())) {
+ qCWarning(lcShiboken).noquote().nospace()
+ << "Typedef used on signal " << metaClass->qualifiedCppName() << "::"
+ << cppSignal->signature();
+ }
}
}
@@ -4452,10 +4456,11 @@ void CppGenerator::writeInitQtMetaTypeFunctionBody(QTextStream& s, const Abstrac
if (canBeValue) {
foreach (QString name, nameVariants) {
if (name == "iterator") {
- ReportHandler::warning(QString("%1:%2 FIXME:\n"
- " The code tried to qRegisterMetaType the unqualified name "
- "'iterator'. This is currently fixed by a hack(ct) and needs improvement!")
- .arg(__FILE__).arg(__LINE__));
+ qCWarning(lcShiboken).noquote().nospace()
+ << QString::fromLatin1("%1:%2 FIXME:\n"
+ " The code tried to qRegisterMetaType the unqualified name "
+ "'iterator'. This is currently fixed by a hack(ct) and needs improvement!")
+ .arg(__FILE__).arg(__LINE__);
continue;
}
s << INDENT << "qRegisterMetaType< ::" << className << " >(\"" << name << "\");" << endl;
@@ -4501,9 +4506,10 @@ void CppGenerator::writeTypeDiscoveryFunction(QTextStream& s, const AbstractMeta
s << INDENT << "return dynamic_cast< ::" << metaClass->qualifiedCppName()
<< "*>(reinterpret_cast< ::"<< ancestor->qualifiedCppName() << "*>(cptr));" << endl;
} else {
- ReportHandler::warning(metaClass->qualifiedCppName() + " inherits from a non polymorphic type ("
- + ancestor->qualifiedCppName() + "), type discovery based on RTTI is "
- "impossible, write a polymorphic-id-expression for this type.");
+ qCWarning(lcShiboken).noquote().nospace()
+ << metaClass->qualifiedCppName() << " inherits from a non polymorphic type ("
+ << ancestor->qualifiedCppName() << "), type discovery based on RTTI is "
+ "impossible, write a polymorphic-id-expression for this type.";
}
}
@@ -4658,7 +4664,8 @@ void CppGenerator::finishGeneration()
QFile file(moduleFileName);
verifyDirectoryFor(file);
if (!file.open(QFile::WriteOnly)) {
- ReportHandler::warning("Error writing file: " + moduleFileName);
+ qCWarning(lcShiboken).noquote().nospace()
+ << "Error writing file: " << QDir::toNativeSeparators(moduleFileName);
return;
}
@@ -5016,7 +5023,8 @@ bool CppGenerator::writeParentChildManagement(QTextStream& s, const AbstractMeta
QString childVariable;
if (action != ArgumentOwner::Invalid) {
if (!usePyArgs && argIndex > 1)
- ReportHandler::warning("Argument index for parent tag out of bounds: "+func->signature());
+ qCWarning(lcShiboken).noquote().nospace()
+ << "Argument index for parent tag out of bounds: " << func->signature();
if (action == ArgumentOwner::Remove) {
parentVariable = "Py_None";
diff --git a/generator/shiboken2/headergenerator.cpp b/generator/shiboken2/headergenerator.cpp
index b5fa6066e..a9a831633 100644
--- a/generator/shiboken2/headergenerator.cpp
+++ b/generator/shiboken2/headergenerator.cpp
@@ -72,7 +72,8 @@ void HeaderGenerator::writeProtectedFieldAccessors(QTextStream& s, const Abstrac
void HeaderGenerator::generateClass(QTextStream& s, const AbstractMetaClass* metaClass)
{
- ReportHandler::debugSparse("Generating header for " + metaClass->fullName());
+ if (ReportHandler::isDebug(ReportHandler::SparseDebug))
+ qCDebug(lcShiboken) << "Generating header for " << metaClass->fullName();
m_inheritedOverloads.clear();
Indentation indent(INDENT);
diff --git a/generator/shiboken2/overloaddata.cpp b/generator/shiboken2/overloaddata.cpp
index 7335044a9..e76794262 100644
--- a/generator/shiboken2/overloaddata.cpp
+++ b/generator/shiboken2/overloaddata.cpp
@@ -395,7 +395,9 @@ void OverloadData::sortNextOverloads()
for (; it != sortData.map.end(); ++it)
nodeNames.insert(it.value(), it.key());
graph.dumpDot(nodeNames, graphName);
- ReportHandler::warning(QString("Cyclic dependency found on overloaddata for '%1' method! The graph boy saved the graph at %2.").arg(qPrintable(funcName)).arg(qPrintable(graphName)));
+ qCWarning(lcShiboken).noquote().nospace()
+ << QStringLiteral("Cyclic dependency found on overloaddata for '%1' method! The graph boy saved the graph at %2.")
+ .arg(funcName, graphName);
}
m_nextOverloadData.clear();
diff --git a/generator/shiboken2/shibokengenerator.cpp b/generator/shiboken2/shibokengenerator.cpp
index 81b7a281e..f7162fda8 100644
--- a/generator/shiboken2/shibokengenerator.cpp
+++ b/generator/shiboken2/shibokengenerator.cpp
@@ -613,12 +613,11 @@ QString ShibokenGenerator::getFormatUnitString(const AbstractMetaFunction* func,
} else if (isCString(arg->type())) {
result += 'z';
} else {
- QString report;
- QTextStream(&report) << "Method: " << func->ownerClass()->qualifiedCppName()
- << "::" << func->signature() << " => Arg:"
- << arg->name() << "index: " << arg->argumentIndex()
- << " - cannot be handled properly. Use an inject-code to fix it!";
- ReportHandler::warning(report);
+ qCWarning(lcShiboken).noquote().nospace()
+ << "Method: " << func->ownerClass()->qualifiedCppName()
+ << "::" << func->signature() << " => Arg:"
+ << arg->name() << "index: " << arg->argumentIndex()
+ << " - cannot be handled properly. Use an inject-code to fix it!";
result += '?';
}
}
@@ -811,7 +810,7 @@ QString ShibokenGenerator::pythonOperatorFunctionName(QString cppOpFuncName)
{
QString value = m_pythonOperators.value(cppOpFuncName);
if (value.isEmpty()) {
- ReportHandler::warning("Unknown operator: "+cppOpFuncName);
+ qCWarning(lcShiboken).noquote().nospace() << "Unknown operator: " << cppOpFuncName;
value = "UNKNOWN_OPERATOR";
}
value.prepend("__").append("__");
@@ -1559,7 +1558,8 @@ void ShibokenGenerator::writeCodeSnips(QTextStream& s,
} else {
static QRegExp pyArgsRegexCheck("%PYARG_([2-9]+)");
if (pyArgsRegexCheck.indexIn(code) != -1) {
- ReportHandler::warning("Wrong index for %PYARG variable ("+pyArgsRegexCheck.cap(1)+") on "+func->signature());
+ qCWarning(lcShiboken).noquote().nospace()
+ << "Wrong index for %PYARG variable (" << pyArgsRegexCheck.cap(1) << ") on " << func->signature();
return;
}
code.replace("%PYARG_1", PYTHON_ARG);
@@ -1582,7 +1582,9 @@ void ShibokenGenerator::writeCodeSnips(QTextStream& s,
int pos = 0;
static QRegExp cppArgTypeRegexCheck("%ARG(\\d+)_TYPE");
while ((pos = cppArgTypeRegexCheck.indexIn(code, pos)) != -1) {
- ReportHandler::warning("Wrong index for %ARG#_TYPE variable ("+cppArgTypeRegexCheck.cap(1)+") on "+func->signature());
+ qCWarning(lcShiboken).noquote().nospace()
+ << "Wrong index for %ARG#_TYPE variable (" << cppArgTypeRegexCheck.cap(1)
+ << ") on " << func->signature();
pos += cppArgTypeRegexCheck.matchedLength();
}
@@ -1643,7 +1645,7 @@ void ShibokenGenerator::writeCodeSnips(QTextStream& s,
code.replace("%BEGIN_ALLOW_THREADS", BEGIN_ALLOW_THREADS);
code.replace("%END_ALLOW_THREADS", END_ALLOW_THREADS);
} else {
- ReportHandler::warning("%BEGIN_ALLOW_THREADS and %END_ALLOW_THREADS mismatch");
+ qCWarning(lcShiboken) << "%BEGIN_ALLOW_THREADS and %END_ALLOW_THREADS mismatch";
}
}