diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2019-03-27 14:05:12 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2019-04-02 14:14:09 +0000 |
commit | 66f466b6c80dc3bc016c7e8f98898805ab2d149e (patch) | |
tree | 04e986984afc2f3a2888f90eb93ddf9c213564c7 | |
parent | ca7a5a9c3a40cc7c432ef1d9d4713fe1169a92b2 (diff) |
shiboken: Further refactorings related to the package name
Let Generator::packageName() return the default package name of the
type data base instead of storing it in a member variable. Instead,
use a member variable for the module name which is derived from it,
since it is queried many times.
Use the default type system entry instead of searching for it
via package name.
Change-Id: I171330b3d73d2e3ceac239e4c1c6f130e9f5ee7b
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
-rw-r--r-- | sources/shiboken2/generator/generator.cpp | 22 | ||||
-rw-r--r-- | sources/shiboken2/generator/shiboken2/cppgenerator.cpp | 2 | ||||
-rw-r--r-- | sources/shiboken2/generator/shiboken2/shibokengenerator.cpp | 3 |
3 files changed, 14 insertions, 13 deletions
diff --git a/sources/shiboken2/generator/generator.cpp b/sources/shiboken2/generator/generator.cpp index 154a16ed3..91e940f51 100644 --- a/sources/shiboken2/generator/generator.cpp +++ b/sources/shiboken2/generator/generator.cpp @@ -156,7 +156,7 @@ struct Generator::GeneratorPrivate QString outDir; // License comment QString licenseComment; - QString packageName; + QString moduleName; QStringList instantiatedContainersNames; QStringList instantiatedSmartPointerNames; QVector<const AbstractMetaType *> instantiatedContainers; @@ -182,8 +182,6 @@ bool Generator::setup(const ApiExtractor& extractor) return false; } - m_d->packageName = moduleEntry->name(); - collectInstantiatedContainersAndSmartPointers(); return doSetup(); @@ -356,13 +354,16 @@ void Generator::setLicenseComment(const QString& licenseComment) QString Generator::packageName() const { - return m_d->packageName; + return TypeDatabase::instance()->defaultPackageName(); } QString Generator::moduleName() const { - QString& pkgName = m_d->packageName; - return QString(pkgName).remove(0, pkgName.lastIndexOf(QLatin1Char('.')) + 1); + if (m_d->moduleName.isEmpty()) { + m_d->moduleName = packageName(); + m_d->moduleName.remove(0, m_d->moduleName.lastIndexOf(QLatin1Char('.')) + 1); + } + return m_d->moduleName; } QString Generator::outputDirectory() const @@ -859,11 +860,12 @@ QString Generator::subDirectoryForClass(const AbstractMetaClass* clazz) const return subDirectoryForPackage(clazz->package()); } -QString Generator::subDirectoryForPackage(QString packageName) const +QString Generator::subDirectoryForPackage(QString packageNameIn) const { - if (packageName.isEmpty()) - packageName = m_d->packageName; - return QString(packageName).replace(QLatin1Char('.'), QDir::separator()); + if (packageNameIn.isEmpty()) + packageNameIn = packageName(); + packageNameIn.replace(QLatin1Char('.'), QDir::separator()); + return packageNameIn; } template<typename T> diff --git a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp index 039a2928b..2fedf9ae1 100644 --- a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp +++ b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp @@ -5508,7 +5508,7 @@ bool CppGenerator::finishGeneration() } TypeDatabase* typeDb = TypeDatabase::instance(); - const TypeSystemTypeEntry *moduleEntry = typeDb->findTypeSystemType(packageName()); + const TypeSystemTypeEntry *moduleEntry = typeDb->defaultTypeSystemType(); Q_ASSERT(moduleEntry); //Extra includes diff --git a/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp b/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp index c572a98d9..b5069db14 100644 --- a/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp +++ b/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp @@ -2489,7 +2489,6 @@ static void getCode(QStringList& code, const TypeEntry* type) bool ShibokenGenerator::doSetup() { - TypeDatabase* td = TypeDatabase::instance(); QStringList snips; const PrimitiveTypeEntryList &primitiveTypeList = primitiveTypes(); for (const PrimitiveTypeEntry *type : primitiveTypeList) @@ -2501,7 +2500,7 @@ bool ShibokenGenerator::doSetup() for (const AbstractMetaClass *metaClass : classList) getCode(snips, metaClass->typeEntry()); - const TypeSystemTypeEntry *moduleEntry = td->findTypeSystemType(packageName()); + const TypeSystemTypeEntry *moduleEntry = TypeDatabase::instance()->defaultTypeSystemType(); Q_ASSERT(moduleEntry); getCode(snips, moduleEntry); |