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