diff options
author | Marcelo Lira <marcelo.lira@openbossa.org> | 2011-02-04 17:12:41 -0300 |
---|---|---|
committer | Hugo Parente Lima <hugo.pl@gmail.com> | 2012-03-09 19:10:14 -0300 |
commit | 7ee3543fd19e49fffaf6f3213cc553ebb3ee636e (patch) | |
tree | 35d067052f993ef4df4def43f8a3045617cf17a1 /typesystem.cpp | |
parent | 517993907bb165daafda75c9c5165985ea454794 (diff) |
Global functions can now be renamed.
This is accomplished via the "rename" attribute on the "function" tag.
An unit test was added and the documentation updated.
Reviewed by Hugo Parente <hugo.lima@openbossa.org>
Reviewed by Luciano Wolf <luciano.wolf@openbossa.org>
Diffstat (limited to 'typesystem.cpp')
-rw-r--r-- | typesystem.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/typesystem.cpp b/typesystem.cpp index 20ee8650f..736627bf4 100644 --- a/typesystem.cpp +++ b/typesystem.cpp @@ -418,6 +418,7 @@ bool Handler::startElement(const QString &, const QString &n, break; case StackElement::FunctionTypeEntry: attributes["signature"] = QString(); + attributes["rename"] = QString(); break; default: { } // nada @@ -432,6 +433,19 @@ bool Handler::startElement(const QString &, const QString &n, if (element->type == StackElement::FunctionTypeEntry) { QString signature = attributes["signature"]; name = signature.left(signature.indexOf('(')).trimmed(); + QString rename = attributes["rename"]; + if (!rename.isEmpty()) { + static QRegExp functionNameRegExp("^[a-zA-Z_][a-zA-Z0-9_]*$"); + if (!functionNameRegExp.exactMatch(rename)) { + m_error = "can not rename '" + signature + "', '" + rename + "' is not a valid function name"; + return false; + } + FunctionModification mod(since); + mod.signature = signature; + mod.renamedToName = attributes["rename"]; + mod.modifiers |= Modification::Rename; + m_contextStack.top()->functionMods << mod; + } } // We need to be able to have duplicate primitive type entries, |