diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2018-07-05 08:45:00 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2018-07-11 19:01:50 +0000 |
commit | 0a8e37cd60863773940d9d7f21403a841d744720 (patch) | |
tree | 50cdcf32098bc4622576029c8c666a060a6ccbe5 /sources/shiboken2/ApiExtractor/typeparser.cpp | |
parent | 6f5f279b49756b1f848a6d85fde6bcae5eef4937 (diff) |
shiboken: Improve support for volatile
Previously, the volatile keyword ended up as a part of the
qualified type name while parsing in translateType().
Add the token to TypeParser and add it to AbstractMetaType.
Task-number: PYSIDE-672
Change-Id: I553ea1b35e7e99ffde4442471b82e32be84731ba
Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources/shiboken2/ApiExtractor/typeparser.cpp')
-rw-r--r-- | sources/shiboken2/ApiExtractor/typeparser.cpp | 36 |
1 files changed, 29 insertions, 7 deletions
diff --git a/sources/shiboken2/ApiExtractor/typeparser.cpp b/sources/shiboken2/ApiExtractor/typeparser.cpp index 11f04d079..0a60159ae 100644 --- a/sources/shiboken2/ApiExtractor/typeparser.cpp +++ b/sources/shiboken2/ApiExtractor/typeparser.cpp @@ -49,6 +49,7 @@ public: GreaterThanToken, ConstToken, + VolatileToken, Identifier, NoToken, InvalidToken @@ -137,13 +138,30 @@ Scanner::Token Scanner::nextToken(QString *errorMessage) } } - if (tok == Identifier && m_pos - m_tokenStart == 5) { - if (m_chars[m_tokenStart] == QLatin1Char('c') - && m_chars[m_tokenStart + 1] == QLatin1Char('o') - && m_chars[m_tokenStart + 2] == QLatin1Char('n') - && m_chars[m_tokenStart + 3] == QLatin1Char('s') - && m_chars[m_tokenStart + 4] == QLatin1Char('t')) - tok = ConstToken; + if (tok == Identifier) { + switch (m_pos - m_tokenStart) { + case 5: + if (m_chars[m_tokenStart] == QLatin1Char('c') + && m_chars[m_tokenStart + 1] == QLatin1Char('o') + && m_chars[m_tokenStart + 2] == QLatin1Char('n') + && m_chars[m_tokenStart + 3] == QLatin1Char('s') + && m_chars[m_tokenStart + 4] == QLatin1Char('t')) { + tok = ConstToken; + } + break; + case 8: + if (m_chars[m_tokenStart] == QLatin1Char('v') + && m_chars[m_tokenStart + 1] == QLatin1Char('o') + && m_chars[m_tokenStart + 2] == QLatin1Char('l') + && m_chars[m_tokenStart + 3] == QLatin1Char('a') + && m_chars[m_tokenStart + 4] == QLatin1Char('t') + && m_chars[m_tokenStart + 5] == QLatin1Char('i') + && m_chars[m_tokenStart + 6] == QLatin1Char('l') + && m_chars[m_tokenStart + 7] == QLatin1Char('e')) { + tok = VolatileToken; + } + break; + } } return tok; @@ -241,6 +259,10 @@ TypeInfo TypeParser::parse(const QString &str, QString *errorMessage) } break; + case Scanner::VolatileToken: + stack.top()->m_volatile = true; + break; + case Scanner::OpenParenToken: // function pointers not supported case Scanner::CloseParenToken: { const QString message = scanner.msgParseError(QStringLiteral("Function pointers are not supported")); |