diff options
author | Marcelo Lira <marcelo.lira@openbossa.org> | 2011-04-06 18:58:18 -0300 |
---|---|---|
committer | Hugo Parente Lima <hugo.pl@gmail.com> | 2012-03-08 16:15:20 -0300 |
commit | f107f41c2b99517133ac4d2d624e8ee61cac2bb2 (patch) | |
tree | 5a5f4961c1189468c488c81e542b923937bd9316 /generator/cppgenerator.cpp | |
parent | 8c506130849194b0f7838a7920b5f7cc94bfe619 (diff) |
Fixed the argument conversion of modified virtual methods.
Wrong conversion code was being outputted to virtual method wrapper code
when all arguments were removed.
Unit tests were added as well.
Diffstat (limited to 'generator/cppgenerator.cpp')
-rw-r--r-- | generator/cppgenerator.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/generator/cppgenerator.cpp b/generator/cppgenerator.cpp index 72ca183b6..f208241b8 100644 --- a/generator/cppgenerator.cpp +++ b/generator/cppgenerator.cpp @@ -549,6 +549,17 @@ void CppGenerator::writeDestructorNative(QTextStream &s, const AbstractMetaClass s << '}' << endl; } +static bool allArgumentsRemoved(const AbstractMetaFunction* func) +{ + if (func->arguments().isEmpty()) + return false; + foreach (const AbstractMetaArgument* arg, func->arguments()) { + if (!func->argumentRemoved(arg->argumentIndex() + 1)) + return false; + } + return true; +} + void CppGenerator::writeVirtualMethodNative(QTextStream &s, const AbstractMetaFunction* func) { //skip metaObject function, this will be written manually ahead @@ -654,7 +665,7 @@ void CppGenerator::writeVirtualMethodNative(QTextStream &s, const AbstractMetaFu s << INDENT << "Shiboken::AutoDecRef pyargs("; - if (func->arguments().isEmpty()) { + if (func->arguments().isEmpty() || allArgumentsRemoved(func)) { s << "PyTuple_New(0));" << endl; } else { QStringList argConversions; @@ -3442,7 +3453,7 @@ void CppGenerator::writeClassRegister(QTextStream& s, const AbstractMetaClass* m s << INDENT << "Shiboken::ObjectType::setDestructorFunction(&" << cpythonTypeName(metaClass) << ", &Shiboken::callCppDestructor<" << dtorClassName << " >);" << endl; } - s << INDENT << "Py_INCREF((PyObject*)&" << pyTypeName << "); //Incref due the 'PyModule_AddObject' steals the reference." << endl; + s << INDENT << "Py_INCREF((PyObject*)&" << pyTypeName << "); //Incref due the 'PyModule_AddObject' steals the reference." << endl; s << INDENT << "if (PyType_Ready((PyTypeObject*)&" << pyTypeName << ") < 0)" << endl; s << INDENT << INDENT << "return;" << endl << endl; |