Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/PyLauncher/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ int main(int argc, char *argv[])
}
PythonQtScriptingConsole console(NULL, mainContext);

Q_FOREACH(QString file, files) {
for (const QString& file : qAsConst(files)) {
mainContext.evalFile(file);
}
if (showConsole || console.hadError()) {
Expand Down
23 changes: 10 additions & 13 deletions generator/abstractmetabuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ void AbstractMetaBuilder::traverseArithmeticOperator(FunctionModelItem item)
void AbstractMetaBuilder::fixQObjectForScope(TypeDatabase *types,
NamespaceModelItem scope)
{
for (ClassModelItem item : scope->classes()) {
for (const ClassModelItem& item : scope->classes()) {
QString qualified_name = item->qualifiedName().join("::");
TypeEntry *entry = types->findType(qualified_name);
if (entry) {
Expand All @@ -378,7 +378,7 @@ void AbstractMetaBuilder::fixQObjectForScope(TypeDatabase *types,
}
}

for (NamespaceModelItem item : scope->namespaceMap().values()) {
for (const NamespaceModelItem& item : scope->namespaceMap().values()) {
if (scope != item)
fixQObjectForScope(types, item);
}
Expand Down Expand Up @@ -490,25 +490,22 @@ bool AbstractMetaBuilder::build()
// First automatically add all enums marked as QEnum into the TypeDatabase
// (if they don't contain an entry already). If there is an QEnum entry,
// the enum is obviously meant for scripting.
for (ClassModelItem item : typeMap.values()) {
for (const ClassModelItem& item : typeMap.values()) {
autoAddQEnumsForClassItem(item);
}


for (ClassModelItem item : typeMap.values()) {
for (const ClassModelItem& item : typeMap.values()) {
AbstractMetaClass *cls = traverseClass(item);
addAbstractMetaClass(cls);
}


QHash<QString, NamespaceModelItem> namespaceMap = m_dom->namespaceMap();
for (NamespaceModelItem item : namespaceMap.values()) {
for (const NamespaceModelItem& item : namespaceMap.values()) {
AbstractMetaClass *meta_class = traverseNamespace(item);
if (meta_class)
m_meta_classes << meta_class;
}


// Some trickery to support global-namespace enums...
QHash<QString, EnumModelItem> enumMap = m_dom->enumMap();
m_current_class = 0;
Expand Down Expand Up @@ -848,7 +845,7 @@ AbstractMetaEnum *AbstractMetaBuilder::traverseEnum(EnumModelItem enum_item, Abs

ReportHandler::debugMedium(QString(" - traversing enum %1").arg(meta_enum->fullName()));

for (EnumeratorModelItem value : enum_item->enumerators()) {
for (const EnumeratorModelItem& value : enum_item->enumerators()) {
if (meta_enum->typeEntry()->isEnumValueRejected(value->name())) {
continue;
}
Expand Down Expand Up @@ -1077,7 +1074,7 @@ AbstractMetaField *AbstractMetaBuilder::traverseField(VariableModelItem field, c

void AbstractMetaBuilder::traverseFields(ScopeModelItem scope_item, AbstractMetaClass *meta_class)
{
for (VariableModelItem field : scope_item->variables()) {
for (const VariableModelItem& field : scope_item->variables()) {
AbstractMetaField *meta_field = traverseField(field, meta_class);

if (meta_field) {
Expand Down Expand Up @@ -1108,7 +1105,7 @@ void AbstractMetaBuilder::setupFunctionDefaults(AbstractMetaFunction *meta_funct

void AbstractMetaBuilder::traverseFunctions(ScopeModelItem scope_item, AbstractMetaClass *meta_class)
{
for (FunctionModelItem function : scope_item->functions()) {
for (const FunctionModelItem& function : scope_item->functions()) {
AbstractMetaFunction *meta_function = traverseFunction(function);

if (meta_function) {
Expand Down Expand Up @@ -2040,7 +2037,7 @@ bool AbstractMetaBuilder::inheritTemplate(AbstractMetaClass *subclass,
}

AbstractMetaFunctionList funcs = subclass->functions();
for (const AbstractMetaFunction *function : template_class->functions()) {
for (const AbstractMetaFunction* function : template_class->functions()) {

if (function->isModifiedRemoved(TypeSystem::All))
continue;
Expand All @@ -2056,7 +2053,7 @@ bool AbstractMetaBuilder::inheritTemplate(AbstractMetaClass *subclass,
continue;
}

for (AbstractMetaArgument *argument : function->arguments()) {
for (const AbstractMetaArgument* argument : function->arguments()) {
AbstractMetaType::shared_pointer atype = argument->type();

AbstractMetaArgument *arg = argument->copy();
Expand Down
215 changes: 109 additions & 106 deletions generator/abstractmetalang.cpp

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion generator/abstractmetalang.h
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ class AbstractMetaFunction : public AbstractMetaAttributes
// true if one or more of the arguments are of QtJambiObject subclasses
bool argumentsHaveNativeId() const
{
foreach (const AbstractMetaArgument *arg, m_arguments) {
for (const AbstractMetaArgument* arg : m_arguments) {
if (arg->type()->hasNativeId())
return true;
}
Expand Down
8 changes: 4 additions & 4 deletions generator/generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ void Generator::generate()

m_classes.sort();

foreach (AbstractMetaClass *cls, m_classes) {
for (AbstractMetaClass* cls : m_classes) {
if (!shouldGenerate(cls))
continue;

Expand All @@ -87,7 +87,7 @@ void Generator::printClasses()
AbstractMetaClassList classes = m_classes;
classes.sort();

foreach (AbstractMetaClass *cls, classes) {
for (AbstractMetaClass* cls : classes) {
if (!shouldGenerate(cls))
continue;
write(s, cls);
Expand Down Expand Up @@ -127,10 +127,10 @@ bool Generator::hasDefaultConstructor(const AbstractMetaType *type)
QString full_name = type->typeEntry()->qualifiedTargetLangName();
QString class_name = type->typeEntry()->targetLangName();

foreach (const AbstractMetaClass *java_class, m_classes) {
for (const AbstractMetaClass* java_class : m_classes) {
if (java_class->typeEntry()->qualifiedTargetLangName() == full_name) {
AbstractMetaFunctionList functions = java_class->functions();
foreach (const AbstractMetaFunction *function, functions) {
for (const AbstractMetaFunction* function : functions) {
if (function->arguments().size() == 0 && function->name() == class_name)
return true;
}
Expand Down
30 changes: 20 additions & 10 deletions generator/parser/binder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,8 @@ void Binder::declare_symbol(SimpleDeclarationAST *node, InitDeclaratorAST *init_
fun->setVariadics (decl_cc.isVariadics ());

// ... and the signature
foreach (DeclaratorCompiler::Parameter p, decl_cc.parameters())
const QList<DeclaratorCompiler::Parameter> parameters = decl_cc.parameters();
for (const DeclaratorCompiler::Parameter& p : parameters)
{
ArgumentModelItem arg = model()->create<ArgumentModelItem>();
arg->setType(qualifyType(p.type, _M_context));
Expand Down Expand Up @@ -361,8 +362,10 @@ void Binder::declare_symbol(SimpleDeclarationAST *node, InitDeclaratorAST *init_
{
typeInfo.setFunctionPointer (true);
decl_cc.run (init_declarator->declarator);
foreach (DeclaratorCompiler::Parameter p, decl_cc.parameters())
const QList<DeclaratorCompiler::Parameter> parameters = decl_cc.parameters();
for (const DeclaratorCompiler::Parameter& p : parameters) {
typeInfo.addArgument(p.type);
}
}

var->setType(qualifyType(typeInfo, _M_context));
Expand Down Expand Up @@ -426,7 +429,8 @@ void Binder::visitFunctionDefinition(FunctionDefinitionAST *node)
}

decl_cc.run(declarator);
foreach (DeclaratorCompiler::Parameter p, decl_cc.parameters()) {
const QList<DeclaratorCompiler::Parameter> parameters = decl_cc.parameters();
for (const DeclaratorCompiler::Parameter& p : parameters) {
if (p.type.isRvalueReference()) {
//warnHere();
//std::cerr << "** Skipping function with rvalue reference parameter: "
Expand Down Expand Up @@ -481,22 +485,25 @@ void Binder::visitFunctionDefinition(FunctionDefinitionAST *node)
}
_M_current_function->setVariadics (decl_cc.isVariadics ());

foreach (DeclaratorCompiler::Parameter p, decl_cc.parameters())
for (const DeclaratorCompiler::Parameter& p : parameters)
{
ArgumentModelItem arg = model()->create<ArgumentModelItem>();


// Work on a local copy of the type only
TypeInfo parameter_type = p.type;

if (_M_current_class && _M_current_class->isTemplateClass())
{
QStringList qualifiedName = p.type.qualifiedName();
QStringList qualifiedName = parameter_type.qualifiedName();
if (qualifiedName.size() == 1 && !qualifiedName.last().contains('<') &&
qualifiedName.last() == _M_current_class->name().split('<').first())
{
// Fix: add template arguments if the argument type is the current class
// name without template arguments
p.type.setQualifiedName(QStringList(_M_current_class->name()));
parameter_type.setQualifiedName(QStringList(_M_current_class->name()));
}
}
arg->setType(qualifyType(p.type, functionScope->qualifiedName()));
arg->setType(qualifyType(parameter_type, functionScope->qualifiedName()));
arg->setName(p.name);
arg->setDefaultValue(p.defaultValue);
if (p.defaultValue)
Expand Down Expand Up @@ -650,8 +657,10 @@ void Binder::visitTypedef(TypedefAST *node)
{
typeInfo.setFunctionPointer (true);
decl_cc.run (init_declarator->declarator);
foreach (DeclaratorCompiler::Parameter p, decl_cc.parameters())
const QList<DeclaratorCompiler::Parameter> parameters = decl_cc.parameters();
for (const DeclaratorCompiler::Parameter& p : parameters) {
typeInfo.addArgument(p.type);
}
}

ScopeModelItem scope = currentScope();
Expand Down Expand Up @@ -1029,7 +1038,8 @@ TypeInfo Binder::qualifyType(const TypeInfo &type, const QStringList &context) c

if (ClassModelItem klass = scope.dynamicCast<_ClassModelItem> ())
{
foreach (QString base, klass->baseClasses ())
const QStringList baseClasses = klass->baseClasses();
for (const QString& base : baseClasses)
{
QStringList ctx = context;
ctx.removeLast();
Expand Down
7 changes: 4 additions & 3 deletions generator/parser/codemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,8 @@ QString TypeInfo::toString(bool parsable) const
tmp += QLatin1String(")");
}

foreach (QString elt, arrayElements ())
const QStringList arrayElements = this->arrayElements();
for (const QString& elt : arrayElements)
{
tmp += QLatin1String ("[");
tmp += elt;
Expand Down Expand Up @@ -398,9 +399,9 @@ void _ClassModelItem::addPropertyDeclaration(const QString &propertyDeclaration)
// ---------------------------------------------------------------------------
FunctionModelItem _ScopeModelItem::declaredFunction(FunctionModelItem item)
{
FunctionList function_list = findFunctions(item->name());
const FunctionList function_list = findFunctions(item->name());

foreach (FunctionModelItem fun, function_list)
for (const FunctionModelItem& fun : function_list)
{
if (fun->isSimilar(item))
return fun;
Expand Down
4 changes: 2 additions & 2 deletions generator/prigenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ void PriGenerator::generate()
}

file.stream << "HEADERS += \\\n";
foreach (const QString &entry, list) {
for (const QString& entry : list) {
file.stream << " $$PWD/" << entry << " \\\n";
}

Expand All @@ -156,7 +156,7 @@ void PriGenerator::generate()
if (compact) {
list = compactFiles(list, ".cpp", m_out_dir + "/generated_cpp/" + folder, folder);
}
foreach (const QString &entry, list) {
for (const QString& entry : list) {
file.stream << " $$PWD/" << entry << " \\\n";
}
file.stream << " $$PWD/" << folder << "_init.cpp\n";
Expand Down
16 changes: 8 additions & 8 deletions generator/setupgenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@ static QStringList getOperatorCodes(const AbstractMetaClass* cls) {
QSet<QString> operatorCodes;
AbstractMetaFunctionList returned;
AbstractMetaFunctionList functions = cls->functions();
foreach (AbstractMetaFunction *function, functions) {
for (AbstractMetaFunction* function : functions) {
if (function->originalName().startsWith("operator")) {
QString op = function->originalName().mid(8);
operatorCodes.insert(op);
}
}
QSet<QString> r;
for (QString op :
for (const QString& op :
# if QT_VERSION < QT_VERSION_CHECK(5,14,0)
operatorCodes.toList()
# else
Expand Down Expand Up @@ -182,7 +182,7 @@ static void addListRegistration(AbstractMetaType::shared_pointer type, QSet<QStr

/*
QString debugStr;
Q_FOREACH(AbstractMetaType* arg, args) {
for (AbstractMetaType* arg : args) {
debugStr += QString(arg->typeEntry()->isEnum()?"ENUM ":"") + arg->typeEntry()->qualifiedCppName() + ",";
if (arg->typeEntry()->qualifiedCppName() == "QPair") {
debugStr += "(" + arg->instantiations().at(0)->typeEntry()->qualifiedCppName() + ",";
Expand Down Expand Up @@ -238,7 +238,7 @@ void SetupGenerator::generate()
while (pack.hasNext()) {
pack.next();
QList<const AbstractMetaClass*> list = pack.value();
foreach (const AbstractMetaClass *cls, list) {
for (const AbstractMetaClass* cls : list) {
if (cls->typeEntry()->isPolymorphicBase()) {
classes_with_polymorphic_id.append((AbstractMetaClass*)cls);
}
Expand Down Expand Up @@ -325,7 +325,7 @@ void SetupGenerator::generate()
// declare individual class creation functions
s << "void PythonQt_init_" << initName << "(PyObject* module) {" << endl;

foreach (const AbstractMetaClass *cls, list) {
for (const AbstractMetaClass* cls : list) {
if (cls->qualifiedCppName().contains("Ssl")) {
s << "#ifndef QT_NO_SSL" << endl;
}
Expand Down Expand Up @@ -376,7 +376,7 @@ void SetupGenerator::generate()
}
}
s << endl;
foreach (QString handler, polymorphicHandlers) {
for (QString handler : polymorphicHandlers) {
s << "PythonQt::self()->addPolymorphicHandler(\""<< handler << "\", polymorphichandler_" << handler << ");" << endl;
}
s << endl;
Expand Down Expand Up @@ -407,14 +407,14 @@ QStringList SetupGenerator::writePolymorphicHandler(QTextStream &s, const QStrin
const AbstractMetaClassList &polybase, QList<const AbstractMetaClass*>& allClasses)
{
QStringList handlers;
foreach (AbstractMetaClass *cls, polybase) {
for (AbstractMetaClass* cls : polybase) {
const ComplexTypeEntry *centry = cls->typeEntry();
if (!centry->isPolymorphicBase())
continue;
bool isGraphicsItem = (cls->qualifiedCppName()=="QGraphicsItem");

bool first = true;
foreach (const AbstractMetaClass *clazz, allClasses) {
for (const AbstractMetaClass* clazz : allClasses) {
bool inherits = false;
if (isGraphicsItem) {
const AbstractMetaClass *currentClazz = clazz;
Expand Down
8 changes: 4 additions & 4 deletions generator/shellimplgenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ void ShellImplGenerator::write(QTextStream &s, const AbstractMetaClass *meta_cla

IncludeList list = meta_class->typeEntry()->extraIncludes();
std::sort(list.begin(), list.end());
foreach (const Include &inc, list) {
for (const Include& inc : list) {
ShellGenerator::writeInclude(s, inc);
}
s << endl;
Expand Down Expand Up @@ -122,7 +122,7 @@ void ShellImplGenerator::write(QTextStream &s, const AbstractMetaClass *meta_cla
s << "}" << endl;

AbstractMetaFunctionList virtualsForShell = getVirtualFunctionsForShell(meta_class);
foreach (const AbstractMetaFunction *fun, virtualsForShell) {
for (const AbstractMetaFunction* fun : virtualsForShell) {
bool hasReturnValue = !fun->type().isNull();
writeFunctionSignature(s, fun, meta_class, QString(),
Option(ShowStatic | UnderscoreSpaces | UseIndexedName),
Expand Down Expand Up @@ -234,7 +234,7 @@ void ShellImplGenerator::write(QTextStream &s, const AbstractMetaClass *meta_cla
if (meta_class->generateShellClass() || !meta_class->isAbstract()) {

// write constructors
foreach (const AbstractMetaFunction *ctor, ctors) {
for (const AbstractMetaFunction* ctor : ctors) {
if (ctor->isAbstract() || (!meta_class->generateShellClass() && !ctor->isPublic())) { continue; }

s << meta_class->qualifiedCppName() << "* ";
Expand Down Expand Up @@ -382,7 +382,7 @@ void ShellImplGenerator::write(QTextStream &s, const AbstractMetaClass *meta_cla
void ShellImplGenerator::writeInjectedCode(QTextStream &s, const AbstractMetaClass *meta_class)
{
CodeSnipList code_snips = meta_class->typeEntry()->codeSnips();
foreach (const CodeSnip &cs, code_snips) {
for (const CodeSnip& cs : code_snips) {
if (cs.language == TypeSystem::PyWrapperCode) {
s << cs.code() << endl;
}
Expand Down
Loading
Loading