diff options
Diffstat (limited to 'src/qdoc/clangcodeparser.cpp')
-rw-r--r-- | src/qdoc/clangcodeparser.cpp | 46 |
1 files changed, 30 insertions, 16 deletions
diff --git a/src/qdoc/clangcodeparser.cpp b/src/qdoc/clangcodeparser.cpp index 46fb095e2..a25a8533d 100644 --- a/src/qdoc/clangcodeparser.cpp +++ b/src/qdoc/clangcodeparser.cpp @@ -1005,32 +1005,44 @@ bool ClangVisitor::parseProperty(const QString &spelling, const Location &loc) QString signature = spelling.mid(lpIdx + 1, rpIdx - lpIdx - 1); signature = signature.simplified(); - - QString type; - QString name; QStringList parts = signature.split(QChar(' '), Qt::SkipEmptyParts); - if (parts.size() < 2) - return false; - if (parts.first() == QLatin1String("enum")) - parts.removeFirst(); // QTBUG-80027 - type = parts.takeFirst(); - if (type == QLatin1String("const") && !parts.empty()) - type += " " + parts.takeFirst(); + static const QStringList attrs = + QStringList() << "READ" << "MEMBER" << "WRITE" + << "NOTIFY" << "CONSTANT" << "FINAL" + << "REQUIRED" << "BINDABLE" << "DESIGNABLE" + << "RESET" << "REVISION" << "SCRIPTABLE" + << "STORED" << "USER"; + + // Find the location of the first attribute. All preceding parts + // represent the property type + name. + auto it = std::find_if(parts.cbegin(), parts.cend(), + [](const QString &attr) -> bool { + return attrs.contains(attr); + }); - if (!parts.empty()) - name = parts.takeFirst(); - else + if (it == parts.cend() || std::distance(parts.cbegin(), it) < 2) return false; - if (name.front() == QChar('*')) { - type.append(QChar('*')); + QStringList typeParts; + std::copy(parts.cbegin(), it, std::back_inserter(typeParts)); + parts.erase(parts.cbegin(), it); + QString name = typeParts.takeLast(); + + // Move the pointer operator(s) from name to type + while (!name.isEmpty() && name.front() == QChar('*')) { + typeParts.last().push_back(name.front()); name.remove(0, 1); } + + // Need at least READ or MEMBER + getter/member name + if (parts.size() < 2 || name.isEmpty()) + return false; + auto *property = new PropertyNode(parent_, name); property->setAccess(Access::Public); property->setLocation(loc); - property->setDataType(type); + property->setDataType(typeParts.join(QChar(' '))); int i = 0; while (i < parts.size()) { @@ -1048,6 +1060,8 @@ bool ClangVisitor::parseProperty(const QString &spelling, const Location &loc) } else if (key == "WRITE") { qdb_->addPropertyFunction(property, value, PropertyNode::Setter); property->setWritable(true); + } else if (key == "MEMBER") { + property->setWritable(true); } else if (key == "STORED") { property->setStored(value.toLower() == "true"); } else if (key == "DESIGNABLE") { |