diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2017-08-02 15:17:01 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2017-08-29 13:46:31 +0000 |
commit | 1a3afc7549238463a35d374eaed96410cf76bfb8 (patch) | |
tree | 2dfd663e0062df7455408d2c516c8091f3f545f7 /sources/shiboken2/ApiExtractor/typesystem.cpp | |
parent | 31872c5c71bf48193744a547b3e2e753f83d5b0b (diff) |
FunctionModification: Make it possible to specify a regular expression
It should make it easier to specify the <array> modifications
for GL functions.
Task-number: PYSIDE-516
Change-Id: Ieb2e540f61785d13ee46a196a18d03b311d308e1
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'sources/shiboken2/ApiExtractor/typesystem.cpp')
-rw-r--r-- | sources/shiboken2/ApiExtractor/typesystem.cpp | 39 |
1 files changed, 33 insertions, 6 deletions
diff --git a/sources/shiboken2/ApiExtractor/typesystem.cpp b/sources/shiboken2/ApiExtractor/typesystem.cpp index 13664c336..0f35e2dd6 100644 --- a/sources/shiboken2/ApiExtractor/typesystem.cpp +++ b/sources/shiboken2/ApiExtractor/typesystem.cpp @@ -811,7 +811,8 @@ bool Handler::startElement(const QStringRef &n, const QXmlStreamAttributes &atts return false; } FunctionModification mod(since); - mod.signature = signature; + if (!mod.setSignature(signature, &m_error)) + return false; mod.renamedToName = attributes[QLatin1String("rename")]; mod.modifiers |= Modification::Rename; m_contextStack.top()->functionMods << mod; @@ -1722,7 +1723,8 @@ bool Handler::startElement(const QStringRef &n, const QXmlStreamAttributes &atts m_contextStack.top()->addedFunctions << func; FunctionModification mod(since); - mod.signature = m_currentSignature; + if (!mod.setSignature(m_currentSignature, &m_error)) + return false; m_contextStack.top()->functionMods << mod; } break; @@ -1747,7 +1749,9 @@ bool Handler::startElement(const QStringRef &n, const QXmlStreamAttributes &atts } FunctionModification mod(since); - m_currentSignature = mod.signature = signature; + if (!mod.setSignature(signature, &m_error)) + return false; + m_currentSignature = signature; QString access = attributes[QLatin1String("access")].toLower(); if (!access.isEmpty()) { @@ -2106,7 +2110,7 @@ FunctionModificationList ComplexTypeEntry::functionModifications(const QString & FunctionModificationList lst; for (int i = 0; i < m_functionMods.count(); ++i) { const FunctionModification &mod = m_functionMods.at(i); - if (mod.signature == signature) + if (mod.matches(signature)) lst << mod; } return lst; @@ -2271,9 +2275,26 @@ QString CodeSnipFragment::code() const return m_code; } +bool FunctionModification::setSignature(const QString &s, QString *errorMessage) +{ + if (s.startsWith(QLatin1Char('^'))) { + m_signaturePattern.setPattern(s); + if (!m_signaturePattern.isValid()) { + if (errorMessage) { + *errorMessage = QLatin1String("Invalid signature pattern: \"") + + s + QLatin1String("\": ") + m_signaturePattern.errorString(); + } + return false; + } + } else { + m_signature = s; + } + return true; +} + QString FunctionModification::toString() const { - QString str = signature + QLatin1String("->"); + QString str = signature() + QLatin1String("->"); if (modifiers & AccessModifierMask) { switch (modifiers & AccessModifierMask) { case Private: str += QLatin1String("private"); break; @@ -2312,8 +2333,14 @@ bool FunctionModification::operator!=(const FunctionModification& other) const bool FunctionModification::operator==(const FunctionModification& other) const { - if (signature != other.signature) + if (m_signature.isEmpty() != other.m_signature.isEmpty()) + return false; + + if (m_signature.isEmpty() + ? m_signaturePattern != other.m_signaturePattern + : m_signature != other.m_signature) { return false; + } if (association != other.association) return false; |