aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken2/generator/generator.cpp
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2019-03-27 14:05:12 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2019-04-02 14:14:09 +0000
commit66f466b6c80dc3bc016c7e8f98898805ab2d149e (patch)
tree04e986984afc2f3a2888f90eb93ddf9c213564c7 /sources/shiboken2/generator/generator.cpp
parentca7a5a9c3a40cc7c432ef1d9d4713fe1169a92b2 (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>
Diffstat (limited to 'sources/shiboken2/generator/generator.cpp')
-rw-r--r--sources/shiboken2/generator/generator.cpp22
1 files changed, 12 insertions, 10 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>