diff options
author | Marcelo Lira <marcelo.lira@openbossa.org> | 2010-03-22 10:31:34 -0300 |
---|---|---|
committer | Hugo Parente Lima <hugo.pl@gmail.com> | 2012-03-09 19:09:57 -0300 |
commit | e8f37f7ee2b7ea6a7d25732dbd335687b5493ec3 (patch) | |
tree | 19f7164efa01f91628ac9966b082c596efb46afa | |
parent | 60c0865c6af16c91244123fe6f2c328f5fc912a4 (diff) |
Meta type minimal signature should place reference symbol after pointer symbols.
The minimalSignature method was placing '&' before '*'. For example,
the signature "foo(Bar*&)" was becoming "foo(Bar&*)".
An unit test was added to verify AbstractMetaType::minimalSignature().
Reviewed by Hugo Parente <hugo.lima@openbossa.org>
Reviewed by Anderson Lizardo <anderson.lizardo@openbossa.org>
-rw-r--r-- | abstractmetalang.cpp | 4 | ||||
-rw-r--r-- | tests/CMakeLists.txt | 1 | ||||
-rw-r--r-- | tests/testreferencetopointer.cpp | 53 | ||||
-rw-r--r-- | tests/testreferencetopointer.h | 36 |
4 files changed, 92 insertions, 2 deletions
diff --git a/abstractmetalang.cpp b/abstractmetalang.cpp index 73f617637..b9a15d426 100644 --- a/abstractmetalang.cpp +++ b/abstractmetalang.cpp @@ -2119,10 +2119,10 @@ QString AbstractMetaType::minimalSignature() const minimalSignature += " >"; } - if (isReference()) - minimalSignature += "&"; for (int j = 0; j < indirections(); ++j) minimalSignature += "*"; + if (isReference()) + minimalSignature += "&"; return minimalSignature; } diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 10cce3fc7..61f40ce2e 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -20,6 +20,7 @@ declare_test(testmodifydocumentation) declare_test(testmodifyfunction) declare_test(testmultipleinheritance) declare_test(testrefcounttag) +declare_test(testreferencetopointer) declare_test(testremoveimplconv) declare_test(testreverseoperators) declare_test(testtoposort) diff --git a/tests/testreferencetopointer.cpp b/tests/testreferencetopointer.cpp new file mode 100644 index 000000000..cd4b63b0a --- /dev/null +++ b/tests/testreferencetopointer.cpp @@ -0,0 +1,53 @@ +/* +* This file is part of the API Extractor project. +* +* Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +* +* Contact: PySide team <contact@pyside.org> +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* version 2 as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, but +* WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA +* 02110-1301 USA +* +*/ + +#include "testreferencetopointer.h" +#include <QtTest/QTest> +#include "testutil.h" + +void TestReferenceToPointer::testReferenceToPointerArgument() +{ + const char* cppCode ="\ + struct A {};\ + struct B {\ + void dummy(A*&);\ + };\ + "; + const char* xmlCode = "\ + <typesystem package=\"Foo\"> \ + <object-type name='A' /> \ + <object-type name='B' /> \ + </typesystem>"; + TestUtil t(cppCode, xmlCode, false); + AbstractMetaClassList classes = t.builder()->classes(); + AbstractMetaClass* classB = classes.findClass("B"); + QVERIFY(classB); + const AbstractMetaFunction* func = classB->findFunction("dummy"); + QVERIFY(func); + QCOMPARE(func->arguments().first()->type()->minimalSignature(), QString("A*&")); +} + +QTEST_APPLESS_MAIN(TestReferenceToPointer) + +#include "testreferencetopointer.moc" + diff --git a/tests/testreferencetopointer.h b/tests/testreferencetopointer.h new file mode 100644 index 000000000..b682285b5 --- /dev/null +++ b/tests/testreferencetopointer.h @@ -0,0 +1,36 @@ +/* +* This file is part of the API Extractor project. +* +* Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +* +* Contact: PySide team <contact@pyside.org> +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* version 2 as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, but +* WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA +* 02110-1301 USA +* +*/ + +#ifndef TESTREFERENCETOPOINTER_H +#define TESTREFERENCETOPOINTER_H + +#include <QObject> + +class TestReferenceToPointer : public QObject +{ + Q_OBJECT + private slots: + void testReferenceToPointerArgument(); +}; + +#endif |