summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Smith <martin.smith@qt.io>2017-08-30 16:00:12 +0200
committerMartin Smith <martin.smith@qt.io>2017-09-06 15:18:06 +0000
commitdf3661dc5493191979d71b0b5610533234890a77 (patch)
tree0a47e1eefacbd12097bd9d492fbd4f66c1b616b6 /src
parent99dfabc44a46be0a1a16600435a911a4816afc8c (diff)
downloadqttools-df3661dc5493191979d71b0b5610533234890a77.tar.gz
qdoc: Remove uses of QRegular Expression
This change replaces two uses of QRegularExpression with a simple ad hoc parser. qdoc is not allowed to use QRegularExpression because it is not in the bootstrap library. Task-number: QTBUG-62845 Change-Id: Icfaca2181ff1879f02d111626a85fb3da758c731 Reviewed-by: Martin Smith <martin.smith@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/qdoc/clangcodeparser.cpp113
1 files changed, 58 insertions, 55 deletions
diff --git a/src/qdoc/clangcodeparser.cpp b/src/qdoc/clangcodeparser.cpp
index 4cf678ee6..4b455414f 100644
--- a/src/qdoc/clangcodeparser.cpp
+++ b/src/qdoc/clangcodeparser.cpp
@@ -45,7 +45,6 @@
#include <qdebug.h>
#include <qscopedvaluerollback.h>
#include <qelapsedtimer.h>
-#include <qregularexpression.h>
#include <qtemporarydir.h>
#include "generator.h"
@@ -683,71 +682,75 @@ void ClangVisitor::readParameterNamesAndAttributes(FunctionNode* fn, CXCursor cu
void ClangVisitor::parseProperty(const QString& spelling, const Location& loc)
{
- const QLatin1String metaKeyword("READ|WRITE|CONSTANT|FINAL|REVISION|MEMBER|RESET|SCRIPTABLE|STORED|WRITE|DESIGNABLE|EDITABLE|NOTIFY|USER");
- static QRegularExpression typeNameRx(QLatin1String("^[^(]*\\((?<type>.*?)\\s*(?<name>[a-zA-Z0-9_]+)\\s+(")
- + metaKeyword + QLatin1String(")\\s"));
- auto match = typeNameRx.match(spelling);
- if (!match.hasMatch()) {
- qWarning() << "(qdoc) ERROR PARSING " << spelling;
+ int lpIdx = spelling.indexOf(QChar('('));
+ int rpIdx = spelling.lastIndexOf(QChar(')'));
+ if (lpIdx <= 0 || rpIdx <= lpIdx)
return;
+ QString signature = spelling.mid(lpIdx + 1, rpIdx - lpIdx - 1);
+ signature = signature.simplified();
+ QStringList part = signature.split(QChar(' '));
+ if (part.size() < 2)
+ return;
+ QString type = part.at(0);
+ QString name = part.at(1);
+ if (name.at(0) == QChar('*')) {
+ type.append(QChar('*'));
+ name.remove(0,1);
}
- auto type = match.captured(QStringLiteral("type"));
- auto name = match.captured(QStringLiteral("name"));
auto *property = new PropertyNode(parent_, name);
property->setAccess(Node::Public);
property->setLocation(loc);
property->setDataType(type);
-
- static QRegularExpression nextKeyword(QLatin1String("\\s(?<key>") + metaKeyword
- + QLatin1String(")\\s+(?<value>.*?)(\\s*\\)$|\\s+(") + metaKeyword + QLatin1String("))"));
- int pos = match.capturedEnd(QStringLiteral("name"));
- while ((match = nextKeyword.match(spelling, pos)).hasMatch()) {
- pos = match.capturedEnd(QStringLiteral("value"));
- auto key = match.capturedRef(QStringLiteral("key"));
- auto value = match.captured(QStringLiteral("value"));
+ int i = 2;
+ while (i < part.size()) {
+ QString key = part.at(i++);
// Keywords with no associated values
if (key == "CONSTANT") {
property->setConstant();
} else if (key == "FINAL") {
property->setFinal();
- } else if (key == "READ") {
- qdb_->addPropertyFunction(property, value, PropertyNode::Getter);
- } else if (key == "WRITE") {
- qdb_->addPropertyFunction(property, value, PropertyNode::Setter);
- property->setWritable(true);
- } else if (key == "STORED") {
- property->setStored(value.toLower() == "true");
- } else if (key == "DESIGNABLE") {
- QString v = value.toLower();
- if (v == "true")
- property->setDesignable(true);
- else if (v == "false")
- property->setDesignable(false);
- else {
- property->setDesignable(false);
- property->setRuntimeDesFunc(value);
- }
- } else if (key == "RESET") {
- qdb_->addPropertyFunction(property, value, PropertyNode::Resetter);
- } else if (key == "NOTIFY") {
- qdb_->addPropertyFunction(property, value, PropertyNode::Notifier);
- } else if (key == "REVISION") {
- int revision;
- bool ok;
- revision = value.toInt(&ok);
- if (ok)
- property->setRevision(revision);
- else
- loc.warning(ClangCodeParser::tr("Invalid revision number: %1").arg(value));
- } else if (key == "SCRIPTABLE") {
- QString v = value.toLower();
- if (v == "true")
- property->setScriptable(true);
- else if (v == "false")
- property->setScriptable(false);
- else {
- property->setScriptable(false);
- property->setRuntimeScrFunc(value);
+ }
+ if (i < part.size()) {
+ QString value = part.at(i++);
+ if (key == "READ") {
+ qdb_->addPropertyFunction(property, value, PropertyNode::Getter);
+ } else if (key == "WRITE") {
+ qdb_->addPropertyFunction(property, value, PropertyNode::Setter);
+ property->setWritable(true);
+ } else if (key == "STORED") {
+ property->setStored(value.toLower() == "true");
+ } else if (key == "DESIGNABLE") {
+ QString v = value.toLower();
+ if (v == "true")
+ property->setDesignable(true);
+ else if (v == "false")
+ property->setDesignable(false);
+ else {
+ property->setDesignable(false);
+ property->setRuntimeDesFunc(value);
+ }
+ } else if (key == "RESET") {
+ qdb_->addPropertyFunction(property, value, PropertyNode::Resetter);
+ } else if (key == "NOTIFY") {
+ qdb_->addPropertyFunction(property, value, PropertyNode::Notifier);
+ } else if (key == "REVISION") {
+ int revision;
+ bool ok;
+ revision = value.toInt(&ok);
+ if (ok)
+ property->setRevision(revision);
+ else
+ loc.warning(ClangCodeParser::tr("Invalid revision number: %1").arg(value));
+ } else if (key == "SCRIPTABLE") {
+ QString v = value.toLower();
+ if (v == "true")
+ property->setScriptable(true);
+ else if (v == "false")
+ property->setScriptable(false);
+ else {
+ property->setScriptable(false);
+ property->setRuntimeScrFunc(value);
+ }
}
}
}