##// END OF EJS Templates
improved generator, requires uptodate pythonqt version...
florianlink -
r66:f93f1d21eb33
parent child
Show More
1 NO CONTENT: modified file
NO CONTENT: modified file
@@ -98,24 +98,26 void ShellImplGenerator::write(QTextStream &s, const AbstractMetaClass *meta_cla
98 "PythonQtShell_");
98 "PythonQtShell_");
99 s << endl << "{" << endl;
99 s << endl << "{" << endl;
100
100
101 Option typeOptions = Option(OriginalName | UnderscoreSpaces);
101 Option typeOptions = Option(OriginalName | UnderscoreSpaces | SkipName);
102 AbstractMetaArgumentList args = fun->arguments();
102 AbstractMetaArgumentList args = fun->arguments();
103
103
104 s << "if (_wrapper) {" << endl;
104 s << "if (_wrapper) {" << endl;
105 s << " PyObject* obj = PyObject_GetAttrString((PyObject*)_wrapper, \"" << fun->name() << "\");" << endl;
105 s << " PyObject* obj = PyObject_GetAttrString((PyObject*)_wrapper, \"" << fun->name() << "\");" << endl;
106 s << " PyErr_Clear();" << endl;
106 s << " PyErr_Clear();" << endl;
107 s << " if (obj && !PythonQtSlotFunction_Check(obj)) {" << endl;
107 s << " if (obj && !PythonQtSlotFunction_Check(obj)) {" << endl;
108 s << " static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromMetaObjectAndSignature(" << endl;
108 s << " static const char* argumentList[] ={\"";
109 s << " &" << wrapperClassName(meta_class) << "::staticMetaObject," << endl;
109 if (hasReturnValue) {
110 // write the arguments, return type first
111 writeTypeInfo(s, fun->type(), typeOptions);
112 }
110 s << " \"";
113 s << "\"";
111 // write the signature
112 s << fun->name() << "(" << meta_class->qualifiedCppName() << "*";
113 for (int i = 0; i < args.size(); ++i) {
114 for (int i = 0; i < args.size(); ++i) {
114 s << ",";
115 s << " , \"";
115 writeTypeInfo(s, args.at(i)->type(), typeOptions);
116 writeTypeInfo(s, args.at(i)->type(), typeOptions);
117 s << "\"";
116 }
118 }
117 s << ")";
119 s << "};" << endl;
118 s << "\");" << endl;
120 s << " static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(" << QString::number(args.size()+1) << ", argumentList);" << endl;
119
121
120 if (hasReturnValue) {
122 if (hasReturnValue) {
121 s << " ";
123 s << " ";
@@ -134,11 +136,15 void ShellImplGenerator::write(QTextStream &s, const AbstractMetaClass *meta_cla
134 s << " if (result) {" << endl;
136 s << " if (result) {" << endl;
135 s << " args[0] = PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, NULL, &returnValue);" << endl;
137 s << " args[0] = PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, NULL, &returnValue);" << endl;
136 s << " if (args[0]!=&returnValue) {" << endl;
138 s << " if (args[0]!=&returnValue) {" << endl;
139 s << " if (args[0]==NULL) {" << endl;
140 s << " PythonQt::priv()->handleVirtualOverloadReturnError(\"" << fun->name() << "\", methodInfo, result);" << endl;
141 s << " } else {" << endl;
137 s << " returnValue = *((";
142 s << " returnValue = *((";
138 writeTypeInfo(s, fun->type(), typeOptions);
143 writeTypeInfo(s, fun->type(), typeOptions);
139 s << "*)args[0]);" << endl;
144 s << "*)args[0]);" << endl;
140 s << " }" << endl;
145 s << " }" << endl;
141 s << " }" << endl;
146 s << " }" << endl;
147 s << " }" << endl;
142 }
148 }
143 s << " if (result) { Py_DECREF(result); } " << endl;
149 s << " if (result) { Py_DECREF(result); } " << endl;
144 s << " Py_DECREF(obj);" << endl;
150 s << " Py_DECREF(obj);" << endl;
General Comments 0
You need to be logged in to leave comments. Login now