summaryrefslogtreecommitdiffstats
path: root/typedatabase.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'typedatabase.cpp')
-rw-r--r--typedatabase.cpp60
1 files changed, 17 insertions, 43 deletions
diff --git a/typedatabase.cpp b/typedatabase.cpp
index 2593350..d5c1eb6 100644
--- a/typedatabase.cpp
+++ b/typedatabase.cpp
@@ -430,12 +430,8 @@ void TypeDatabase::setDropTypeEntries(QStringList dropTypeEntries)
// This global variable exists only because we can't break the ABI
typedef QHash<const TypeEntry*, std::pair<int, int> > TypeRevisionMap;
Q_GLOBAL_STATIC(TypeRevisionMap, typeEntryFields);
-// Hash of: packageName -> (max type index found, max primitive type index found)
-typedef QMap<QString, QPair<int, int> > MaxTypeIndexes;
-Q_GLOBAL_STATIC(MaxTypeIndexes, maxTypeIndexes);
static bool computeTypeIndexes = true;
-// This is kept for API compatibility issues with previous versions
-int oldMaxTypeIndex;
+static int maxTypeIndex;
int getTypeRevision(const TypeEntry* typeEntry)
{
@@ -457,51 +453,39 @@ static void _computeTypeIndexes()
{
TypeDatabase* tdb = TypeDatabase::instance();
typedef QMap<int, QList<TypeEntry*> > GroupedTypeEntries;
- typedef QHash<QString, GroupedTypeEntries> GroupedPerPackageGroups;
- GroupedPerPackageGroups groupsPerPackage;
+ GroupedTypeEntries groupedEntries;
// Group type entries by revision numbers
TypeEntryHash allEntries = tdb->allEntries();
- QString pkgName;
- oldMaxTypeIndex = 0;
foreach (QList<TypeEntry*> entryList, allEntries) {
foreach (TypeEntry* entry, entryList) {
- if (entry->isCppPrimitive()
+ if (entry->isPrimitive()
|| entry->isContainer()
|| entry->isFunction()
+ || !entry->generateCode()
|| entry->isEnumValue()
|| entry->isVarargs()
|| entry->isTypeSystem()
|| entry->isVoid()
|| entry->isCustom())
continue;
-
- if (entry->generateCode() && !entry->isPrimitive())
- oldMaxTypeIndex++;
- pkgName = entry->targetLangPackage();
- groupsPerPackage[pkgName][getTypeRevision(entry)] << entry;
+ groupedEntries[getTypeRevision(entry)] << entry;
}
}
-
- GroupedPerPackageGroups::iterator pkg = groupsPerPackage.begin();
- for (; pkg != groupsPerPackage.end() ; ++pkg) {
- GroupedTypeEntries::iterator it = pkg.value().begin();
- for (; it != pkg.value().end(); ++it) {
- // Remove duplicates
- QList<TypeEntry*>::iterator newEnd = std::unique(it.value().begin(), it.value().end());
- it.value().erase(newEnd, it.value().end());
- // Sort the type entries by name
- qSort(it.value().begin(), newEnd, compareTypeEntriesByName);
-
- foreach (TypeEntry* entry, it.value()) {
- QPair<int, int>& pair = (*maxTypeIndexes())[pkg.key()];
- int value = entry->isPrimitive() ? pair.second++ : pair.first++;
- (*typeEntryFields())[entry].second = value;
- }
+ maxTypeIndex = 0;
+ GroupedTypeEntries::iterator it = groupedEntries.begin();
+ for (; it != groupedEntries.end(); ++it) {
+ // Remove duplicates
+ QList<TypeEntry*>::iterator newEnd = std::unique(it.value().begin(), it.value().end());
+ it.value().erase(newEnd, it.value().end());
+ // Sort the type entries by name
+ qSort(it.value().begin(), newEnd, compareTypeEntriesByName);
+
+ foreach (TypeEntry* entry, it.value()) {
+ (*typeEntryFields())[entry].second = maxTypeIndex++;
}
}
-
computeTypeIndexes = false;
}
@@ -516,17 +500,7 @@ int getMaxTypeIndex()
{
if (computeTypeIndexes)
_computeTypeIndexes();
- return oldMaxTypeIndex;
-}
-
-int getMaxTypeIndex(const QString& packageName)
-{
- return maxTypeIndexes()->value(packageName).first - 1;
-}
-
-int getMaxPrimitiveTypeIndex(const QString& packageName)
-{
- return maxTypeIndexes()->value(packageName).second - 1;
+ return maxTypeIndex;
}
void TypeDatabase::setApiVersion(const QString& package, const QByteArray& version)