diff options
author | Olivier Goffart <ogoffart@woboq.com> | 2013-03-04 16:52:12 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-02-14 09:42:53 +0100 |
commit | 2b26f801b5b49e2f354da0b67070917d25d5917d (patch) | |
tree | c3542211d7827e2d05cbf18281af00c16d99e89b /src/corelib/kernel/qmetaobject_moc_p.h | |
parent | 8e261ac756132baeb857fb15013cde126ffa22cc (diff) |
Make parsing of template arguments more robust.
At first, my goal was just to fix Moc::until() to parse properly
template arguments containing expressions containing > or >>
such as Foo<(8>>2)>
But with the test, I realized that normalizeType also requires change
not to split the > > too much.
And QMetaObjectPrivate::decodeMethodSignature should not interpret
the ) within the template parameter as the end of the function.
Change-Id: Ia9d3a2a786368aeda1edcf66280d70f64cf05070
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/corelib/kernel/qmetaobject_moc_p.h')
-rw-r--r-- | src/corelib/kernel/qmetaobject_moc_p.h | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/src/corelib/kernel/qmetaobject_moc_p.h b/src/corelib/kernel/qmetaobject_moc_p.h index c791f017d4..d26cd54e5d 100644 --- a/src/corelib/kernel/qmetaobject_moc_p.h +++ b/src/corelib/kernel/qmetaobject_moc_p.h @@ -155,21 +155,28 @@ static QByteArray normalizeTypeInternal(const char *t, const char *e, bool fixSc //template recursion const char* tt = t; int templdepth = 1; + int scopeDepth = 0; while (t != e) { c = *t++; - if (c == '<') - ++templdepth; - if (c == '>') - --templdepth; - if (templdepth == 0 || (templdepth == 1 && c == ',')) { - result += normalizeTypeInternal(tt, t-1, fixScope, false); - result += c; - if (templdepth == 0) { - if (*t == '>') - result += ' '; // avoid >> - break; + if (c == '{' || c == '(' || c == '[') + ++scopeDepth; + if (c == '}' || c == ')' || c == ']') + --scopeDepth; + if (scopeDepth == 0) { + if (c == '<') + ++templdepth; + if (c == '>') + --templdepth; + if (templdepth == 0 || (templdepth == 1 && c == ',')) { + result += normalizeTypeInternal(tt, t-1, fixScope, false); + result += c; + if (templdepth == 0) { + if (*t == '>') + result += ' '; // avoid >> + break; + } + tt = t; } - tt = t; } } } |