summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHugo Lima <hugo.lima@openbossa.org>2010-03-03 15:10:06 -0300
committerHugo Lima <hugo.lima@openbossa.org>2010-03-18 19:45:06 -0300
commit7dc3fd531da613df2ffee3ae152c316021bb0e2a (patch)
tree99a362aa19be5205f09fdca0ed23fa130199992e
parent10872ead263959d103eea17507f6ccd16757e8b6 (diff)
downloadshiboken-7dc3fd531da613df2ffee3ae152c316021bb0e2a.tar.gz
shiboken-7dc3fd531da613df2ffee3ae152c316021bb0e2a.tar.xz
shiboken-7dc3fd531da613df2ffee3ae152c316021bb0e2a.zip
Remove boost::graph dependency from Shiboken generator.
-rw-r--r--CMakeLists.txt4
-rw-r--r--overloaddata.cpp46
2 files changed, 27 insertions, 23 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 600d21f2..b4ad6768 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -6,7 +6,6 @@ cmake_minimum_required(VERSION 2.6)
find_package(Qt4 4.5.0 REQUIRED)
find_package(ApiExtractor REQUIRED)
find_package(GeneratorRunner REQUIRED)
-find_package(Boost COMPONENTS graph REQUIRED)
add_definitions(${QT_DEFINITIONS})
@@ -50,8 +49,7 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}
${APIEXTRACTOR_INCLUDE_DIR}
${GENERATORRUNNER_INCLUDE_DIR}
${QT_INCLUDE_DIR}
- ${QT_QTCORE_INCLUDE_DIR}
- ${Boost_INCLUDE_DIR})
+ ${QT_QTCORE_INCLUDE_DIR})
add_library(shiboken_generator SHARED ${shiboken_SRC})
diff --git a/overloaddata.cpp b/overloaddata.cpp
index fe7b643c..11a2b6ea 100644
--- a/overloaddata.cpp
+++ b/overloaddata.cpp
@@ -22,13 +22,11 @@
*/
#include <QtCore/QFile>
+#include <reporthandler.h>
+#include <graph.h>
#include "overloaddata.h"
#include "shibokengenerator.h"
-#include <boost/graph/topological_sort.hpp>
-#include <boost/graph/adjacency_list.hpp>
-#include <boost/graph/graph_traits.hpp>
-
/**
* Topologically sort the overloads by implicit convertion order
*
@@ -69,7 +67,8 @@ void OverloadData::sortNextOverloads()
}
// Create the graph of type dependencies based on implicity conversions.
- QSet<QPair<int, int> > deps;
+ Graph graph(reverseMap.count());
+
foreach(OverloadData* ov, m_nextOverloadData) {
const AbstractMetaType* targetType = ov->argType();
foreach(AbstractMetaFunction* function, m_generator->implicitConversions(ov->argType())) {
@@ -87,11 +86,8 @@ void OverloadData::sortNextOverloads()
// If a reverse pair already exists, remove it. Probably due to the
// container check (This happened to QVariant and QHash)
- QPair<int, int> reversePair = qMakePair(convertibleTypeId, targetTypeId);
- if (deps.contains(reversePair))
- deps.remove(reversePair);
-
- deps << qMakePair(targetTypeId, convertibleTypeId);
+ graph.removeEdge(targetTypeId, convertibleTypeId);
+ graph.addEdge(convertibleTypeId, targetTypeId);
}
if (targetType->hasInstantiations()) {
@@ -100,32 +96,42 @@ void OverloadData::sortNextOverloads()
int target = map[targetType->typeEntry()->name()];
int convertible = map[instantiation->typeEntry()->name()];
- if (!deps.contains(qMakePair(convertible, target))) // Avoid cyclic dependency.
- deps << qMakePair(target, convertible);
+ if (!graph.containsEdge(target, convertible)) // Avoid cyclic dependency.
+ graph.addEdge(convertible, target);
}
}
}
/* Add dependency on PyObject, so its check is the last one (too generic) */
if (checkPyObject && !targetType->typeEntry()->name().contains("PyObject")) {
- deps << qMakePair(pyobjectIndex,
- map[targetType->typeEntry()->name()]);
+ graph.addEdge(map[targetType->typeEntry()->name()], pyobjectIndex);
}
}
// Special case for double(int i) (not tracked by m_generator->implicitConversions
if (map.contains("int")) {
+ if (map.contains("float"))
+ graph.addEdge(map["float"], map["int"]);
+ if (map.contains("double"))
+ graph.addEdge(map["double"], map["int"]);
+ if (map.contains("bool"))
+ graph.addEdge(map["bool"], map["int"]);
+ }
+
+ if (map.contains("long")) {
+ if (map.contains("float"))
+ graph.addEdge(map["float"], map["long"]);
if (map.contains("double"))
- deps << qMakePair(map["int"], map["double"]);
+ graph.addEdge(map["double"], map["long"]);
if (map.contains("bool"))
- deps << qMakePair(map["int"], map["bool"]);
+ graph.addEdge(map["bool"], map["long"]);
}
// sort the overloads topologicaly based on the deps graph.
- typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::directedS> Graph;
- Graph g(deps.begin(), deps.end(), reverseMap.size());
- QList<int> unmappedResult;
- boost::topological_sort(g, std::back_inserter(unmappedResult));
+
+ QLinkedList<int> unmappedResult = graph.topologicalSort();
+ if (unmappedResult.isEmpty())
+ ReportHandler::warning("Cyclic dependency found on overloaddata!");
m_nextOverloadData.clear();
foreach(int i, unmappedResult)