Skip to content

Commit a4cafc5

Browse files
jbowlermrbean-bremen
authored andcommitted
Handle constexpr, auto (#126)
These changes use the new and existing support inside the parser to handle constexpr in Qt6 files and to ignore (with a warning) 'auto' functions.
1 parent 8db0ff4 commit a4cafc5

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

generator/abstractmetabuilder.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1489,6 +1489,19 @@ AbstractMetaFunction *AbstractMetaBuilder::traverseFunction(FunctionModelItem fu
14891489
return 0;
14901490
}
14911491

1492+
if (function_item->isAuto()) {
1493+
/*TODO: it might work just to output 'auto', but this would require
1494+
* understanding what AbstractMetabuild::translateType() does and
1495+
* changing it. auto is only used once anyway.
1496+
*/
1497+
ReportHandler::warning(QString("%1: skipping auto function type '%2'")
1498+
.arg(function_name)
1499+
.arg(function_item->type().toString()));
1500+
m_rejected_functions[class_name + "::" + function_name + " " + function_item->type().toString()] =
1501+
UnmatchedReturnType;
1502+
return 0;
1503+
}
1504+
14921505
QString cast_type;
14931506

14941507
if (function_name.startsWith("operator")) {
@@ -1504,6 +1517,8 @@ AbstractMetaFunction *AbstractMetaBuilder::traverseFunction(FunctionModelItem fu
15041517

15051518
AbstractMetaFunction *meta_function = createMetaFunction();
15061519
meta_function->setConstant(function_item->isConstant());
1520+
meta_function->setConstexpr(function_item->isConstexpr());
1521+
meta_function->setAuto(function_item->isAuto());
15071522
meta_function->setException(function_item->exception());
15081523

15091524
ReportHandler::debugMedium(QString(" - %2()").arg(function_name));
@@ -1707,10 +1722,12 @@ AbstractMetaType *AbstractMetaBuilder::translateType(const TypeInfo &_typei, boo
17071722
//newInfo.setArguments(typei.arguments());
17081723
newInfo.setIndirections(typei.indirections());
17091724
newInfo.setConstant(typei.isConstant());
1725+
newInfo.setConstexpr(typei.isConstexpr());
17101726
newInfo.setFunctionPointer(typei.isFunctionPointer());
17111727
newInfo.setQualifiedName(typei.qualifiedName());
17121728
newInfo.setReference(typei.isReference());
17131729
newInfo.setVolatile(typei.isVolatile());
1730+
newInfo.setMutable(typei.isMutable());
17141731

17151732
AbstractMetaType *elementType = translateType(newInfo, ok);
17161733
if (!(*ok))

generator/abstractmetalang.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,8 @@ AbstractMetaFunction *AbstractMetaFunction::copy() const
315315
if (type())
316316
cpy->setType(type()->copy());
317317
cpy->setConstant(isConstant());
318+
cpy->setConstexpr(isConstexpr());
319+
cpy->setAuto(isAuto());
318320
cpy->setException(exception());
319321
cpy->setOriginalAttributes(originalAttributes());
320322

@@ -366,6 +368,8 @@ QString AbstractMetaFunction::signature() const
366368

367369
if (isConstant())
368370
s += " const";
371+
if (isConstexpr())
372+
s += " constexpr";
369373

370374
return s;
371375
}
@@ -657,6 +661,8 @@ QString AbstractMetaFunction::minimalSignature() const
657661
minimalSignature += ")";
658662
if (isConstant())
659663
minimalSignature += "const";
664+
if (isConstexpr())
665+
minimalSignature += "constexpr";
660666

661667
minimalSignature = TypeSystem::normalizedSignature(minimalSignature.toLocal8Bit().constData());
662668
m_cached_minimal_signature = minimalSignature;

generator/abstractmetalang.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,7 @@ class AbstractMetaFunction : public AbstractMetaAttributes
410410

411411
AbstractMetaFunction() :
412412
m_constant(false),
413+
m_constexpr(false),
413414
m_invalid(false)
414415
{
415416
}
@@ -487,6 +488,12 @@ class AbstractMetaFunction : public AbstractMetaAttributes
487488
bool isConstant() const { return m_constant; }
488489
void setConstant(bool constant) { m_constant = constant; }
489490

491+
bool isConstexpr() const { return m_constexpr; }
492+
void setConstexpr(bool constant) { m_constexpr = constant; }
493+
494+
bool isAuto() const { return m_auto; }
495+
void setAuto(bool isAuto) { m_auto = isAuto; }
496+
490497
QString exception() const { return m_exception; }
491498
void setException(const QString &exception) { m_exception = exception; }
492499
QString toString() const { return m_name; }
@@ -550,6 +557,8 @@ class AbstractMetaFunction : public AbstractMetaAttributes
550557
AbstractMetaArgumentList m_arguments;
551558
QString m_exception;
552559
uint m_constant : 1;
560+
uint m_constexpr : 1;
561+
uint m_auto : 1;
553562
uint m_invalid : 1;
554563
};
555564

0 commit comments

Comments
 (0)