summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrenatofilho <renato.filho@openbossa.org>2010-11-05 16:35:59 -0300
committerrenatofilho <renato.filho@openbossa.org>2010-11-05 17:39:20 -0300
commit4120f5e4b8a2781a917d97395b251fbc0bf8c8d8 (patch)
tree4e4103e1a09b5bdae103e25114ecfa83eb0023f1
parenta97ff930b29f6c4d51fdda0f448d172ceb83654e (diff)
downloadshiboken-4120f5e4b8a2781a917d97395b251fbc0bf8c8d8.tar.gz
shiboken-4120f5e4b8a2781a917d97395b251fbc0bf8c8d8.tar.xz
shiboken-4120f5e4b8a2781a917d97395b251fbc0bf8c8d8.zip
Implemented support to dynamic slots on generated code.
Fixes bug #451. Reviewer: Luciano Wolf <luciano.wolf@openbossa.org> Hugo Parente Lima <hugo.pl@gmail.com>
-rw-r--r--generator/cppgenerator.cpp36
1 files changed, 29 insertions, 7 deletions
diff --git a/generator/cppgenerator.cpp b/generator/cppgenerator.cpp
index 0a1cd315..77c34000 100644
--- a/generator/cppgenerator.cpp
+++ b/generator/cppgenerator.cpp
@@ -168,12 +168,13 @@ void CppGenerator::generateClass(QTextStream &s, const AbstractMetaClass *metaCl
s << "#include <pyside.h>" << endl;
}
- s << "#include <typeresolver.h>\n";
- s << "#include <typeinfo>\n";
+ s << "#include <typeresolver.h>" << endl;
+ s << "#include <typeinfo>" << endl;
if (usePySideExtensions()) {
if (metaClass->isQObject()) {
- s << "#include <signalmanager.h>\n";
- s << "#include <dynamicqmetaobject.h>\n";
+ s << "#include <signalmanager.h>" << endl;
+ s << "#include <dynamicqmetaobject.h>" << endl;
+ s << "#include <pysidemetafunction.h>" << endl;
}
}
@@ -3550,9 +3551,30 @@ void CppGenerator::writeGetattroFunction(QTextStream& s, const AbstractMetaClass
{
Indentation indent(INDENT);
s << INDENT << "QMetaMethod method = metaObject->method(i);" << endl
- << INDENT << "if ((method.methodType() == QMetaMethod::Signal) &&" << endl
- << INDENT << "QString(method.signature()).startsWith(cname))" << endl
- << INDENT << "signalList.append(method);" << endl;
+ << INDENT << "if (QString(method.signature()).startsWith(cname)) {" << endl;
+ {
+ Indentation indent(INDENT);
+ s << INDENT << "if (method.methodType() == QMetaMethod::Signal) {" << endl;
+ {
+ Indentation indent(INDENT);
+ s << INDENT << "signalList.append(method);" << endl;
+ }
+ s << INDENT << "} else {" << endl;
+ {
+ Indentation indent(INDENT);
+ s << INDENT << "PySideMetaFunction* func = PySide::MetaFunction::newObject(cppSelf, i);" << endl
+ << INDENT << "if (func) {" << endl;
+ {
+ Indentation indent(INDENT);
+ s << INDENT << "PyObject_SetAttr(self, name, (PyObject*)func);" << endl
+ << INDENT << "return (PyObject*)func;" << endl;
+ }
+ s << INDENT << "}" << endl;
+ }
+ s << INDENT << "}" << endl;
+ }
+ s << INDENT << "}" << endl;
+
}
s << INDENT << "}" << endl
<< INDENT << "if (signalList.size() > 0) {" << endl;