summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcelo Lira <marcelo.lira@openbossa.org>2011-12-22 14:23:22 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-09 19:10:21 -0300
commitab94961a639cc7b364fcb1e3f68531792c312990 (patch)
treedab719ae2054d237bbb465757e340d1d43c50304
parent3fed11c07c214e4c396f2ecfd19236ac1dcedb07 (diff)
Function signatures including return types are reported as invalid.
This fixes bug #1101: "Report invalid function signatures in typesystem" http://bugs.pyside.org/show_bug.cgi?id=1101
-rw-r--r--typesystem.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/typesystem.cpp b/typesystem.cpp
index bbf7e86a..8808e531 100644
--- a/typesystem.cpp
+++ b/typesystem.cpp
@@ -436,6 +436,21 @@ static QString getNamePrefix(StackElement* element)
return names.join(".");
}
+// Returns empty string if there's no error.
+static QString checkSignatureError(const QString& signature, const QString& tag)
+{
+ QString funcName = signature.left(signature.indexOf('(')).trimmed();
+ static QRegExp whiteSpace("\\s");
+ if (!funcName.startsWith("operator ") && funcName.contains(whiteSpace)) {
+ return QString("Error in <%1> tag signature attribute '%2'.\n"
+ "White spaces aren't allowed in function names, "
+ "and return types should not be part of the signature.")
+ .arg(tag)
+ .arg(signature);
+ }
+ return QString();
+}
+
bool Handler::startElement(const QString &, const QString &n,
const QString &, const QXmlAttributes &atts)
{
@@ -562,6 +577,11 @@ bool Handler::startElement(const QString &, const QString &n,
if (element->type == StackElement::FunctionTypeEntry) {
QString signature = attributes["signature"];
name = signature.left(signature.indexOf('(')).trimmed();
+ QString errorString = checkSignatureError(signature, "function");
+ if (!errorString.isEmpty()) {
+ m_error = errorString;
+ return false;
+ }
QString rename = attributes["rename"];
if (!rename.isEmpty()) {
static QRegExp functionNameRegExp("^[a-zA-Z_][a-zA-Z0-9_]*$");
@@ -1457,6 +1477,12 @@ bool Handler::startElement(const QString &, const QString &n,
return false;
}
+ QString errorString = checkSignatureError(signature, "add-function");
+ if (!errorString.isEmpty()) {
+ m_error = errorString;
+ return false;
+ }
+
AddedFunction func(signature, attributes["return-type"], since);
func.setStatic(attributes["static"] == "yes");
if (!signature.contains("("))
@@ -1496,6 +1522,12 @@ bool Handler::startElement(const QString &, const QString &n,
return false;
}
+ QString errorString = checkSignatureError(signature, "modify-function");
+ if (!errorString.isEmpty()) {
+ m_error = errorString;
+ return false;
+ }
+
FunctionModification mod(since);
m_currentSignature = mod.signature = signature;