From f60da508aa6e45232dbb1ae2831c4a45479d168e Mon Sep 17 00:00:00 2001 From: Hugo Parente Lima Date: Mon, 29 Aug 2011 18:22:00 -0300 Subject: Revert "Implement getTypeIndex function for types no generated types and primitive types." This commit broke the macosx build of PySide. This reverts commit e9758a01f15bc53de8e03b77ec8beb5673b1b1af. --- tests/CMakeLists.txt | 10 +++--- tests/testtypeindex.cpp | 87 ------------------------------------------------- tests/testtypeindex.h | 46 -------------------------- tests/typeindex.h | 7 ---- tests/typeindex_1.xml | 9 ----- tests/typeindex_2.xml | 12 ------- typedatabase.cpp | 60 ++++++++++------------------------ typedatabase.h | 4 +-- 8 files changed, 22 insertions(+), 213 deletions(-) delete mode 100644 tests/testtypeindex.cpp delete mode 100644 tests/testtypeindex.h delete mode 100644 tests/typeindex.h delete mode 100644 tests/typeindex_1.xml delete mode 100644 tests/typeindex_2.xml diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 75af51d..01c7deb 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -15,7 +15,8 @@ declare_test(testabstractmetatype) declare_test(testaddfunction) declare_test(testarrayargument) declare_test(testcodeinjection) -configure_file("${CMAKE_CURRENT_SOURCE_DIR}/utf8code.txt" "${CMAKE_CURRENT_BINARY_DIR}/utf8code.txt" COPYONLY) +configure_file("${CMAKE_CURRENT_SOURCE_DIR}/utf8code.txt" + "${CMAKE_CURRENT_BINARY_DIR}/utf8code.txt" COPYONLY) declare_test(testcontainer) declare_test(testconversionoperator) declare_test(testconversionruletag) @@ -40,16 +41,13 @@ declare_test(testremoveoperatormethod) declare_test(testresolvetype) declare_test(testreverseoperators) declare_test(testtemplates) -declare_test(testtypeindex) -configure_file("${CMAKE_CURRENT_SOURCE_DIR}/typeindex_1.xml" "${CMAKE_CURRENT_BINARY_DIR}/typeindex_1.xml" COPYONLY) -configure_file("${CMAKE_CURRENT_SOURCE_DIR}/typeindex_2.xml" "${CMAKE_CURRENT_BINARY_DIR}/typeindex_2.xml" COPYONLY) -configure_file("${CMAKE_CURRENT_SOURCE_DIR}/typeindex.h" "${CMAKE_CURRENT_BINARY_DIR}/typeindex.h" COPYONLY) declare_test(testtoposort) declare_test(testvaluetypedefaultctortag) declare_test(testvoidarg) declare_test(testtyperevision) if (NOT DISABLE_DOCSTRINGS) declare_test(testmodifydocumentation) - configure_file("${CMAKE_CURRENT_SOURCE_DIR}/a.xml" "${CMAKE_CURRENT_BINARY_DIR}/a.xml" COPYONLY) + configure_file("${CMAKE_CURRENT_SOURCE_DIR}/a.xml" + "${CMAKE_CURRENT_BINARY_DIR}/a.xml" COPYONLY) endif() diff --git a/tests/testtypeindex.cpp b/tests/testtypeindex.cpp deleted file mode 100644 index e6a7654..0000000 --- a/tests/testtypeindex.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/* -* This file is part of the API Extractor project. -* -* Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -* -* Contact: PySide team -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* version 2 as published by the Free Software Foundation. -* -* This program is distributed in the hope that it will be useful, but -* WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA -* 02110-1301 USA -* -*/ - -#include "testtypeindex.h" -#include "abstractmetabuilder.h" -#include -#include "testutil.h" -#include - -void TestTypeIndex::initTestCase() -{ - m_td = TypeDatabase::instance(true); - m_td->addTypesystemPath(QDir::currentPath()); - QVERIFY(m_td->parseFile("typeindex_1.xml")); - QFile cppCode("typeindex.h"); - bool res = m_builder.build(&cppCode); - QVERIFY(res); -} - -void TestTypeIndex::testTypeIndex_data() -{ - QTest::addColumn("typeName"); - QTest::addColumn("typeIndex"); - - QTest::newRow("unsigned int") << "unsigned int" << 0; - QTest::newRow("bool") << "bool" << 0; - QTest::newRow("P1") << "P1" << 0; - QTest::newRow("P2") << "P2" << 0; - QTest::newRow("P3") << "P3" << 1; - QTest::newRow("Pa4") << "Pa4" << 2; - QTest::newRow("Value1") << "Value1" << 0; - QTest::newRow("Value2") << "Value2" << 1; - QTest::newRow("P4") << "P4" << 0; - QTest::newRow("P5") << "P5" << 1; - QTest::newRow("Value3") << "Value3" << 0; - QTest::newRow("Value4") << "Value4" << 1; -} - -void TestTypeIndex::testTypeIndex() -{ - QFETCH(QString, typeName); - QFETCH(int, typeIndex); - - TypeEntry* type = m_td->findType(typeName); - QVERIFY(type); - - QCOMPARE(getTypeIndex(type), typeIndex); -} - -void TestTypeIndex::testMaxTypeIndex() -{ - QCOMPARE(getMaxPrimitiveTypeIndex("Foo"), 2); - QCOMPARE(getMaxTypeIndex("Foo"), 1); - QCOMPARE(getMaxPrimitiveTypeIndex("Bar"), 1); - QCOMPARE(getMaxTypeIndex("Bar"), 1); -} - -void TestTypeIndex::testDeprecatedFunction() -{ - // This returns max type index + 1, the new versions return the right value - QCOMPARE(getMaxTypeIndex(), 2); -} - -QTEST_APPLESS_MAIN(TestTypeIndex) - -#include "testtypeindex.moc" - diff --git a/tests/testtypeindex.h b/tests/testtypeindex.h deleted file mode 100644 index d0327e7..0000000 --- a/tests/testtypeindex.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -* This file is part of the API Extractor project. -* -* Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -* -* Contact: PySide team -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* version 2 as published by the Free Software Foundation. -* -* This program is distributed in the hope that it will be useful, but -* WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA -* 02110-1301 USA -* -*/ - -#ifndef TESTTYPEINDEX_H -#define TESTTYPEINDEX_H - -#include -#include "abstractmetabuilder.h" - -class TypeDatabase; -class TestTypeIndex : public QObject { -Q_OBJECT - -private slots: - void initTestCase(); - void testTypeIndex_data(); - void testTypeIndex(); - void testMaxTypeIndex(); - void testDeprecatedFunction(); - -private: - AbstractMetaBuilder m_builder; - TypeDatabase* m_td; -}; - -#endif diff --git a/tests/typeindex.h b/tests/typeindex.h deleted file mode 100644 index 6205dd8..0000000 --- a/tests/typeindex.h +++ /dev/null @@ -1,7 +0,0 @@ - -struct Value1 {}; -struct Value2 {}; -struct Value3 {}; -struct Value4 {}; - -typedef unsigned int P1; diff --git a/tests/typeindex_1.xml b/tests/typeindex_1.xml deleted file mode 100644 index 047987c..0000000 --- a/tests/typeindex_1.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/tests/typeindex_2.xml b/tests/typeindex_2.xml deleted file mode 100644 index f3fde0a..0000000 --- a/tests/typeindex_2.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - 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 > TypeRevisionMap; Q_GLOBAL_STATIC(TypeRevisionMap, typeEntryFields); -// Hash of: packageName -> (max type index found, max primitive type index found) -typedef QMap > 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 > GroupedTypeEntries; - typedef QHash GroupedPerPackageGroups; - GroupedPerPackageGroups groupsPerPackage; + GroupedTypeEntries groupedEntries; // Group type entries by revision numbers TypeEntryHash allEntries = tdb->allEntries(); - QString pkgName; - oldMaxTypeIndex = 0; foreach (QList 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::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& 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::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) diff --git a/typedatabase.h b/typedatabase.h index 229da08..8c735c1 100644 --- a/typedatabase.h +++ b/typedatabase.h @@ -30,9 +30,7 @@ APIEXTRACTOR_API void setTypeRevision(TypeEntry* typeEntry, int revision); APIEXTRACTOR_API int getTypeRevision(const TypeEntry* typeEntry); APIEXTRACTOR_API int getTypeIndex(const TypeEntry* typeEntry); -APIEXTRACTOR_API APIEXTRACTOR_DEPRECATED(int getMaxTypeIndex()); -APIEXTRACTOR_API int getMaxTypeIndex(const QString& packageName); -APIEXTRACTOR_API int getMaxPrimitiveTypeIndex(const QString& packageName); +APIEXTRACTOR_API int getMaxTypeIndex(); class ContainerTypeEntry; class PrimitiveTypeEntry; -- cgit v1.2.3