From f93f1d21eb33707e664b368d876fdf50ce49290c 2009-05-26 11:42:30 From: florianlink Date: 2009-05-26 11:42:30 Subject: [PATCH] improved generator, requires uptodate pythonqt version git-svn-id: svn://svn.code.sf.net/p/pythonqt/code/trunk@102 ea8d5007-eb21-0410-b261-ccb3ea6e24a9 --- diff --git a/generator/shellgenerator.h b/generator/shellgenerator.h index 090e406..8860aeb 100644 --- a/generator/shellgenerator.h +++ b/generator/shellgenerator.h @@ -72,7 +72,7 @@ public: static bool isSpecialStreamingOperator(const AbstractMetaFunction *fun); static void writeInclude(QTextStream &stream, const Include &inc); - + protected: PriGenerator *priGenerator; diff --git a/generator/shellimplgenerator.cpp b/generator/shellimplgenerator.cpp index 7001328..93bbac3 100644 --- a/generator/shellimplgenerator.cpp +++ b/generator/shellimplgenerator.cpp @@ -98,24 +98,26 @@ void ShellImplGenerator::write(QTextStream &s, const AbstractMetaClass *meta_cla "PythonQtShell_"); s << endl << "{" << endl; - Option typeOptions = Option(OriginalName | UnderscoreSpaces); + Option typeOptions = Option(OriginalName | UnderscoreSpaces | SkipName); AbstractMetaArgumentList args = fun->arguments(); s << "if (_wrapper) {" << endl; s << " PyObject* obj = PyObject_GetAttrString((PyObject*)_wrapper, \"" << fun->name() << "\");" << endl; s << " PyErr_Clear();" << endl; s << " if (obj && !PythonQtSlotFunction_Check(obj)) {" << endl; - s << " static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromMetaObjectAndSignature(" << endl; - s << " &" << wrapperClassName(meta_class) << "::staticMetaObject," << endl; - s << " \""; - // write the signature - s << fun->name() << "(" << meta_class->qualifiedCppName() << "*"; + s << " static const char* argumentList[] ={\""; + if (hasReturnValue) { + // write the arguments, return type first + writeTypeInfo(s, fun->type(), typeOptions); + } + s << "\""; for (int i = 0; i < args.size(); ++i) { - s << ","; + s << " , \""; writeTypeInfo(s, args.at(i)->type(), typeOptions); + s << "\""; } - s << ")"; - s << "\");" << endl; + s << "};" << endl; + s << " static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(" << QString::number(args.size()+1) << ", argumentList);" << endl; if (hasReturnValue) { s << " "; @@ -134,9 +136,13 @@ void ShellImplGenerator::write(QTextStream &s, const AbstractMetaClass *meta_cla s << " if (result) {" << endl; s << " args[0] = PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, NULL, &returnValue);" << endl; s << " if (args[0]!=&returnValue) {" << endl; - s << " returnValue = *(("; + s << " if (args[0]==NULL) {" << endl; + s << " PythonQt::priv()->handleVirtualOverloadReturnError(\"" << fun->name() << "\", methodInfo, result);" << endl; + s << " } else {" << endl; + s << " returnValue = *(("; writeTypeInfo(s, fun->type(), typeOptions); s << "*)args[0]);" << endl; + s << " }" << endl; s << " }" << endl; s << " }" << endl; }