From 6f5f279b49756b1f848a6d85fde6bcae5eef4937 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 4 Jul 2018 12:22:54 +0200 Subject: 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 Reviewed-by: Alexandru Croitor --- sources/shiboken2/ApiExtractor/typeparser.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'sources/shiboken2/ApiExtractor/typeparser.cpp') 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 -- cgit v1.2.3