Skip to content

Commit d72f41f

Browse files
author
florianlink
committed
changed special generated method prefix to py_, added py_toString() generation
git-svn-id: http://svn.code.sf.net/p/pythonqt/code/trunk@152 ea8d5007-eb21-0410-b261-ccb3ea6e24a9
1 parent 1b2e626 commit d72f41f

5 files changed

+15
-10
lines changed

generator/abstractmetabuilder.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ void AbstractMetaBuilder::registerToStringCapability(FunctionModelItem function_
234234
if (arguments.at(0)->type().toString() == "QDebug"){
235235
ArgumentModelItem arg = arguments.at(1);
236236
if (AbstractMetaClass *cls = argumentToClass(arg)) {
237-
if (arg->type().indirections() < 2) {
237+
if (arg->type().indirections() < 2 && cls->name()!="QObject") {
238238
cls->setToStringCapability(function_item);
239239
}
240240
}

generator/metaqtscript.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,5 @@
4444

4545
bool MetaQtScriptClass::hasDefaultToStringFunction() const
4646
{
47-
return 0 < queryFunctionsByName("toString").size();
47+
return AbstractMetaClass::hasDefaultToStringFunction();
4848
}

generator/shellgenerator.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -223,9 +223,9 @@ void ShellGenerator::writeFunctionSignature(QTextStream &s,
223223
}
224224

225225
if (meta_function->attributes() & AbstractMetaAttributes::SetterFunction)
226-
s << "setter_";
226+
s << "py_set_";
227227
else if (meta_function->attributes() & AbstractMetaAttributes::GetterFunction)
228-
s << "getter_";
228+
s << "py_get_";
229229

230230
s << name_prefix << function_name;
231231

generator/shellheadergenerator.cpp

+7-4
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ void ShellHeaderGenerator::writeFieldAccessors(QTextStream &s, const AbstractMet
5757
const AbstractMetaFunction *setter = field->setter();
5858
const AbstractMetaFunction *getter = field->getter();
5959

60+
// Uuid data4 did not work
61+
if (field->enclosingClass()->name()=="QUuid" && setter->name()=="data4") return;
62+
6063
if (!field->type()->isConstant()) {
6164
writeFunctionSignature(s, setter, 0, QString(),
6265
Option(ConvertReferenceToPtr | FirstArgIsWrappedObject| IncludeDefaultExpression | ShowStatic | UnderscoreSpaces));
@@ -257,9 +260,9 @@ void ShellHeaderGenerator::write(QTextStream &s, const AbstractMetaClass *meta_c
257260
s << endl;
258261
}
259262
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;
261264
} 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;
263266
}
264267

265268
AbstractMetaFunctionList functions = getFunctionsToWrap(meta_class);
@@ -272,8 +275,8 @@ void ShellHeaderGenerator::write(QTextStream &s, const AbstractMetaClass *meta_c
272275
s << ";" << endl;
273276
}
274277
}
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;
277280
}
278281

279282
// Field accessors

generator/shellimplgenerator.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -284,11 +284,13 @@ void ShellImplGenerator::write(QTextStream &s, const AbstractMetaClass *meta_cla
284284
s << "}" << endl << endl;
285285
}
286286

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()) {
288290
FunctionModelItem fun = meta_class->hasToStringCapability();
289291
int indirections = fun->arguments().at(1)->type().indirections();
290292
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;
292294
s << " QString result;" << endl;
293295
s << " QDebug d(&result);" << endl;
294296
s << " d << " << deref << "obj;" << endl;

0 commit comments

Comments
 (0)