summaryrefslogtreecommitdiffstats
path: root/generator/cppgenerator.cpp
diff options
context:
space:
mode:
authorrenatofilho <renato.filho@openbossa.org>2010-11-04 17:37:48 -0300
committerrenatofilho <renato.filho@openbossa.org>2010-11-04 17:38:23 -0300
commita97ff930b29f6c4d51fdda0f448d172ceb83654e (patch)
tree1d31cf81263fbd7de7246e0e6ac440662682b9cb /generator/cppgenerator.cpp
parentd77d0948463d31be329c67a4320ab1354219283a (diff)
downloadshiboken-a97ff930b29f6c4d51fdda0f448d172ceb83654e.tar.gz
shiboken-a97ff930b29f6c4d51fdda0f448d172ceb83654e.tar.xz
shiboken-a97ff930b29f6c4d51fdda0f448d172ceb83654e.zip
Fixed code generation for functions virtual with know type
implementation. Fixes bug #449. Reviewer: Luciano Wolf <luciano.wolf@openbossa.org> Hugo Parente Lima <hugo.pl@gmail.com>
Diffstat (limited to 'generator/cppgenerator.cpp')
-rw-r--r--generator/cppgenerator.cpp28
1 files changed, 22 insertions, 6 deletions
diff --git a/generator/cppgenerator.cpp b/generator/cppgenerator.cpp
index a44b79c3..0a1cd315 100644
--- a/generator/cppgenerator.cpp
+++ b/generator/cppgenerator.cpp
@@ -2005,25 +2005,41 @@ void CppGenerator::writeMethodCall(QTextStream& s, const AbstractMetaFunction* f
} else {
if (func->ownerClass()) {
#ifndef AVOID_PROTECTED_HACK
- if (!func->isStatic())
+ if (func->isStatic())
+ mc << func->ownerClass()->qualifiedCppName() << "::";
+ else
mc << CPP_SELF_VAR "->";
- if (!func->isAbstract())
- mc << "::" << func->ownerClass()->qualifiedCppName() << "::";
+
+ if (!func->isAbstract() && func->isVirtual())
+ mc << "::%CLASS_NAME::";
+
mc << func->originalName();
#else
- if (!func->isStatic()) {
+ if (func->isStatic())
+ mc << func->ownerClass()->qualifiedCppName() << "::";
+ else {
if (func->isProtected())
mc << "((" << wrapperName(func->ownerClass()) << "*) ";
mc << CPP_SELF_VAR << (func->isProtected() ? ")" : "") << "->";
}
- if (!func->isAbstract())
- mc << (func->isProtected() ? wrapperName(func->ownerClass()) : "::" + func->ownerClass()->qualifiedCppName()) << "::";
+ if (!func->isAbstract() && func->isVirtual())
+ mc << (func->isProtected() ? wrapperName(func->ownerClass()) : "::%CLASS_NAME::");
mc << func->originalName() << (func->isProtected() ? "_protected" : "");
#endif
} else {
mc << func->originalName();
}
mc << '(' << userArgs.join(", ") << ')';
+ if (!func->isAbstract() && func->isVirtual()) {
+ mc.flush();
+ QString virtualCall(methodCall);
+ QString normalCall(methodCall);
+
+ virtualCall = virtualCall.replace("%CLASS_NAME", func->ownerClass()->qualifiedCppName());
+ normalCall = normalCall.replace("::%CLASS_NAME::", "");
+ methodCall = "";
+ mc << "(Shiboken::isUserType(self) ? " << virtualCall << ":" << normalCall << ")";
+ }
}
}