From 7426212cb22dedd45d78a08676ee4ee07340e41e Mon Sep 17 00:00:00 2001 From: Marcelo Lira Date: Tue, 9 Nov 2010 10:08:48 -0300 Subject: Fixed overload decisor sorting to put QStrings after pointers to wrapped objects. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed by Renato Araújo --- generator/overloaddata.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'generator') 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) { -- cgit v1.2.3