##// END OF EJS Templates
changed special generated method prefix to py_, added py_toString() generation...
florianlink -
r115:5366b65bcedb
parent child
Show More
@@ -234,7 +234,7 void AbstractMetaBuilder::registerToStringCapability(FunctionModelItem function_
234 234 if (arguments.at(0)->type().toString() == "QDebug"){
235 235 ArgumentModelItem arg = arguments.at(1);
236 236 if (AbstractMetaClass *cls = argumentToClass(arg)) {
237 if (arg->type().indirections() < 2) {
237 if (arg->type().indirections() < 2 && cls->name()!="QObject") {
238 238 cls->setToStringCapability(function_item);
239 239 }
240 240 }
@@ -44,5 +44,5
44 44
45 45 bool MetaQtScriptClass::hasDefaultToStringFunction() const
46 46 {
47 return 0 < queryFunctionsByName("toString").size();
47 return AbstractMetaClass::hasDefaultToStringFunction();
48 48 }
@@ -223,9 +223,9 void ShellGenerator::writeFunctionSignature(QTextStream &s,
223 223 }
224 224
225 225 if (meta_function->attributes() & AbstractMetaAttributes::SetterFunction)
226 s << "setter_";
226 s << "py_set_";
227 227 else if (meta_function->attributes() & AbstractMetaAttributes::GetterFunction)
228 s << "getter_";
228 s << "py_get_";
229 229
230 230 s << name_prefix << function_name;
231 231
@@ -57,6 +57,9 void ShellHeaderGenerator::writeFieldAccessors(QTextStream &s, const AbstractMet
57 57 const AbstractMetaFunction *setter = field->setter();
58 58 const AbstractMetaFunction *getter = field->getter();
59 59
60 // Uuid data4 did not work
61 if (field->enclosingClass()->name()=="QUuid" && setter->name()=="data4") return;
62
60 63 if (!field->type()->isConstant()) {
61 64 writeFunctionSignature(s, setter, 0, QString(),
62 65 Option(ConvertReferenceToPtr | FirstArgIsWrappedObject| IncludeDefaultExpression | ShowStatic | UnderscoreSpaces));
@@ -257,9 +260,9 void ShellHeaderGenerator::write(QTextStream &s, const AbstractMetaClass *meta_c
257 260 s << endl;
258 261 }
259 262 if (meta_class->name()=="QTreeWidgetItem") {
260 s << "bool hasOwner(QTreeWidgetItem* theWrappedObject) { return theWrappedObject->treeWidget()!=NULL || theWrappedObject->parent()!=NULL; }" << endl;
263 s << "bool py_hasOwner(QTreeWidgetItem* theWrappedObject) { return theWrappedObject->treeWidget()!=NULL || theWrappedObject->parent()!=NULL; }" << endl;
261 264 } else if (meta_class->name()=="QGraphicsItem") {
262 s << "bool hasOwner(QGraphicsItem* theWrappedObject) { return theWrappedObject->scene()!=NULL || theWrappedObject->parentItem()!=NULL; }" << endl;
265 s << "bool py_hasOwner(QGraphicsItem* theWrappedObject) { return theWrappedObject->scene()!=NULL || theWrappedObject->parentItem()!=NULL; }" << endl;
263 266 }
264 267
265 268 AbstractMetaFunctionList functions = getFunctionsToWrap(meta_class);
@@ -272,8 +275,8 void ShellHeaderGenerator::write(QTextStream &s, const AbstractMetaClass *meta_c
272 275 s << ";" << endl;
273 276 }
274 277 }
275 if (!meta_class->hasDefaultToStringFunction() && meta_class->hasToStringCapability()) {
276 s << " QString toString(" << meta_class->qualifiedCppName() << "*);" << endl;
278 if (meta_class->hasDefaultToStringFunction() || meta_class->hasToStringCapability()) {
279 s << " QString py_toString(" << meta_class->qualifiedCppName() << "*);" << endl;
277 280 }
278 281
279 282 // Field accessors
@@ -284,11 +284,13 void ShellImplGenerator::write(QTextStream &s, const AbstractMetaClass *meta_cla
284 284 s << "}" << endl << endl;
285 285 }
286 286
287 if (!meta_class->hasDefaultToStringFunction() && meta_class->hasToStringCapability()) {
287 if (meta_class->hasDefaultToStringFunction()) {
288 s << "QString PythonQtWrapper_" << meta_class->name() << "::py_toString(" << meta_class->qualifiedCppName() << "* obj) { return obj->toString(); }" << endl;
289 } else if (meta_class->hasToStringCapability()) {
288 290 FunctionModelItem fun = meta_class->hasToStringCapability();
289 291 int indirections = fun->arguments().at(1)->type().indirections();
290 292 QString deref = QLatin1String(indirections == 0 ? "*" : "");
291 s << "QString PythonQtWrapper_" << meta_class->name() << "::toString(" << meta_class->qualifiedCppName() << "* obj) {" << endl;
293 s << "QString PythonQtWrapper_" << meta_class->name() << "::py_toString(" << meta_class->qualifiedCppName() << "* obj) {" << endl;
292 294 s << " QString result;" << endl;
293 295 s << " QDebug d(&result);" << endl;
294 296 s << " d << " << deref << "obj;" << endl;
General Comments 0
You need to be logged in to leave comments. Login now