Skip to content

Commit e6e29ec

Browse files
committed
Remember/re-use the result of AbstractMetaClass::generateShellClass()
1 parent 3655a2f commit e6e29ec

2 files changed

Lines changed: 8 additions & 10 deletions

File tree

‎generator/shellheadergenerator.cpp‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,8 @@ void ShellHeaderGenerator::write(QTextStream& s, const AbstractMetaClass* meta_c
135135
}
136136

137137
// Shell-------------------------------------------------------------------
138-
if (meta_class->generateShellClass() && !ctors.isEmpty()) {
138+
bool generateShell = meta_class->generateShellClass() && !ctors.isEmpty();
139+
if (generateShell) {
139140

140141
AbstractMetaFunctionList virtualsForShell = getVirtualFunctionsForShell(meta_class);
141142

@@ -348,12 +349,12 @@ void ShellHeaderGenerator::write(QTextStream& s, const AbstractMetaClass* meta_c
348349
}
349350
}
350351
s << "public Q_SLOTS:" << Qt::endl;
351-
if (meta_class->generateShellClass() || !meta_class->isAbstract()) {
352+
if (generateShell || !meta_class->isAbstract()) {
352353

353354
bool copyConstructorSeen = false;
354355
bool defaultConstructorSeen = false;
355356
for (const AbstractMetaFunction* fun : ctors) {
356-
if (fun->isAbstract() || (!meta_class->generateShellClass() && !fun->isPublic())) {
357+
if (fun->isAbstract() || (!generateShell && !fun->isPublic())) {
357358
continue;
358359
}
359360

@@ -373,8 +374,7 @@ void ShellHeaderGenerator::write(QTextStream& s, const AbstractMetaClass* meta_c
373374
if (meta_class->typeEntry()->isValue() && !copyConstructorSeen && defaultConstructorSeen
374375
&& !meta_class->typeEntry()->hasNoCopy())
375376
{
376-
QString className =
377-
meta_class->generateShellClass() ? shellClassName(meta_class) : meta_class->qualifiedCppName();
377+
QString className = generateShell ? shellClassName(meta_class) : meta_class->qualifiedCppName();
378378
s << meta_class->qualifiedCppName() << "* new_" << meta_class->name() << "(const "
379379
<< meta_class->qualifiedCppName() << "& other) {" << Qt::endl;
380380
s << className << "* a = new " << className << "();" << Qt::endl;

‎generator/shellimplgenerator.cpp‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -228,11 +228,11 @@ void ShellImplGenerator::write(QTextStream& s, const AbstractMetaClass* meta_cla
228228
}
229229
}
230230

231-
if (meta_class->generateShellClass() || !meta_class->isAbstract()) {
231+
if (generateShell || !meta_class->isAbstract()) {
232232

233233
// write constructors
234234
for (const AbstractMetaFunction* ctor : ctors) {
235-
if (ctor->isAbstract() || (!meta_class->generateShellClass() && !ctor->isPublic())) {
235+
if (ctor->isAbstract() || (!generateShell && !ctor->isPublic())) {
236236
continue;
237237
}
238238

@@ -241,8 +241,7 @@ void ShellImplGenerator::write(QTextStream& s, const AbstractMetaClass* meta_cla
241241
writeFunctionSignature(s, ctor, 0, "new_", Option(AddOwnershipTemplates | ShowStatic));
242242
s << Qt::endl;
243243
s << "{ " << Qt::endl;
244-
s << "return new "
245-
<< (meta_class->generateShellClass() ? shellClassName(meta_class) : meta_class->qualifiedCppName()) << "(";
244+
s << "return new " << (generateShell ? shellClassName(meta_class) : meta_class->qualifiedCppName()) << "(";
246245
AbstractMetaArgumentList args = ctor->arguments();
247246
for (int i = 0; i < args.size(); ++i) {
248247
if (i > 0)
@@ -333,7 +332,6 @@ void ShellImplGenerator::write(QTextStream& s, const AbstractMetaClass* meta_cla
333332
}
334333
} else {
335334
if (fun->wasProtected()) {
336-
//|| (fun->isVirtual() && meta_class->typeEntry()->shouldCreatePromoter())) {
337335
s << " ((" << promoterClassName(meta_class) << "*)theWrappedObject)->promoted_";
338336
} else {
339337
s << " theWrappedObject->";

0 commit comments

Comments
 (0)