aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2017-06-28 10:12:21 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2017-08-03 06:21:03 +0000
commit700ebd831f9ee7143c525bb936cd55f2a91adcc7 (patch)
treeb85c51843208c856c6311de3658aced9dda4c94c
parent48fad87c14e6e09e01a66b7b1c4b62778a2268b1 (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>
-rw-r--r--sources/pyside2/PySide2/QtMultimedia/typesystem_multimedia_common.xml2
-rw-r--r--sources/pyside2/PySide2/QtOpenGL/typesystem_opengl.xml12
-rw-r--r--sources/pyside2/PySide2/QtTest/typesystem_test.xml1
-rw-r--r--sources/shiboken2/ApiExtractor/abstractmetalang.cpp23
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testarrayargument.cpp36
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testarrayargument.h1
-rw-r--r--sources/shiboken2/generator/generator.cpp9
7 files changed, 76 insertions, 8 deletions
diff --git a/sources/pyside2/PySide2/QtMultimedia/typesystem_multimedia_common.xml b/sources/pyside2/PySide2/QtMultimedia/typesystem_multimedia_common.xml
index 9565b4334..f708d46ab 100644
--- a/sources/pyside2/PySide2/QtMultimedia/typesystem_multimedia_common.xml
+++ b/sources/pyside2/PySide2/QtMultimedia/typesystem_multimedia_common.xml
@@ -77,7 +77,7 @@
</modify-function>
-->
<!-- TODO: PYSIDE-354, arrays are not supported -->
- <modify-function signature="mapPlanes(QAbstractVideoBuffer::MapMode,int*,Array,Array)" remove="all"/>
+ <modify-function signature="mapPlanes(QAbstractVideoBuffer::MapMode,int*,int[4],uchar*[4])" remove="all"/>
</object-type>
<object-type name="QAbstractVideoSurface">
<enum-type name="Error"/>
diff --git a/sources/pyside2/PySide2/QtOpenGL/typesystem_opengl.xml b/sources/pyside2/PySide2/QtOpenGL/typesystem_opengl.xml
index d5c701b6f..8dea5d67c 100644
--- a/sources/pyside2/PySide2/QtOpenGL/typesystem_opengl.xml
+++ b/sources/pyside2/PySide2/QtOpenGL/typesystem_opengl.xml
@@ -59,6 +59,16 @@
<rejection class="QGLColormap::QGLColormapData"/>
<rejection class="QGLContext" field-name="currentCtx"/>
+ <rejection class="^QGL.*$" argument-type="^GLboolean( const)?\*$"/>
+ <rejection class="^QGL.*$" argument-type="^GLchar( const)?\*$"/>
+ <rejection class="^QGL.*$" argument-type="GLchar *const const*"/>
+ <rejection class="^QGL.*$" argument-type="^GLenum( const)?\*$"/>
+ <rejection class="^QGL.*$" argument-type="^GLfloat( const)?\*$"/>
+ <rejection class="^QGL.*$" argument-type="^GLfloat( const)?\[.*$"/>
+ <rejection class="^QGL.*$" argument-type="^GLdouble( const)?\*$"/>
+ <rejection class="^QGL.*$" argument-type="GLintptr"/>
+ <rejection class="^QGL.*$" argument-type="^GLint64( const)?\*$"/>
+ <rejection class="^QGL.*$" argument-type="^GLsizei( const)?\*$"/>
<namespace-type name="QGL">
<enum-type name="FormatOption" flags="FormatOptions" force-integer="yes"/>
@@ -681,8 +691,6 @@
<!-- ### -->
<!-- ### Use QMatrixZxY overloads -->
- <modify-function signature="setUniformValue(int,Array)" remove="all" />
- <modify-function signature="setUniformValue(const char*,Array)" remove="all" />
<modify-function signature="setAttributeValue(int,const GLfloat*,int,int)" remove="all" />
<modify-function signature="setAttributeValue(const char*,const GLfloat*,int,int)" remove="all" />
<modify-function signature="setAttributeArray(int, GLenum, const void*, int, int)" remove="all" since="4.7" />
diff --git a/sources/pyside2/PySide2/QtTest/typesystem_test.xml b/sources/pyside2/PySide2/QtTest/typesystem_test.xml
index 61a3ee850..2e2d5a99d 100644
--- a/sources/pyside2/PySide2/QtTest/typesystem_test.xml
+++ b/sources/pyside2/PySide2/QtTest/typesystem_test.xml
@@ -51,6 +51,7 @@
<rejection class="QTest" function-name="qCompare&lt;double,qreal&gt;"/>
<rejection class="QTest" function-name="qCompare&lt;qreal,double&gt;"/>
<rejection class="QTest" function-name="qCompare"/>
+ <rejection class="QTest" function-name="qInit"/>
<rejection class="QTest" function-name="qVerify"/>
<rejection class="QTest" function-name="qSleep"/>
<rejection class="QTest" function-name="toHexRepresentation"/>
diff --git a/sources/shiboken2/ApiExtractor/abstractmetalang.cpp b/sources/shiboken2/ApiExtractor/abstractmetalang.cpp
index 482efdaa0..0c4e4a8bf 100644
--- a/sources/shiboken2/ApiExtractor/abstractmetalang.cpp
+++ b/sources/shiboken2/ApiExtractor/abstractmetalang.cpp
@@ -91,7 +91,7 @@ QDebug operator<<(QDebug d, const AbstractMetaVariable *av)
AbstractMetaType::AbstractMetaType()
:m_typeEntry(0),
- m_arrayElementCount(0),
+ m_arrayElementCount(-1),
m_arrayElementType(0),
m_originalTemplateType(0),
m_pattern(InvalidPattern),
@@ -2545,13 +2545,32 @@ void AbstractMetaClass::fixFunctions()
setFunctions(funcs);
}
+static inline QString formatArraySize(int e)
+{
+ QString result;
+ result += QLatin1Char('[');
+ if (e >= 0)
+ result += QString::number(e);
+ result += QLatin1Char(']');
+ return result;
+}
QString AbstractMetaType::formatSignature(bool minimal) const
{
QString result;
if (isConstant())
result += QLatin1String("const ");
- result += typeEntry()->qualifiedCppName();
+ if (isArray()) {
+ // Build nested array dimensions a[2][3] in correct order
+ result += m_arrayElementType->minimalSignature();
+ const int arrayPos = result.indexOf(QLatin1Char('['));
+ if (arrayPos != -1)
+ result.insert(arrayPos, formatArraySize(m_arrayElementCount));
+ else
+ result.append(formatArraySize(m_arrayElementCount));
+ } else {
+ result += typeEntry()->qualifiedCppName();
+ }
if (!m_instantiations.isEmpty()) {
result += QLatin1Char('<');
if (minimal)
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();
};
diff --git a/sources/shiboken2/generator/generator.cpp b/sources/shiboken2/generator/generator.cpp
index f60b195f2..a8e8735bb 100644
--- a/sources/shiboken2/generator/generator.cpp
+++ b/sources/shiboken2/generator/generator.cpp
@@ -515,9 +515,12 @@ bool Generator::isVoidPointer(const AbstractMetaType* type)
QString Generator::getFullTypeName(const TypeEntry* type) const
{
- return type->isCppPrimitive()
- ? type->qualifiedCppName()
- : (QLatin1String("::") + type->qualifiedCppName());
+ QString result = type->qualifiedCppName();
+ if (type->isArray())
+ type = static_cast<const ArrayTypeEntry *>(type)->nestedTypeEntry();
+ if (!type->isCppPrimitive())
+ result.prepend(QLatin1String("::"));
+ return result;
}
QString Generator::getFullTypeName(const AbstractMetaType* type) const