Commit 3ff84a29 authored by Martin Flöser's avatar Martin Flöser

[tools/generator] Pass this as q pointer to Client::Resource::Private

Experience showed that in most cases we need the q pointer in the
resource private class on the client side.
parent a5689b7b
...@@ -897,11 +897,14 @@ void Generator::generateClientPrivateResourceClass(const Interface &interface) ...@@ -897,11 +897,14 @@ void Generator::generateClientPrivateResourceClass(const Interface &interface)
"class %1::Private\n" "class %1::Private\n"
"{\n" "{\n"
"public:\n" "public:\n"
" Private() = default;\n" " Private(%1 *q);\n"
"\n" "\n"
" void setup(%2 *arg);\n" " void setup(%2 *arg);\n"
"\n" "\n"
" WaylandPointer<%2, %2_destroy> %3;\n" " WaylandPointer<%2, %2_destroy> %3;\n"
"\n"
"private:\n"
" %1 *q;\n"
"};\n\n"); "};\n\n");
*m_stream.localData() << templateString.arg(interface.kwaylandClientName()).arg(interface.name()).arg(interface.kwaylandClientName().toLower()); *m_stream.localData() << templateString.arg(interface.kwaylandClientName()).arg(interface.name()).arg(interface.kwaylandClientName().toLower());
...@@ -926,13 +929,32 @@ void Generator::generateClientPrivateGlobalClass(const Interface &interface) ...@@ -926,13 +929,32 @@ void Generator::generateClientPrivateGlobalClass(const Interface &interface)
void Generator::generateClientCpp(const Interface &interface) void Generator::generateClientCpp(const Interface &interface)
{ {
const QString templateString = QStringLiteral( if (interface.isGlobal()) {
// generate ctor without this pointer to Private
const QString templateString = QStringLiteral(
"%1::%1(QObject *parent)\n" "%1::%1(QObject *parent)\n"
" : QObject(parent)\n" " : QObject(parent)\n"
" , d(new Private)\n" " , d(new Private)\n"
"{\n" "{\n"
"}\n");
*m_stream.localData() << templateString.arg(interface.kwaylandClientName());
} else {
// Private ctor
const QString templateString = QStringLiteral(
"%1::Private::Private(%1 *q)\n"
" : q(q)\n"
"{\n"
"}\n" "}\n"
"\n" "\n"
"%1::%1(QObject *parent)\n"
" : QObject(parent)\n"
" , d(new Private(this))\n"
"{\n"
"}\n");
*m_stream.localData() << templateString.arg(interface.kwaylandClientName());
}
const QString templateString = QStringLiteral(
"\n"
"%1::~%1()\n" "%1::~%1()\n"
"{\n" "{\n"
" release();\n" " release();\n"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment