diff options
author | Hugo Lima <hugo.lima@openbossa.org> | 2010-02-24 19:30:05 -0300 |
---|---|---|
committer | Hugo Lima <hugo.lima@openbossa.org> | 2010-02-24 19:30:05 -0300 |
commit | 87e9b581d64e2d34b2cc63ecc80b946be38ad190 (patch) | |
tree | d398be0099f141cc321de7e8452b02d42611db99 | |
parent | ea10af7b04f581034a32bf1f051ad0d024cfcc9c (diff) |
Fix bug#142.
Reviewed by Marcelo Lira <marcelo.lira@openbossa.org> and Luciano Wolf <luciano.wolf@openbossa.org>
-rw-r--r-- | cppgenerator.cpp | 13 | ||||
-rw-r--r-- | tests/libother/othermultiplederived.h | 47 | ||||
-rw-r--r-- | tests/otherbinding/CMakeLists.txt | 1 | ||||
-rw-r--r-- | tests/otherbinding/global.h | 1 | ||||
-rw-r--r-- | tests/otherbinding/typesystem_other.xml | 1 |
5 files changed, 58 insertions, 5 deletions
diff --git a/cppgenerator.cpp b/cppgenerator.cpp index 559be79a3..bd3c21993 100644 --- a/cppgenerator.cpp +++ b/cppgenerator.cpp @@ -1769,13 +1769,9 @@ void CppGenerator::writeClassDefinition(QTextStream& s, const AbstractMetaClass* // class or some ancestor has multiple inheritance const AbstractMetaClass* miClass = getMultipleInheritingClass(metaClass); if (miClass) { - mi_init = QString("(Shiboken::MultipleInheritanceInitFunction)%1") - .arg(multipleInheritanceInitializerFunctionName(miClass)); if (metaClass == miClass) { + mi_init = multipleInheritanceInitializerFunctionName(miClass); writeMultipleInheritanceInitializerFunction(s, metaClass); - } else { - s << "extern int* " << multipleInheritanceInitializerFunctionName(miClass); - s << "(const void* cptr);" << endl; } mi_specialcast = '&'+cpythonSpecialCastFunctionName(metaClass); writeSpecialCastFunction(s, metaClass); @@ -2582,6 +2578,13 @@ void CppGenerator::writeClassRegister(QTextStream& s, const AbstractMetaClass* m s << INDENT << bases.join(", ") << ");" << endl << endl; } + // Fill multiple inheritance init function, if needed. + const AbstractMetaClass* miClass = getMultipleInheritingClass(metaClass); + if (miClass && miClass != metaClass) { + s << INDENT << cpythonTypeName(metaClass) << ".mi_init = "; + s << "reinterpret_cast<SbkBaseWrapperType*>(" + cpythonTypeNameExt(miClass->typeEntry()) + ")->mi_init;" << endl << endl; + } + s << INDENT << "if (PyType_Ready((PyTypeObject*)&" << pyTypeName << ") < 0)" << endl; s << INDENT << INDENT << "return;" << endl << endl; diff --git a/tests/libother/othermultiplederived.h b/tests/libother/othermultiplederived.h new file mode 100644 index 000000000..454bfaf0f --- /dev/null +++ b/tests/libother/othermultiplederived.h @@ -0,0 +1,47 @@ +/* + * This file is part of the Shiboken Python Binding Generator project. + * + * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). + * + * Contact: PySide team <contact@pyside.org> + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * version 2.1 as published by the Free Software Foundation. Please + * review the following information to ensure the GNU Lesser General + * Public License version 2.1 requirements will be met: + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. + * + * As a special exception to the GNU Lesser General Public License + * version 2.1, the object code form of a "work that uses the Library" + * may incorporate material from a header file that is part of the + * Library. You may distribute such object code under terms of your + * choice, provided that the incorporated material (i) does not exceed + * more than 5% of the total size of the Library; and (ii) is limited to + * numerical parameters, data structure layouts, accessors, macros, + * inline functions and templates. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA + */ + +#ifndef OTHERMULTIPLEDERIVED_H +#define OTHERMULTIPLEDERIVED_H + +#include "libothermacros.h" +#include "multiple_derived.h" + +class ObjectType; + +class LIBOTHER_API OtherMultipleDerived : public MDerived1 +{ +}; + +#endif diff --git a/tests/otherbinding/CMakeLists.txt b/tests/otherbinding/CMakeLists.txt index b8c4096cf..500e8682a 100644 --- a/tests/otherbinding/CMakeLists.txt +++ b/tests/otherbinding/CMakeLists.txt @@ -7,6 +7,7 @@ ${CMAKE_CURRENT_SOURCE_DIR}/typesystem_other.xml set(other_SRC ${CMAKE_CURRENT_BINARY_DIR}/other/number_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/other/otherderived_wrapper.cpp +${CMAKE_CURRENT_BINARY_DIR}/other/othermultiplederived_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/other/other_module_wrapper.cpp ) diff --git a/tests/otherbinding/global.h b/tests/otherbinding/global.h index 7837ba17a..25276a982 100644 --- a/tests/otherbinding/global.h +++ b/tests/otherbinding/global.h @@ -1,4 +1,5 @@ #include "../samplebinding/global.h" #include "number.h" #include "otherderived.h" +#include "othermultiplederived.h" diff --git a/tests/otherbinding/typesystem_other.xml b/tests/otherbinding/typesystem_other.xml index 487613a4b..005334a39 100644 --- a/tests/otherbinding/typesystem_other.xml +++ b/tests/otherbinding/typesystem_other.xml @@ -3,6 +3,7 @@ <load-typesystem name="typesystem_sample.xml" generate="no" /> <object-type name="OtherDerived" /> + <object-type name="OtherMultipleDerived" /> <value-type name="Number" /> |