diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2018-07-04 12:22:54 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2018-07-11 19:01:47 +0000 |
commit | 6f5f279b49756b1f848a6d85fde6bcae5eef4937 (patch) | |
tree | 825fe846b1ce66c01338a97aebb9126749ccaf3a /sources/shiboken2/ApiExtractor/typeparser.cpp | |
parent | ae7cb8f5c903b0176dbb98617d6c604874ca4219 (diff) |
shiboken: Introduce enumeration for C++ indirections
Replace the int "indirections" field of TypeInfo and AbstractMetaType
by a Vector of an enumeration representing '*' and "* const".
It is then possible distinguish between "int *" and "int *const".
Task-number: PYSIDE-672
Change-Id: I68677fa515abb7e94217fc1c2b6ac28b42678284
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'sources/shiboken2/ApiExtractor/typeparser.cpp')
-rw-r--r-- | sources/shiboken2/ApiExtractor/typeparser.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/sources/shiboken2/ApiExtractor/typeparser.cpp b/sources/shiboken2/ApiExtractor/typeparser.cpp index 919da5471..11f04d079 100644 --- a/sources/shiboken2/ApiExtractor/typeparser.cpp +++ b/sources/shiboken2/ApiExtractor/typeparser.cpp @@ -167,6 +167,7 @@ TypeInfo TypeParser::parse(const QString &str, QString *errorMessage) bool colon_prefix = false; bool in_array = false; QString array; + bool seenStar = false; Scanner::Token tok = scanner.nextToken(errorMessage); while (tok != Scanner::NoToken) { @@ -191,7 +192,8 @@ TypeInfo TypeParser::parse(const QString &str, QString *errorMessage) switch (tok) { case Scanner::StarToken: - ++stack.top()->m_indirections; + seenStar = true; + stack.top()->addIndirection(Indirection::Pointer); break; case Scanner::AmpersandToken: @@ -231,7 +233,12 @@ TypeInfo TypeParser::parse(const QString &str, QString *errorMessage) break; case Scanner::ConstToken: - stack.top()->m_constant = true; + if (seenStar) { // "int *const": Last indirection is const. + Q_ASSERT(!stack.top()->m_indirections.isEmpty()); + *stack.top()->m_indirections.rbegin() = Indirection::ConstPointer; + } else { + stack.top()->m_constant = true; + } break; case Scanner::OpenParenToken: // function pointers not supported |