diff options
author | Lauro Neto <lauro.neto@openbossa.org> | 2010-02-05 18:02:51 -0300 |
---|---|---|
committer | Hugo Lima <hugo.lima@openbossa.org> | 2010-02-08 16:16:07 -0200 |
commit | cfd1c97717e8bdf05a0fa9aada851c7bcd4385b2 (patch) | |
tree | be46afc878c4df2bee457c7f1de8cc9dbf5d6a13 /overloaddata.cpp | |
parent | 7d4f470fd6babc417222133bec8e8b9b13737ce2 (diff) |
Fixing sort overload
Now sorting OverloadData recursively
Reviewer: Renato Filho <renato.filho@openbossa.org>
Diffstat (limited to 'overloaddata.cpp')
-rw-r--r-- | overloaddata.cpp | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/overloaddata.cpp b/overloaddata.cpp index 8b18b3456..4e9446a61 100644 --- a/overloaddata.cpp +++ b/overloaddata.cpp @@ -39,13 +39,21 @@ * * Side effects: Modifies m_nextOverloadData */ -void OverloadData::sortOverloads() +void OverloadData::sortNextOverloads() { QHash<QString, int> map; // type_name -> id QHash<int, OverloadData*> reverseMap; // id -> type_name bool checkPyObject = false; int pyobjectIndex = 0; + // sort the children overloads + foreach(OverloadData *ov, m_nextOverloadData) { + ov->sortNextOverloads(); + } + + if (m_nextOverloadData.size() <= 1) + return; + // Creates the map and reverseMap, to map type names to ids, these ids will be used by the topological // sort algorithm, because is easier and faster to work with boost::graph using ints. int i = 0; @@ -116,7 +124,23 @@ void OverloadData::sortOverloads() m_nextOverloadData << reverseMap[i]; } -// Prepare the information about overloaded methods signatures +/** + * Root constructor for OverloadData + * + * This constructor receives the list of overloads for a given function and iterates generating + * the graph of OverloadData instances. Each OverloadData instance references an argument/type + * combination. + * + * Example: + * addStuff(double, PyObject *) + * addStuff(double, int) + * + * Given these two overloads, there will be the following graph: + * + * addStuff - double - PyObject* + * \- int + * + */ OverloadData::OverloadData(const AbstractMetaFunctionList overloads, const ShibokenGenerator* generator) : m_minArgs(256), m_maxArgs(0), m_argPos(-1), m_argType(0), m_headOverloadData(this), m_generator(generator) @@ -139,8 +163,7 @@ OverloadData::OverloadData(const AbstractMetaFunctionList overloads, const Shibo // Sort the overload possibilities so that the overload decisor code goes for the most // important cases first, based on the topological order of the implicit conversions - if (m_nextOverloadData.size() > 1) - sortOverloads(); + sortNextOverloads(); // Fix minArgs if (minArgs() > maxArgs()) |