diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2017-06-28 10:12:21 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2017-08-03 06:21:03 +0000 |
commit | 700ebd831f9ee7143c525bb936cd55f2a91adcc7 (patch) | |
tree | b85c51843208c856c6311de3658aced9dda4c94c /sources/shiboken2/ApiExtractor/tests | |
parent | 48fad87c14e6e09e01a66b7b1c4b62778a2268b1 (diff) |
Shiboken: Improve Handling of array types
Change the AbstractMetaType::signature() functions to work with the
nested AbstractMetaType types instead of TypeEntry so that the correct
array signatures appear in the signature of AbstractMetaFunction.
Task-number: PYSIDE-354
Task-number: PYSIDE-516
Change-Id: I90aa11891c95ccdcbae81fb70db4bec0e62f5923
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'sources/shiboken2/ApiExtractor/tests')
-rw-r--r-- | sources/shiboken2/ApiExtractor/tests/testarrayargument.cpp | 36 | ||||
-rw-r--r-- | sources/shiboken2/ApiExtractor/tests/testarrayargument.h | 1 |
2 files changed, 37 insertions, 0 deletions
diff --git a/sources/shiboken2/ApiExtractor/tests/testarrayargument.cpp b/sources/shiboken2/ApiExtractor/tests/testarrayargument.cpp index 4d46d44bc..72d29fb06 100644 --- a/sources/shiboken2/ApiExtractor/tests/testarrayargument.cpp +++ b/sources/shiboken2/ApiExtractor/tests/testarrayargument.cpp @@ -58,6 +58,42 @@ void TestArrayArgument::testArrayArgumentWithSizeDefinedByInteger() QCOMPARE(arg->type()->arrayElementType()->name(), QLatin1String("double")); } +static QString functionMinimalSignature(const AbstractMetaClass *c, const QString &name) +{ + const AbstractMetaFunction *f = c->findFunction(name); + return f ? f->minimalSignature() : QString(); +} + +void TestArrayArgument::testArraySignature() +{ + const char cppCode[] ="\ + struct A {\n\ + void mi1(int arg[5]);\n\ + void mi1c(const int arg[5]);\n\ + void muc2(unsigned char *arg[2][3]);\n\ + void mc2c(const char *arg[5][6]);\n\ + };\n"; + const char xmlCode[] = "\ + <typesystem package='Foo'>\n\ + <primitive-type name='char'/>\n\ + <primitive-type name='unsigned char'/>\n\ + <primitive-type name='int'/>\n\ + <object-type name='A'/>\n\ + </typesystem>\n"; + + QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode, false)); + QVERIFY(!builder.isNull()); + const AbstractMetaClass *classA = AbstractMetaClass::findClass(builder->classes(), QLatin1String("A")); + QCOMPARE(functionMinimalSignature(classA, QLatin1String("mi1")), + QLatin1String("mi1(int[5])")); + QCOMPARE(functionMinimalSignature(classA, QLatin1String("mi1c")), + QLatin1String("mi1c(const int[5])")); + QCOMPARE(functionMinimalSignature(classA, QLatin1String("muc2")), + QLatin1String("muc2(unsigned char*[2][3])")); + QCOMPARE(functionMinimalSignature(classA, QLatin1String("mc2c")), + QLatin1String("mc2c(const char*[5][6])")); +} + void TestArrayArgument::testArrayArgumentWithSizeDefinedByEnumValue() { const char* cppCode ="\ diff --git a/sources/shiboken2/ApiExtractor/tests/testarrayargument.h b/sources/shiboken2/ApiExtractor/tests/testarrayargument.h index b50232ef4..45ca8e655 100644 --- a/sources/shiboken2/ApiExtractor/tests/testarrayargument.h +++ b/sources/shiboken2/ApiExtractor/tests/testarrayargument.h @@ -35,6 +35,7 @@ class TestArrayArgument : public QObject Q_OBJECT private slots: void testArrayArgumentWithSizeDefinedByInteger(); + void testArraySignature(); void testArrayArgumentWithSizeDefinedByEnumValue(); void testArrayArgumentWithSizeDefinedByEnumValueFromGlobalEnum(); }; |