diff options
Diffstat (limited to 'sources/shiboken2/ApiExtractor/clangparser/clangbuilder.cpp')
| -rw-r--r-- | sources/shiboken2/ApiExtractor/clangparser/clangbuilder.cpp | 39 |
1 files changed, 5 insertions, 34 deletions
diff --git a/sources/shiboken2/ApiExtractor/clangparser/clangbuilder.cpp b/sources/shiboken2/ApiExtractor/clangparser/clangbuilder.cpp index 263c0a0bb..f00b8dc42 100644 --- a/sources/shiboken2/ApiExtractor/clangparser/clangbuilder.cpp +++ b/sources/shiboken2/ApiExtractor/clangparser/clangbuilder.cpp @@ -574,44 +574,15 @@ void BuilderPrivate::endTemplateTypeAlias(const CXCursor &typeAliasCursor) // CXCursor_EnumConstantDecl, ParmDecl (a = Flag1 | Flag2) QString BuilderPrivate::cursorValueExpression(BaseVisitor *bv, const CXCursor &cursor) const { - BaseVisitor::CodeSnippet snippet = bv->getCodeSnippet(cursor); - const char *equalSign = std::find(snippet.first, snippet.second, '='); - if (equalSign == snippet.second) + const std::string_view snippet = bv->getCodeSnippet(cursor); + auto equalSign = snippet.find('='); + if (equalSign == std::string::npos) return QString(); ++equalSign; - return QString::fromLocal8Bit(equalSign, int(snippet.second - equalSign)).trimmed(); + return QString::fromLocal8Bit(snippet.cbegin() + equalSign, + int(snippet.size() - equalSign)).trimmed(); } -// A hacky reimplementation of clang_EnumDecl_isScoped() for Clang < 5.0 -// which simply checks for a blank-delimited " class " keyword in the enum snippet. - -#define CLANG_NO_ENUMDECL_ISSCOPED \ - (CINDEX_VERSION_MAJOR == 0 && CINDEX_VERSION_MINOR < 43) - -#if CLANG_NO_ENUMDECL_ISSCOPED -static const char *indexOf(const BaseVisitor::CodeSnippet &snippet, const char *needle) -{ - const size_t snippetLength = snippet.first ? size_t(snippet.second - snippet.first) : 0; - const size_t needleLength = strlen(needle); - if (needleLength > snippetLength) - return nullptr; - for (const char *c = snippet.first, *end = snippet.second - needleLength; c < end; ++c) { - if (memcmp(c, needle, needleLength) == 0) - return c; - } - return nullptr; -} - -long clang_EnumDecl_isScoped4(BaseVisitor *bv, const CXCursor &cursor) -{ - BaseVisitor::CodeSnippet snippet = bv->getCodeSnippet(cursor); - const char *classSpec = indexOf(snippet, "class"); - const bool isClass = classSpec && classSpec > snippet.first - && isspace(*(classSpec - 1)) && isspace(*(classSpec + 5)); - return isClass ? 1 : 0; -} -#endif // CLANG_NO_ENUMDECL_ISSCOPED - // Resolve declaration and type of a base class struct TypeDeclaration |
