aboutsummaryrefslogtreecommitdiffstats
path: root/sources
diff options
context:
space:
mode:
Diffstat (limited to 'sources')
-rw-r--r--sources/shiboken6/ApiExtractor/abstractmetabuilder.cpp56
-rw-r--r--sources/shiboken6/ApiExtractor/abstractmetabuilder.h8
-rw-r--r--sources/shiboken6/ApiExtractor/abstractmetabuilder_p.h1
-rw-r--r--sources/shiboken6/ApiExtractor/apiextractor.cpp7
-rw-r--r--sources/shiboken6/ApiExtractor/apiextractor.h2
-rw-r--r--sources/shiboken6/generator/generator.cpp5
-rw-r--r--sources/shiboken6/generator/generator.h7
-rw-r--r--sources/shiboken6/generator/shiboken/cppgenerator.cpp16
8 files changed, 33 insertions, 69 deletions
diff --git a/sources/shiboken6/ApiExtractor/abstractmetabuilder.cpp b/sources/shiboken6/ApiExtractor/abstractmetabuilder.cpp
index 9f2196d84..787094f76 100644
--- a/sources/shiboken6/ApiExtractor/abstractmetabuilder.cpp
+++ b/sources/shiboken6/ApiExtractor/abstractmetabuilder.cpp
@@ -345,10 +345,41 @@ bool AbstractMetaBuilderPrivate::traverseStreamOperator(const FunctionModelItem
return true;
}
+static bool metaEnumLessThan(const AbstractMetaEnum &e1, const AbstractMetaEnum &e2)
+{ return e1.fullName() < e2.fullName(); }
+
+static bool metaClassLessThan(const AbstractMetaClass *c1, const AbstractMetaClass *c2)
+{ return c1->fullName() < c2->fullName(); }
+
+static bool metaFunctionLessThan(const AbstractMetaFunctionCPtr &f1, const AbstractMetaFunctionCPtr &f2)
+{ return f1->name() < f2->name(); }
+
void AbstractMetaBuilderPrivate::sortLists()
{
+ // Ensure indepedent classes are in alphabetical order,
+ std::sort(m_metaClasses.begin(), m_metaClasses.end(), metaClassLessThan);
+ // this is a temporary solution before new type revision implementation
+ // We need move QMetaObject register before QObject.
+ Dependencies additionalDependencies;
+ if (auto qObjectClass = AbstractMetaClass::findClass(m_metaClasses, QStringLiteral("QObject"))) {
+ if (auto qMetaObjectClass = AbstractMetaClass::findClass(m_metaClasses, QStringLiteral("QMetaObject"))) {
+ Dependency dependency;
+ dependency.parent = qMetaObjectClass;
+ dependency.child = qObjectClass;
+ additionalDependencies.append(dependency);
+ }
+ }
+ m_metaClasses = classesTopologicalSorted(m_metaClasses, additionalDependencies);
+
for (AbstractMetaClass *cls : qAsConst(m_metaClasses))
cls->sortFunctions();
+
+ // Ensure that indexes are in alphabetical order, roughly, except
+ // for classes, which are in topological order
+ std::sort(m_globalEnums.begin(), m_globalEnums.end(), metaEnumLessThan);
+ std::sort(m_templates.begin(), m_templates.end(), metaClassLessThan);
+ std::sort(m_smartPointers.begin(), m_smartPointers.end(), metaClassLessThan);
+ std::sort(m_globalFunctions.begin(), m_globalFunctions.end(), metaFunctionLessThan);
}
FileModelItem AbstractMetaBuilderPrivate::buildDom(QByteArrayList arguments,
@@ -560,9 +591,6 @@ void AbstractMetaBuilderPrivate::traverseDom(const FileModelItem &dom)
ReportHandler::startProgress("Writing log files...");
- // sort all classes topologically
- m_metaClasses = classesTopologicalSorted(m_metaClasses);
-
for (AbstractMetaClass *cls : qAsConst(m_metaClasses)) {
// setupEquals(cls);
// setupComparable(cls);
@@ -595,15 +623,6 @@ void AbstractMetaBuilderPrivate::traverseDom(const FileModelItem &dom)
ReportHandler::endProgress();
}
-static bool metaEnumLessThan(const AbstractMetaEnum &e1, const AbstractMetaEnum &e2)
-{ return e1.fullName() < e2.fullName(); }
-
-static bool metaClassLessThan(const AbstractMetaClass *c1, const AbstractMetaClass *c2)
-{ return c1->fullName() < c2->fullName(); }
-
-static bool metaFunctionLessThan(const AbstractMetaFunctionCPtr &f1, const AbstractMetaFunctionCPtr &f2)
-{ return f1->name() < f2->name(); }
-
bool AbstractMetaBuilder::build(const QByteArrayList &arguments,
LanguageLevel level,
unsigned clangFlags)
@@ -615,13 +634,6 @@ bool AbstractMetaBuilder::build(const QByteArrayList &arguments,
qCDebug(lcShiboken) << dom.data();
d->traverseDom(dom);
- // Ensure that indexes are in alphabetical order, roughly
- std::sort(d->m_globalEnums.begin(), d->m_globalEnums.end(), metaEnumLessThan);
- std::sort(d->m_metaClasses.begin(), d->m_metaClasses.end(), metaClassLessThan);
- std::sort(d->m_templates.begin(), d->m_templates.end(), metaClassLessThan);
- std::sort(d->m_smartPointers.begin(), d->m_smartPointers.end(), metaClassLessThan);
- std::sort(d->m_globalFunctions.begin(), d->m_globalFunctions.end(), metaFunctionLessThan);
-
return true;
}
@@ -3102,12 +3114,6 @@ void AbstractMetaBuilderPrivate::pushScope(const NamespaceModelItem &item)
}
}
-AbstractMetaClassList AbstractMetaBuilder::classesTopologicalSorted(const AbstractMetaClassList &classList,
- const Dependencies &additionalDependencies)
-{
- return AbstractMetaBuilderPrivate::classesTopologicalSorted(classList, additionalDependencies);
-}
-
AbstractMetaArgumentList AbstractMetaBuilderPrivate::reverseList(const AbstractMetaArgumentList &list)
{
AbstractMetaArgumentList ret;
diff --git a/sources/shiboken6/ApiExtractor/abstractmetabuilder.h b/sources/shiboken6/ApiExtractor/abstractmetabuilder.h
index 2ad9db304..e9635233d 100644
--- a/sources/shiboken6/ApiExtractor/abstractmetabuilder.h
+++ b/sources/shiboken6/ApiExtractor/abstractmetabuilder.h
@@ -31,7 +31,6 @@
#include "abstractmetalang_typedefs.h"
#include "header_paths.h"
-#include "dependency.h"
#include "typesystem_enums.h"
#include "clangparser/compilersupport.h"
@@ -73,13 +72,6 @@ public:
const AbstractMetaEnumList &globalEnums() const;
std::optional<AbstractMetaEnum> findEnum(const TypeEntry *typeEntry) const;
- /**
- * Sorts a list of classes topologically.
- * \return a list of classes sorted topologically
- */
- static AbstractMetaClassList classesTopologicalSorted(const AbstractMetaClassList &classList,
- const Dependencies &additionalDependencies = {});
-
bool build(const QByteArrayList &arguments,
LanguageLevel level = LanguageLevel::Default,
unsigned clangFlags = 0);
diff --git a/sources/shiboken6/ApiExtractor/abstractmetabuilder_p.h b/sources/shiboken6/ApiExtractor/abstractmetabuilder_p.h
index 80c7f76d3..a6d3134c3 100644
--- a/sources/shiboken6/ApiExtractor/abstractmetabuilder_p.h
+++ b/sources/shiboken6/ApiExtractor/abstractmetabuilder_p.h
@@ -30,6 +30,7 @@
#define ABSTRACTMETABUILDER_P_H
#include "abstractmetabuilder.h"
+#include "dependency.h"
#include "parser/codemodel_fwd.h"
#include "abstractmetalang.h"
#include "abstractmetatype.h"
diff --git a/sources/shiboken6/ApiExtractor/apiextractor.cpp b/sources/shiboken6/ApiExtractor/apiextractor.cpp
index 02f376bdb..019f3db48 100644
--- a/sources/shiboken6/ApiExtractor/apiextractor.cpp
+++ b/sources/shiboken6/ApiExtractor/apiextractor.cpp
@@ -146,13 +146,6 @@ const AbstractMetaClassList &ApiExtractor::smartPointers() const
return m_builder->smartPointers();
}
-AbstractMetaClassList ApiExtractor::classesTopologicalSorted(const Dependencies &additionalDependencies) const
-{
- Q_ASSERT(m_builder);
- return AbstractMetaBuilder::classesTopologicalSorted(m_builder->classes(),
- additionalDependencies);
-}
-
PrimitiveTypeEntryList ApiExtractor::primitiveTypes() const
{
return TypeDatabase::instance()->primitiveTypes();
diff --git a/sources/shiboken6/ApiExtractor/apiextractor.h b/sources/shiboken6/ApiExtractor/apiextractor.h
index 856734593..5782bd51a 100644
--- a/sources/shiboken6/ApiExtractor/apiextractor.h
+++ b/sources/shiboken6/ApiExtractor/apiextractor.h
@@ -29,7 +29,6 @@
#ifndef APIEXTRACTOR_H
#define APIEXTRACTOR_H
-#include "dependency.h"
#include "abstractmetalang_typedefs.h"
#include "header_paths.h"
#include "typedatabase_typedefs.h"
@@ -86,7 +85,6 @@ public:
const AbstractMetaFunctionCList &globalFunctions() const;
const AbstractMetaClassList &classes() const;
const AbstractMetaClassList &smartPointers() const;
- AbstractMetaClassList classesTopologicalSorted(const Dependencies &additionalDependencies = Dependencies()) const;
PrimitiveTypeEntryList primitiveTypes() const;
ContainerTypeEntryList containerTypes() const;
diff --git a/sources/shiboken6/generator/generator.cpp b/sources/shiboken6/generator/generator.cpp
index 7f8167f58..10c5157ed 100644
--- a/sources/shiboken6/generator/generator.cpp
+++ b/sources/shiboken6/generator/generator.cpp
@@ -362,11 +362,6 @@ const AbstractMetaClassList &Generator::invisibleTopNamespaces() const
return m_d->m_invisibleTopNamespaces;
}
-AbstractMetaClassList Generator::classesTopologicalSorted(const Dependencies &additionalDependencies) const
-{
- return m_d->apiextractor->classesTopologicalSorted(additionalDependencies);
-}
-
const AbstractMetaFunctionCList &Generator::globalFunctions() const
{
return m_d->apiextractor->globalFunctions();
diff --git a/sources/shiboken6/generator/generator.h b/sources/shiboken6/generator/generator.h
index 79e2f19b1..9cf1abe45 100644
--- a/sources/shiboken6/generator/generator.h
+++ b/sources/shiboken6/generator/generator.h
@@ -31,7 +31,6 @@
#include <abstractmetatype.h>
#include <typedatabase_typedefs.h>
-#include <dependency.h>
#include <QtCore/QObject>
#include <QtCore/QSharedPointer>
#include <QtCore/QTextStream>
@@ -270,12 +269,6 @@ public:
AbstractMetaFunctionCList implicitConversions(const AbstractMetaType &metaType) const;
protected:
- /// Returns the classes, topologically ordered, used to generate the binding code.
- ///
- /// The classes are ordered such that derived classes appear later in the list than
- /// their parent classes.
- AbstractMetaClassList classesTopologicalSorted(const Dependencies &additionalDependencies = Dependencies()) const;
-
/// Returns all global functions found by APIExtractor
const AbstractMetaFunctionCList &globalFunctions() const;
diff --git a/sources/shiboken6/generator/shiboken/cppgenerator.cpp b/sources/shiboken6/generator/shiboken/cppgenerator.cpp
index d522db846..766ef25d9 100644
--- a/sources/shiboken6/generator/shiboken/cppgenerator.cpp
+++ b/sources/shiboken6/generator/shiboken/cppgenerator.cpp
@@ -5929,21 +5929,7 @@ bool CppGenerator::finishGeneration()
writeMethodDefinition(s_globalFunctionDef, overloads);
}
- //this is a temporary solution before new type revison implementation
- //We need move QMetaObject register before QObject
- Dependencies additionalDependencies;
- const AbstractMetaClassList &allClasses = classes();
- if (auto qObjectClass = AbstractMetaClass::findClass(allClasses, qObjectT())) {
- if (auto qMetaObjectClass = AbstractMetaClass::findClass(allClasses, qMetaObjectT())) {
- Dependency dependency;
- dependency.parent = qMetaObjectClass;
- dependency.child = qObjectClass;
- additionalDependencies.append(dependency);
- }
- }
- const AbstractMetaClassList lst = classesTopologicalSorted(additionalDependencies);
-
- for (const AbstractMetaClass *cls : lst){
+ for (const AbstractMetaClass *cls : classes()){
if (shouldGenerate(cls)) {
writeInitFunc(s_classInitDecl, s_classPythonDefines,
getSimpleClassInitFunctionName(cls),