aboutsummaryrefslogtreecommitdiffstats
path: root/generator
diff options
context:
space:
mode:
authorrenatofilho <renato.filho@openbossa.org>2010-11-04 17:37:48 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-08 16:08:55 -0300
commit73576ee9b01f88a92c05f48da3189532fbdfb578 (patch)
treedb0b83b121dd9331694504d0673b0501216697bf /generator
parent00d2d31691fe6c9274acfd82382b3f5e8c47db96 (diff)
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')
-rw-r--r--generator/cppgenerator.cpp28
1 files changed, 22 insertions, 6 deletions
diff --git a/generator/cppgenerator.cpp b/generator/cppgenerator.cpp
index a44b79c38..0a1cd3155 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 << ")";
+ }
}
}