aboutsummaryrefslogtreecommitdiffstats
path: root/headergenerator.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'headergenerator.cpp')
-rw-r--r--headergenerator.cpp31
1 files changed, 20 insertions, 11 deletions
diff --git a/headergenerator.cpp b/headergenerator.cpp
index b31b92e61..9074726fd 100644
--- a/headergenerator.cpp
+++ b/headergenerator.cpp
@@ -59,9 +59,9 @@ void HeaderGenerator::generateClass(QTextStream& s, const AbstractMetaClass* met
s << "#ifndef SBK_" << wrapperName.toUpper() << "_H" << endl;
s << "#define SBK_" << wrapperName.toUpper() << "_H" << endl<< endl;
- if (shouldGenerateCppWrapper(metaClass)) {
- s << "#define protected public" << endl << endl;
- }
+#ifndef AVOID_PROTECTED_HACK
+ s << "#define protected public" << endl << endl;
+#endif
s << "#include <shiboken.h>" << endl << endl;
@@ -69,9 +69,6 @@ void HeaderGenerator::generateClass(QTextStream& s, const AbstractMetaClass* met
if (metaClass->typeEntry()->include().isValid())
s << metaClass->typeEntry()->include().toString() << endl << endl;
- writeCodeSnips(s, metaClass->typeEntry()->codeSnips(),
- CodeSnip::Declaration, TypeSystem::NativeCode);
-
if (shouldGenerateCppWrapper(metaClass)) {
// Class
s << "class " << wrapperName;
@@ -86,7 +83,9 @@ void HeaderGenerator::generateClass(QTextStream& s, const AbstractMetaClass* met
writeFunction(s, func);
//destructor
- s << INDENT << "~" << wrapperName << "();" << endl;
+ s << INDENT << (metaClass->hasVirtualDestructor() ? "virtual " : "") << "~" << wrapperName << "();" << endl;
+
+ writeCodeSnips(s, metaClass->typeEntry()->codeSnips(), CodeSnip::Declaration, TypeSystem::NativeCode);
if (metaClass->isQObject() && (metaClass->name() != "QObject"))
s << INDENT << "using QObject::parent;" << endl;
@@ -99,14 +98,24 @@ void HeaderGenerator::generateClass(QTextStream& s, const AbstractMetaClass* met
void HeaderGenerator::writeFunction(QTextStream& s, const AbstractMetaFunction* func) const
{
- // pure virtual functions need a default implementation
- if (func->isPrivate() || (func->isModifiedRemoved() && !func->isAbstract()))
- return;
-
// do not write copy ctors here.
if (func->isCopyConstructor())
return;
+#ifdef AVOID_PROTECTED_HACK
+ if (func->isProtected() && !func->isConstructor()) {
+ s << INDENT << "inline " << (func->isStatic() ? "static " : "");
+ s << functionSignature(func, "", "_protected") << " { ";
+ s << (func->type() ? "return " : "") << func->ownerClass()->qualifiedCppName() << "::";
+ writeFunctionCall(s, func);
+ s << "; }" << endl;
+ }
+#endif
+
+ // pure virtual functions need a default implementation
+ if (func->isPrivate() || (func->isModifiedRemoved() && !func->isAbstract()))
+ return;
+
if (func->isConstructor() || func->isAbstract() || func->isVirtual()) {
s << INDENT;
if (func->isVirtual() || func->isAbstract())