summaryrefslogtreecommitdiffstats
path: root/src/tools
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2012-03-05 17:55:59 +0100
committerQt by Nokia <qt-info@nokia.com>2012-08-26 14:29:52 +0200
commit80694dd614a112046a5d5af1824ea52ef3a28823 (patch)
treeb0e85100a9ad67f3c833369de0b01c00b4e6dfd5 /src/tools
parentd811b2434bd583a94a5e2b99808b8103768b1606 (diff)
moc: parse classes that use Q_DECL_FINAL|final|sealed
This only works with the C++11 contextual keyword directly, the MSVC equivalent 'sealed', or the Qt define for it. While this isn't a problem for syncqt, being an internal tool, moc should eventually be able to parse user code using local C++11-final-wrapping macros. For this, I guess moc would have to be taught to expand macros in code and not just test #if clauses, potentially driven by something like #pragma qt-moc expand-this #define MY_FINAL_CLASS final but that's something for someone more intimately familiar with moc's source than I am. Change-Id: Id6aec961a881e8d5a9b76a7fc8e1c02c71913f64 Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/moc/moc.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/tools/moc/moc.cpp b/src/tools/moc/moc.cpp
index f63404c3c2..a176b87aaa 100644
--- a/src/tools/moc/moc.cpp
+++ b/src/tools/moc/moc.cpp
@@ -100,13 +100,16 @@ bool Moc::parseClassHead(ClassDef *def)
QByteArray name = lexem();
// support "class IDENT name" and "class IDENT(IDENT) name"
+ // also support "class IDENT name (final|sealed|Q_DECL_FINAL)"
if (test(LPAREN)) {
until(RPAREN);
if (!test(IDENTIFIER))
return false;
name = lexem();
} else if (test(IDENTIFIER)) {
- name = lexem();
+ const QByteArray lex = lexem();
+ if (lex != "final" && lex != "sealed" && lex != "Q_DECL_FINAL")
+ name = lex;
}
def->qualified += name;
@@ -118,6 +121,13 @@ bool Moc::parseClassHead(ClassDef *def)
}
}
def->classname = name;
+
+ if (test(IDENTIFIER)) {
+ const QByteArray lex = lexem();
+ if (lex != "final" && lex != "sealed" && lex != "Q_DECL_FINAL")
+ return false;
+ }
+
if (test(COLON)) {
do {
test(VIRTUAL);