summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHugo Lima <hugo.lima@openbossa.org>2009-11-16 11:31:21 -0200
committerMarcelo Lira <marcelo.lira@openbossa.org>2009-11-16 17:26:04 -0300
commit38083ce45cdd4e67b7e59070605c957973ecc250 (patch)
tree1e57f2534688ad8cce96a1651a93f5dc2f31d3f0
parentd2b0d52b53d31ca4b026a1982bb322fcb58a73cd (diff)
downloadshiboken-38083ce45cdd4e67b7e59070605c957973ecc250.tar.gz
shiboken-38083ce45cdd4e67b7e59070605c957973ecc250.tar.xz
shiboken-38083ce45cdd4e67b7e59070605c957973ecc250.zip
OverloadData does not ignore arguments which modify types.
-rw-r--r--cppgenerator.cpp4
-rw-r--r--overloaddata.cpp31
-rw-r--r--overloaddata.h5
3 files changed, 35 insertions, 5 deletions
diff --git a/cppgenerator.cpp b/cppgenerator.cpp
index 6ff6dd4a..52b74517 100644
--- a/cppgenerator.cpp
+++ b/cppgenerator.cpp
@@ -700,7 +700,9 @@ void CppGenerator::writeTypeCheck(QTextStream& s, const OverloadData* overloadDa
if (isPairContainer)
s << '(';
- if (argType->typeEntry()->isFlags())
+ if (overloadData->hasArgumentTypeReplace()) {
+ s << overloadData->argumentTypeReplaced() << "_Check";
+ } else if (argType->typeEntry()->isFlags())
s << cpythonCheckFunction(((FlagsTypeEntry*) argType->typeEntry())->originator(), true);
else if (argType->isEnum())
s << cpythonCheckFunction(argType, false, true);
diff --git a/overloaddata.cpp b/overloaddata.cpp
index 84657654..70059245 100644
--- a/overloaddata.cpp
+++ b/overloaddata.cpp
@@ -154,10 +154,15 @@ OverloadData* OverloadData::addOverloadData(const AbstractMetaFunction* func,
if (!func->isOperatorOverload()) {
foreach (OverloadData* tmp, m_nextOverloadData) {
// TODO: 'const char *', 'char *' and 'char' will have the same TypeEntry?
- if (tmp->m_argType->typeEntry() == argType->typeEntry()) {
+
+ // If an argument have a type replacement, then we should create a new overloaddata
+ // for it, unless the next argument also have a identical type replacement.
+ QString replacedArg = func->typeReplaced(tmp->m_argPos + 1);
+ bool argsReplaced = !replacedArg.isEmpty() || !tmp->m_argTypeReplaced.isEmpty();
+ if ((!argsReplaced && tmp->m_argType->typeEntry() == argType->typeEntry())
+ || (argsReplaced && replacedArg == tmp->argumentTypeReplaced())) {
tmp->addOverload(func);
overloadData = tmp;
- continue;
}
}
}
@@ -165,6 +170,10 @@ OverloadData* OverloadData::addOverloadData(const AbstractMetaFunction* func,
if (!overloadData) {
overloadData = new OverloadData(m_headOverloadData, func, argType, m_argPos + 1);
overloadData->m_generator = this->m_generator;
+ QString typeReplaced = func->typeReplaced(overloadData->m_argPos + 1);
+
+ if (!typeReplaced.isEmpty())
+ overloadData->m_argTypeReplaced = typeReplaced;
m_nextOverloadData.append(overloadData);
}
@@ -414,8 +423,13 @@ QString OverloadData::dumpGraph() const
s << "<font color=\"white\" point-size=\"11\">arg #" << argPos() << "</font></td></tr>";
// Argument type information
+ QString type = hasArgumentTypeReplace() ? argumentTypeReplaced() : argType()->cppSignature();
s << "<tr><td bgcolor=\"gray\" align=\"right\">type</td><td bgcolor=\"gray\" align=\"left\">";
- s << argType()->cppSignature().replace("&", "&amp;") << "</td></tr>";
+ s << type.replace("&", "&amp;") << "</td></tr>";
+ if (hasArgumentTypeReplace()) {
+ s << "<tr><td bgcolor=\"gray\" align=\"right\">orig. type</td><td bgcolor=\"gray\" align=\"left\">";
+ s << argType()->cppSignature().replace("&", "&amp;") << "</td></tr>";
+ }
// Overloads for the signature to present point
s << "<tr><td bgcolor=\"gray\" align=\"right\">overloads</td><td bgcolor=\"gray\" align=\"left\">";
@@ -459,3 +473,14 @@ OverloadData::~OverloadData()
while (!m_nextOverloadData.isEmpty())
delete m_nextOverloadData.takeLast();
}
+
+bool OverloadData::hasArgumentTypeReplace() const
+{
+ return !m_argTypeReplaced.isEmpty();
+}
+
+QString OverloadData::argumentTypeReplaced() const
+{
+ return m_argTypeReplaced;
+}
+
diff --git a/overloaddata.h b/overloaddata.h
index 373dba25..9d720dba 100644
--- a/overloaddata.h
+++ b/overloaddata.h
@@ -37,6 +37,7 @@ class OverloadData
{
public:
OverloadData(const AbstractMetaFunctionList overloads, const ShibokenGenerator* generator);
+ ~OverloadData();
int minArgs() const { return m_headOverloadData->m_minArgs; }
int maxArgs() const { return m_headOverloadData->m_maxArgs; }
@@ -65,7 +66,8 @@ public:
void dumpGraph(QString filename) const;
QString dumpGraph() const;
- ~OverloadData();
+ bool hasArgumentTypeReplace() const;
+ QString argumentTypeReplaced() const;
private:
OverloadData(OverloadData* headOverloadData, const AbstractMetaFunction* func,
@@ -83,6 +85,7 @@ private:
int m_maxArgs;
int m_argPos;
const AbstractMetaType* m_argType;
+ QString m_argTypeReplaced;
QList<const AbstractMetaFunction*> m_overloads;
OverloadData* m_headOverloadData;