summaryrefslogtreecommitdiffstats
path: root/generator/headergenerator.cpp
diff options
context:
space:
mode:
authorHugo Parente Lima <hugo.pl@gmail.com>2011-01-17 14:52:44 -0200
committerHugo Parente Lima <hugo.pl@gmail.com>2011-02-01 17:28:07 -0200
commit81b6d4a6489e8b958418c7db3cccc2b480571af6 (patch)
tree199d8ccbcde89f1852545d5da33b8d3b27768453 /generator/headergenerator.cpp
parent5132ceaac226b604ba02d335fa10d95a0bda6d5b (diff)
downloadshiboken-81b6d4a6489e8b958418c7db3cccc2b480571af6.tar.gz
shiboken-81b6d4a6489e8b958418c7db3cccc2b480571af6.tar.xz
shiboken-81b6d4a6489e8b958418c7db3cccc2b480571af6.zip
Fix bug 616 - "error compiling when public and private methods differ by the const-ness"
Reviewer: Marcelo Lira <marcelo.lira@openbossa.org> Renato Ara├║jo <renato.filho@openbossa.org>
Diffstat (limited to 'generator/headergenerator.cpp')
-rw-r--r--generator/headergenerator.cpp46
1 files changed, 45 insertions, 1 deletions
diff --git a/generator/headergenerator.cpp b/generator/headergenerator.cpp
index bb8f341a..b7e2bbdc 100644
--- a/generator/headergenerator.cpp
+++ b/generator/headergenerator.cpp
@@ -73,6 +73,7 @@ void HeaderGenerator::writeProtectedFieldAccessors(QTextStream& s, const Abstrac
void HeaderGenerator::generateClass(QTextStream& s, const AbstractMetaClass* metaClass)
{
ReportHandler::debugSparse("Generating header for " + metaClass->fullName());
+ m_inheritedOverloads.clear();
Indentation indent(INDENT);
// write license comment
@@ -143,13 +144,18 @@ void HeaderGenerator::generateClass(QTextStream& s, const AbstractMetaClass* met
}
#endif
+ if (m_inheritedOverloads.size()) {
+ s << INDENT << "// Inherited overloads, because the using keyword sux" << endl;
+ writeInheritedOverloads(s);
+ }
+
s << "};" << endl << endl;
}
s << "#endif // SBK_" << headerGuard << "_H" << endl << endl;
}
-void HeaderGenerator::writeFunction(QTextStream& s, const AbstractMetaFunction* func) const
+void HeaderGenerator::writeFunction(QTextStream& s, const AbstractMetaFunction* func)
{
// do not write copy ctors here.
@@ -206,6 +212,20 @@ void HeaderGenerator::writeFunction(QTextStream& s, const AbstractMetaFunction*
s << functionSignature(func, "", "", virtualOption) << ';' << endl;
+ // Check if this method hide other methods in base classes
+ foreach (const AbstractMetaFunction* f, func->ownerClass()->functions()) {
+ if (f != func
+ && !f->isConstructor()
+ && !f->isPrivate()
+ && !f->isVirtual()
+ && !f->isAbstract()
+ && !f->isStatic()
+ && f->name() == func->name()) {
+ m_inheritedOverloads << f;
+ break;
+ }
+ }
+
// TODO: when modified an abstract method ceases to be virtual but stays abstract
//if (func->isModifiedRemoved() && func->isAbstract()) {
//}
@@ -621,3 +641,27 @@ void HeaderGenerator::writeTypeConverterImpl(QTextStream& s, const TypeEntry* ty
s << '}' << endl << endl;
}
+void HeaderGenerator::writeInheritedOverloads(QTextStream& s)
+{
+ foreach (const AbstractMetaFunction* func, m_inheritedOverloads) {
+ s << INDENT << "inline ";
+ s << functionSignature(func, "", "", Generator::EnumAsInts|Generator::OriginalTypeDescription) << " { ";
+ s << (func->type() ? "return " : "");
+ s << func->ownerClass()->qualifiedCppName() << "::" << func->originalName() << '(';
+ QStringList args;
+ foreach (const AbstractMetaArgument* arg, func->arguments()) {
+ QString argName = arg->name();
+ const TypeEntry* enumTypeEntry = 0;
+ if (arg->type()->isFlags())
+ enumTypeEntry = reinterpret_cast<const FlagsTypeEntry*>(arg->type()->typeEntry())->originator();
+ else if (arg->type()->isEnum())
+ enumTypeEntry = arg->type()->typeEntry();
+ if (enumTypeEntry)
+ argName = QString("%1(%2)").arg(arg->type()->cppSignature()).arg(argName);
+ args << argName;
+ }
+ s << args.join(", ") << ')';
+ s << "; }" << endl;
+ }
+}
+