@@ -502,6 +502,7 bool AbstractMetaBuilder::build() | |||
|
502 | 502 | traverseCompareOperator(item); |
|
503 | 503 | } |
|
504 | 504 | } |
|
505 | // TODO XXX search and add operator+ etc. to the classes here! | |
|
505 | 506 | |
|
506 | 507 | { |
|
507 | 508 | FunctionList stream_operators = m_dom->findFunctions("operator<<") + m_dom->findFunctions("operator>>"); |
@@ -65,6 +65,7 public: | |||
|
65 | 65 | NoBlockedSlot = 0x00100000, |
|
66 | 66 | SuperCall = 0x00200000, |
|
67 | 67 | FirstArgIsWrappedObject = 0x00400000, |
|
68 | ConvertReferenceToPtr = 0x00800000, | |
|
68 | 69 | |
|
69 | 70 | GlobalRefJObject = 0x00100000, |
|
70 | 71 |
@@ -88,8 +88,13 void ShellGenerator::writeTypeInfo(QTextStream &s, const AbstractMetaType *type, | |||
|
88 | 88 | |
|
89 | 89 | s << QString(type->indirections(), '*'); |
|
90 | 90 | |
|
91 | if (type->isReference() && !(options & ExcludeReference)) | |
|
91 | if (type->isReference() && !(options & ExcludeReference) && !(options & ConvertReferenceToPtr)) | |
|
92 | 92 | s << "&"; |
|
93 | ||
|
94 | if (type->isReference() && (options & ConvertReferenceToPtr)) { | |
|
95 | s << "*"; | |
|
96 | } | |
|
97 | ||
|
93 | 98 |
|
|
94 | 99 |
|
|
95 | 100 | s << ' '; |
@@ -216,7 +221,7 void ShellGenerator::writeFunctionSignature(QTextStream &s, | |||
|
216 | 221 | } |
|
217 | 222 | } |
|
218 | 223 | |
|
219 | writeFunctionArguments(s, meta_function->ownerClass(), meta_function->arguments(), option, numArguments); | |
|
224 | writeFunctionArguments(s, meta_function->ownerClass(), meta_function->arguments(), Option(option & Option(~ConvertReferenceToPtr)), numArguments); | |
|
220 | 225 | |
|
221 | 226 | // The extra arguments... |
|
222 | 227 | for (int i=0; i<extra_arguments.size(); ++i) { |
@@ -244,10 +244,13 void ShellHeaderGenerator::write(QTextStream &s, const AbstractMetaClass *meta_c | |||
|
244 | 244 | if (!function->isSlot()) { |
|
245 | 245 | s << " "; |
|
246 | 246 | writeFunctionSignature(s, function, 0, QString(), |
|
247 | Option(FirstArgIsWrappedObject| IncludeDefaultExpression | OriginalName | ShowStatic | UnderscoreSpaces)); | |
|
247 | Option(ConvertReferenceToPtr | FirstArgIsWrappedObject| IncludeDefaultExpression | OriginalName | ShowStatic | UnderscoreSpaces)); | |
|
248 | 248 | s << ";" << endl; |
|
249 | 249 | } |
|
250 | 250 | } |
|
251 | if (!meta_class->hasDefaultToStringFunction() && meta_class->hasToStringCapability()) { | |
|
252 | s << " QString toString(" << meta_class->qualifiedCppName() << "*);" << endl; | |
|
253 | } | |
|
251 | 254 | |
|
252 | 255 | // writeInjectedCode(s, meta_class); |
|
253 | 256 |
@@ -169,7 +169,6 void ShellImplGenerator::write(QTextStream &s, const AbstractMetaClass *meta_cla | |||
|
169 | 169 | if (fun->type()) { |
|
170 | 170 | s << "return "; |
|
171 | 171 | } |
|
172 | // call the C++ implementation | |
|
173 | 172 | s << meta_class->qualifiedCppName() << "::"; |
|
174 | 173 | s << fun->originalName() << "("; |
|
175 | 174 | for (int i = 0; i < args.size(); ++i) { |
@@ -213,7 +212,7 void ShellImplGenerator::write(QTextStream &s, const AbstractMetaClass *meta_cla | |||
|
213 | 212 | if (fun->isSlot()) continue; |
|
214 | 213 | |
|
215 | 214 | writeFunctionSignature(s, fun, meta_class, QString(), |
|
216 | Option(FirstArgIsWrappedObject | OriginalName | ShowStatic | UnderscoreSpaces), | |
|
215 | Option(ConvertReferenceToPtr | FirstArgIsWrappedObject | OriginalName | ShowStatic | UnderscoreSpaces), | |
|
217 | 216 | "PythonQtWrapper_"); |
|
218 | 217 | s << endl << "{" << endl; |
|
219 | 218 | s << " "; |
@@ -229,8 +228,14 void ShellImplGenerator::write(QTextStream &s, const AbstractMetaClass *meta_cla | |||
|
229 | 228 | QString scriptFunctionName = fun->originalName(); |
|
230 | 229 | AbstractMetaArgumentList args = fun->arguments(); |
|
231 | 230 | // call the C++ implementation |
|
232 | if (fun->type()) | |
|
231 | if (fun->type()) { | |
|
233 | 232 | s << "return "; |
|
233 | // call the C++ implementation | |
|
234 | if (fun->type()->isReference()) { | |
|
235 | s << "&"; | |
|
236 | } | |
|
237 | } | |
|
238 | s << "("; | |
|
234 | 239 | if (scriptFunctionName.startsWith("operator>>")) { |
|
235 | 240 | s << wrappedObject << " >>" << args.at(0)->argumentName(); |
|
236 | 241 | } else if (scriptFunctionName.startsWith("operator<<")) { |
@@ -258,11 +263,25 void ShellImplGenerator::write(QTextStream &s, const AbstractMetaClass *meta_cla | |||
|
258 | 263 | } |
|
259 | 264 | s << ")"; |
|
260 | 265 | } |
|
266 | s << ")"; | |
|
261 | 267 | } |
|
262 | 268 | s << ";" << endl; |
|
263 | 269 | |
|
264 | 270 | s << "}" << endl << endl; |
|
265 | 271 | } |
|
272 | ||
|
273 | if (!meta_class->hasDefaultToStringFunction() && meta_class->hasToStringCapability()) { | |
|
274 | FunctionModelItem fun = meta_class->hasToStringCapability(); | |
|
275 | int indirections = fun->arguments().at(1)->type().indirections(); | |
|
276 | QString deref = QLatin1String(indirections == 0 ? "*" : ""); | |
|
277 | s << "QString PythonQtWrapper_" << meta_class->name() << "::toString(" << meta_class->qualifiedCppName() << "* obj) {" << endl; | |
|
278 | s << " QString result;" << endl; | |
|
279 | s << " QDebug d(&result);" << endl; | |
|
280 | s << " d << " << deref << "obj;" << endl; | |
|
281 | s << " return result;" << endl; | |
|
282 | s << "}" << endl << endl; | |
|
283 | } | |
|
284 | ||
|
266 | 285 | } |
|
267 | 286 | |
|
268 | 287 | void ShellImplGenerator::writeInjectedCode(QTextStream &s, const AbstractMetaClass *meta_class) |
General Comments 0
You need to be logged in to leave comments.
Login now