diff options
author | Marcelo Lira <marcelo.lira@openbossa.org> | 2010-02-24 14:00:49 -0300 |
---|---|---|
committer | Marcelo Lira <marcelo.lira@openbossa.org> | 2010-02-24 15:41:51 -0300 |
commit | 828ed8e7fc3fa0a3184ddd884e8622a0e5bde080 (patch) | |
tree | 3c15932c669dc89fb3f325af87e54140973793ed /cppgenerator.cpp | |
parent | d84917a9b4c302c0eea4ee011f23ab8ed5bb1022 (diff) |
The special cast function can now cast a pointer to all ancestor classes.
It also stopped using specific "cptr" cast macros, for these are to be
abandoned since they're considered harmful to multiple inheritance
casting.
Diffstat (limited to 'cppgenerator.cpp')
-rw-r--r-- | cppgenerator.cpp | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/cppgenerator.cpp b/cppgenerator.cpp index db48c4fdb..6a5686fb8 100644 --- a/cppgenerator.cpp +++ b/cppgenerator.cpp @@ -1652,19 +1652,18 @@ void CppGenerator::writeMultipleInheritanceInitializerFunction(QTextStream& s, c void CppGenerator::writeSpecialCastFunction(QTextStream& s, const AbstractMetaClass* metaClass) { + QString className = metaClass->qualifiedCppName(); s << "static void* " << cpythonSpecialCastFunctionName(metaClass) << "(PyObject* obj, SbkBaseWrapperType* desiredType)\n"; s << "{\n"; - s << INDENT << metaClass->qualifiedCppName() << "* me = " << cpythonWrapperCPtr(metaClass, "obj") << ";\n"; + s << INDENT << className << "* me = (" << className << "*) SbkBaseWrapper_cptr(obj);\n"; AbstractMetaClassList bases = getBaseClasses(metaClass); bool firstClass = true; - foreach(const AbstractMetaClass* baseClass, bases) { + foreach (const AbstractMetaClass* baseClass, getAllAncestors(metaClass)) { s << INDENT << (!firstClass ? "else " : "") << "if (desiredType == reinterpret_cast<SbkBaseWrapperType*>(" << cpythonTypeNameExt(baseClass->typeEntry()) << "))\n"; Indentation indent(INDENT); s << INDENT << "return static_cast<" << baseClass->qualifiedCppName() << "*>(me);\n"; firstClass = false; } - s << INDENT << "else\n"; - Indentation indent(INDENT); s << INDENT << "return me;\n"; s << "}\n\n"; } |