diff options
author | Hugo Parente Lima <hugo.pl@gmail.com> | 2010-06-29 17:46:29 -0300 |
---|---|---|
committer | Hugo Parente Lima <hugo.pl@gmail.com> | 2010-06-29 18:04:09 -0300 |
commit | 8c973bffccd02365e855af602dc108aa8ba59b72 (patch) | |
tree | 23ede9c1cdc1afc4b9b8221453bab6a37a047b54 | |
parent | 346b26bf5a37117f2fca587d8add5611910e2736 (diff) |
Create specializations for createWrapper function when a class inherits QObject.
We need this to call PySide::signalUpdateSource to setup the signals on objects
originated from C++.
Reviewer: Marcelo Lira <marcelo.lira@openbossa.org>
Luciano Wolf <luciano.wolf@openbossa.org>
-rw-r--r-- | headergenerator.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/headergenerator.cpp b/headergenerator.cpp index 4543799e2..59f3f6e04 100644 --- a/headergenerator.cpp +++ b/headergenerator.cpp @@ -390,6 +390,8 @@ void HeaderGenerator::finishGeneration() s << "#include <basewrapper.h>" << endl; s << "#include <bindingmanager.h>" << endl; s << "#include <memory>" << endl << endl; + if (usePySideExtensions()) + s << "#include <qsignal.h>" << endl; writeExportMacros(s); QStringList requiredTargetImports = TypeDatabase::instance()->requiredTargetImports(); @@ -424,6 +426,25 @@ void HeaderGenerator::finishGeneration() s << "// PyType functions, to get the PyObjectType for a type T\n"; s << sbkTypeFunctions << endl; + + if (usePySideExtensions()) { + foreach (AbstractMetaClass* metaClass, classes()) { + if (!metaClass->isQObject() || !metaClass->typeEntry()->generateCode()) + continue; + + s << "template<>" << endl; + s << "inline PyObject* createWrapper<" << metaClass->qualifiedCppName() << " >(const "; + s << metaClass->qualifiedCppName() << "* cppobj, bool hasOwnership, bool isExactType)" << endl; + s << '{' << endl; + s << INDENT << "PyObject* pyObj = Shiboken::SbkBaseWrapper_New(reinterpret_cast<SbkBaseWrapperType*>(SbkType<" << metaClass->qualifiedCppName() << " >())," + << "const_cast<" << metaClass->qualifiedCppName() << "*>(cppobj), hasOwnership, isExactType);" << endl; + s << INDENT << "PySide::signalUpdateSource(pyObj);" << endl; + s << INDENT << "return pyObj;" << endl; + s << '}' << endl; + + } + } + s << "// Generated converters declarations ----------------------------------" << endl << endl; s << convertersDecl; s << "} // namespace Shiboken" << endl << endl; |