aboutsummaryrefslogtreecommitdiffstats
path: root/generator
diff options
context:
space:
mode:
authorRenato Araujo Oliveira Filho <renato.filho@openbossa.org>2010-11-23 11:42:08 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-08 16:08:59 -0300
commitd17a105e2e71afd1f0b20576b73dcd95b5ca1806 (patch)
tree4bb1e469947cf248b3a6fb21684d6d3b8476dbbb /generator
parent73360b909285ebfd57a0d24b83c64232b4d05a95 (diff)
Fixed generation with AVOID_PROTECTED_HACK.
Fixes bug #476. Reviewer: Luciano Wolf <luciano.wolf@openbossa.org> Hugo Parente Lima <hugo.pl@gmail.com>
Diffstat (limited to 'generator')
-rw-r--r--generator/cppgenerator.cpp66
1 files changed, 42 insertions, 24 deletions
diff --git a/generator/cppgenerator.cpp b/generator/cppgenerator.cpp
index 284b20f81..b1f8d5733 100644
--- a/generator/cppgenerator.cpp
+++ b/generator/cppgenerator.cpp
@@ -2010,27 +2010,35 @@ void CppGenerator::writeMethodCall(QTextStream& s, const AbstractMetaFunction* f
mc << ')';
} else {
if (func->ownerClass()) {
-#ifndef AVOID_PROTECTED_HACK
- if (func->isStatic())
- mc << func->ownerClass()->qualifiedCppName() << "::";
- else
- mc << CPP_SELF_VAR "->";
+#ifdef AVOID_PROTECTED_HACK
+ if (!func->isProtected()) {
+#endif
+ if (func->isStatic())
+ mc << func->ownerClass()->qualifiedCppName() << "::";
+ else {
+#ifdef AVOID_PROTECTED_HACK
+ if (!func->isVirtual() && func->ownerClass()->hasProtectedMembers())
+ mc << "((" << func->ownerClass()->qualifiedCppName() << "*)" << CPP_SELF_VAR << ")->";
+ else
+#endif
+ mc << CPP_SELF_VAR "->";
+ }
- if (!func->isAbstract() && func->isVirtual())
- mc << "::%CLASS_NAME::";
+ if (!func->isAbstract() && func->isVirtual())
+ mc << "::%CLASS_NAME::";
- mc << func->originalName();
-#else
- if (func->isStatic())
- mc << func->ownerClass()->qualifiedCppName() << "::";
- else {
- if (func->isProtected())
- mc << "((" << wrapperName(func->ownerClass()) << "*) ";
- mc << CPP_SELF_VAR << (func->isProtected() ? ")" : "") << "->";
+
+ mc << func->originalName();
+
+#ifdef AVOID_PROTECTED_HACK
+ } else {
+ if (!func->isStatic())
+ mc << "((" << wrapperName(func->ownerClass()) << "*) " << CPP_SELF_VAR << ")->";
+
+ if (!func->isAbstract())
+ mc << (func->isProtected() ? wrapperName(func->ownerClass()) : "::" + func->ownerClass()->qualifiedCppName()) << "::";
+ mc << func->originalName() << "_protected";
}
- if (!func->isAbstract() && func->isVirtual())
- mc << (func->isProtected() ? wrapperName(func->ownerClass()) : "::%CLASS_NAME::");
- mc << func->originalName() << (func->isProtected() ? "_protected" : "");
#endif
} else {
mc << func->originalName();
@@ -2038,13 +2046,19 @@ void CppGenerator::writeMethodCall(QTextStream& s, const AbstractMetaFunction* f
mc << '(' << userArgs.join(", ") << ')';
if (!func->isAbstract() && func->isVirtual()) {
mc.flush();
- QString virtualCall(methodCall);
- QString normalCall(methodCall);
+#ifndef AVOID_PROTECTED_HACK
+ if (!func->isProtected())
+#endif
+ {
+ QString virtualCall(methodCall);
+ QString normalCall(methodCall);
+
+ virtualCall = virtualCall.replace("%CLASS_NAME", func->ownerClass()->qualifiedCppName());
+ normalCall = normalCall.replace("::%CLASS_NAME::", "");
+ methodCall = "";
- virtualCall = virtualCall.replace("%CLASS_NAME", func->ownerClass()->qualifiedCppName());
- normalCall = normalCall.replace("::%CLASS_NAME::", "");
- methodCall = "";
- mc << "(Shiboken::Wrapper::isUserType(self) ? " << virtualCall << ":" << normalCall << ")";
+ mc << "(Shiboken::Wrapper::isUserType(self) ? " << virtualCall << ":" << normalCall << ")";
+ }
}
}
}
@@ -3247,6 +3261,10 @@ void CppGenerator::writeClassRegister(QTextStream& s, const AbstractMetaClass* m
if (metaClass->hasProtectedDestructor())
dtorClassName = wrapperName(metaClass);
#endif
+ // call the real destructor
+ if (metaClass->typeEntry()->isValue())
+ dtorClassName = wrapperName(metaClass);
+
s << INDENT << "Shiboken::BaseType::setDestructorFunction(&" << cpythonTypeName(metaClass) << ", &Shiboken::callCppDestructor<" << dtorClassName << " >);" << endl;
}