aboutsummaryrefslogtreecommitdiffstats
path: root/generator
diff options
context:
space:
mode:
authorJohn Ehresman <jpe@wingware.com>2012-12-20 17:39:11 -0500
committerHugo Parente Lima <hugo.lima@openbossa.org>2012-12-21 15:27:46 +0100
commit76a92c3cc6bda8511e5a8e19d159385361ac84a9 (patch)
tree3ae76dd850fb7ef94cda8dce62e05c0feaba2f69 /generator
parent4aa901db487cc1202680046091f074ea58544ea3 (diff)
Use getWrapperForQObject to convert if generating for PySide
Change-Id: I4a83bc3642c9853e61597093fb0a7f25fdfec46b Reviewed-by: Hugo Parente Lima <hugo.lima@openbossa.org>
Diffstat (limited to 'generator')
-rw-r--r--generator/shiboken/cppgenerator.cpp25
1 files changed, 14 insertions, 11 deletions
diff --git a/generator/shiboken/cppgenerator.cpp b/generator/shiboken/cppgenerator.cpp
index 2643ac7c1..a94cb750b 100644
--- a/generator/shiboken/cppgenerator.cpp
+++ b/generator/shiboken/cppgenerator.cpp
@@ -976,17 +976,22 @@ void CppGenerator::writeConverterFunctions(QTextStream& s, const AbstractMetaCla
// C++ pointer to a Python wrapper, keeping identity.
s << "// C++ to Python pointer conversion - tries to find the Python wrapper for the C++ object (keeps object identity)." << endl;
code.clear();
- c << INDENT << "PyObject* pyOut = (PyObject*)Shiboken::BindingManager::instance().retrieveWrapper(cppIn);" << endl;
- c << INDENT << "if (pyOut) {" << endl;
+ if (usePySideExtensions() && metaClass->isQObject())
{
- Indentation indent(INDENT);
- c << INDENT << "Py_INCREF(pyOut);" << endl;
- c << INDENT << "return pyOut;" << endl;
+ c << INDENT << "return PySide::getWrapperForQObject((" << typeName << "*)cppIn, &" << cpythonType << ");" << endl;
+ } else {
+ c << INDENT << "PyObject* pyOut = (PyObject*)Shiboken::BindingManager::instance().retrieveWrapper(cppIn);" << endl;
+ c << INDENT << "if (pyOut) {" << endl;
+ {
+ Indentation indent(INDENT);
+ c << INDENT << "Py_INCREF(pyOut);" << endl;
+ c << INDENT << "return pyOut;" << endl;
+ }
+ c << INDENT << '}' << endl;
+ c << INDENT << "const char* typeName = typeid(*((" << typeName << "*)cppIn)).name();" << endl;
+ c << INDENT << "return Shiboken::Object::newObject(&" << cpythonType;
+ c << ", const_cast<void*>(cppIn), false, false, typeName);";
}
- c << INDENT << '}' << endl;
- c << INDENT << "const char* typeName = typeid(*((" << typeName << "*)cppIn)).name();" << endl;
- c << INDENT << "return Shiboken::Object::newObject(&" << cpythonType;
- c << ", const_cast<void*>(cppIn), false, false, typeName);";
std::swap(targetTypeName, sourceTypeName);
writeCppToPythonFunction(s, code, sourceTypeName, targetTypeName);
@@ -3391,8 +3396,6 @@ void CppGenerator::writeClassDefinition(QTextStream& s, const AbstractMetaClass*
if (!metaClass->typeEntry()->hashFunction().isEmpty())
tp_hash = '&' + cpythonBaseName(metaClass) + "_HashFunc";
- else if (isObjectType(metaClass))
- tp_hash = "&Shiboken::Object::hash";
const AbstractMetaFunction* callOp = metaClass->findFunction("operator()");
if (callOp && !callOp->isModifiedRemoved())