aboutsummaryrefslogtreecommitdiffstats
path: root/generator
diff options
context:
space:
mode:
authorMarcelo Lira <marcelo.lira@openbossa.org>2010-11-09 10:08:48 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-08 16:08:55 -0300
commit7426212cb22dedd45d78a08676ee4ee07340e41e (patch)
tree04a9d8383019f139820a9c26be9a9e53980994bd /generator
parentf847631ef08c1ea6ed80857b78e0d8fa51e4eb2b (diff)
Fixed overload decisor sorting to put QStrings after pointers to wrapped objects.
This is a special extension for Qt bindings. Since QStrings accept None values the same way object and value types accept, to avoid confusion and calling the wrong signature QString must go after object and value pointers. This wasn't a problem before, but now QString is a primitive-type and the decisor has no access to its implicit conversions, and thus can't sort it properly. Reviewed by Luciano Wolf <luciano.wolf@openbossa.org> Reviewed by Renato Araújo <renato.filho@openbossa.org>
Diffstat (limited to 'generator')
-rw-r--r--generator/overloaddata.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/generator/overloaddata.cpp b/generator/overloaddata.cpp
index 9be972f1f..031c06848 100644
--- a/generator/overloaddata.cpp
+++ b/generator/overloaddata.cpp
@@ -147,6 +147,9 @@ void OverloadData::sortNextOverloads()
OverloadSortData sortData;
bool checkPyObject = false;
int pyobjectIndex = 0;
+ bool checkQString = false;
+ bool hasObjectPointer = false;
+ int qstringIndex = 0;
// Primitive types that are not int, long, short,
// char and their respective unsigned counterparts.
@@ -172,6 +175,15 @@ void OverloadData::sortNextOverloads()
if (!checkPyObject && getTypeName(ov->argType()).contains("PyObject")) {
checkPyObject = true;
pyobjectIndex = sortData.lastProcessedItemId();
+ } else if (!checkQString && getTypeName(ov->argType()) == "QString") {
+ checkQString = true;
+ qstringIndex = sortData.lastProcessedItemId();
+ if (referenceFunction()->name() == "QListWidgetItem")
+ qDebug() << ov->argType()->minimalSignature() << " checkQString: " << checkQString;
+ } else if (!hasObjectPointer && (ov->argType()->isValuePointer() || ov->argType()->typeEntry()->isObject() )) {
+ hasObjectPointer = true;
+ if (referenceFunction()->name() == "QListWidgetItem")
+ qDebug() << ov->argType()->minimalSignature() << " hasObjectPointer: " << hasObjectPointer;
}
foreach (const AbstractMetaType* instantiation, ov->argType()->instantiations()) {
@@ -267,6 +279,8 @@ void OverloadData::sortNextOverloads()
/* Add dependency on PyObject, so its check is the last one (too generic) */
if (checkPyObject && !targetTypeEntryName.contains("PyObject"))
graph.addEdge(sortData.map[targetTypeEntryName], pyobjectIndex);
+ else if (checkQString && hasObjectPointer && targetTypeEntryName != "QString")
+ graph.addEdge(sortData.map[targetTypeEntryName], qstringIndex);
if (targetTypeEntry->isEnum()) {
for (int i = 0; i < numPrimitives; ++i) {