aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken2
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2017-06-30 13:37:51 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2017-08-03 06:21:06 +0000
commit8c699313c85419dc73db35dbdefc844d88a039c6 (patch)
tree53e035e8ae21a7a02657e3a3f6ef30e2b97959e7 /sources/shiboken2
parent700ebd831f9ee7143c525bb936cd55f2a91adcc7 (diff)
Shiboken: No longer change arrays[] to pointer types
In AbstractMetaBuilder, no longer change array types like "int[]" to "int*". Task-number: PYSIDE-354 Task-number: PYSIDE-516 Change-Id: Ia9e15ae3fca895bf179275eb31a94323d91f4941 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'sources/shiboken2')
-rw-r--r--sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp57
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testarrayargument.cpp3
-rw-r--r--sources/shiboken2/generator/shiboken2/shibokengenerator.cpp8
-rw-r--r--sources/shiboken2/tests/samplebinding/typesystem_sample.xml4
4 files changed, 35 insertions, 37 deletions
diff --git a/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp b/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp
index afdc84e46..6032b788e 100644
--- a/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp
+++ b/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp
@@ -2474,45 +2474,36 @@ AbstractMetaType *AbstractMetaBuilderPrivate::translateType(const TypeInfo &_typ
return 0;
}
- // 2. Handle pointers specified as arrays with unspecified size
- bool arrayOfUnspecifiedSize = false;
if (typeInfo.arrays.size() > 0) {
- arrayOfUnspecifiedSize = true;
- for (int i = 0; i < typeInfo.arrays.size(); ++i)
- arrayOfUnspecifiedSize = arrayOfUnspecifiedSize && typeInfo.arrays.at(i).isEmpty();
-
- if (!arrayOfUnspecifiedSize) {
- TypeInfo newInfo;
- //newInfo.setArguments(typei.arguments());
- newInfo.setIndirections(typei.indirections());
- newInfo.setConstant(typei.isConstant());
- newInfo.setFunctionPointer(typei.isFunctionPointer());
- newInfo.setQualifiedName(typei.qualifiedName());
- newInfo.setReferenceType(typei.referenceType());
- newInfo.setVolatile(typei.isVolatile());
-
- AbstractMetaType* elementType = translateType(newInfo, ok);
- if (!(*ok))
- return 0;
+ TypeInfo newInfo;
+ //newInfo.setArguments(typei.arguments());
+ newInfo.setIndirections(typei.indirections());
+ newInfo.setConstant(typei.isConstant());
+ newInfo.setFunctionPointer(typei.isFunctionPointer());
+ newInfo.setQualifiedName(typei.qualifiedName());
+ newInfo.setReferenceType(typei.referenceType());
+ newInfo.setVolatile(typei.isVolatile());
+
+ AbstractMetaType* elementType = translateType(newInfo, ok);
+ if (!(*ok))
+ return 0;
- for (int i = typeInfo.arrays.size() - 1; i >= 0; --i) {
- QString s = typeInfo.arrays.at(i);
+ for (int i = typeInfo.arrays.size() - 1; i >= 0; --i) {
+ AbstractMetaType *arrayType = q->createMetaType();
+ arrayType->setArrayElementType(elementType);
+ if (!typeInfo.arrays.at(i).isEmpty()) {
bool _ok;
- int elems = findOutValueFromString(s, _ok);
-
- AbstractMetaType *arrayType = q->createMetaType();
- arrayType->setArrayElementCount(elems);
- arrayType->setArrayElementType(elementType);
- arrayType->setTypeEntry(new ArrayTypeEntry(elementType->typeEntry() , elementType->typeEntry()->version()));
- decideUsagePattern(arrayType);
-
- elementType = arrayType;
+ const int elems = findOutValueFromString(typeInfo.arrays.at(i), _ok);
+ if (_ok)
+ arrayType->setArrayElementCount(elems);
}
+ arrayType->setTypeEntry(new ArrayTypeEntry(elementType->typeEntry() , elementType->typeEntry()->version()));
+ decideUsagePattern(arrayType);
- return elementType;
- } else {
- typeInfo.indirections += typeInfo.arrays.size();
+ elementType = arrayType;
}
+
+ return elementType;
}
QStringList qualifierList = typeInfo.qualified_name;
diff --git a/sources/shiboken2/ApiExtractor/tests/testarrayargument.cpp b/sources/shiboken2/ApiExtractor/tests/testarrayargument.cpp
index 72d29fb06..408c51461 100644
--- a/sources/shiboken2/ApiExtractor/tests/testarrayargument.cpp
+++ b/sources/shiboken2/ApiExtractor/tests/testarrayargument.cpp
@@ -70,6 +70,7 @@ void TestArrayArgument::testArraySignature()
struct A {\n\
void mi1(int arg[5]);\n\
void mi1c(const int arg[5]);\n\
+ void mi1cu(const int arg[]);\n\
void muc2(unsigned char *arg[2][3]);\n\
void mc2c(const char *arg[5][6]);\n\
};\n";
@@ -88,6 +89,8 @@ void TestArrayArgument::testArraySignature()
QLatin1String("mi1(int[5])"));
QCOMPARE(functionMinimalSignature(classA, QLatin1String("mi1c")),
QLatin1String("mi1c(const int[5])"));
+ QCOMPARE(functionMinimalSignature(classA, QLatin1String("mi1cu")),
+ QLatin1String("mi1cu(const int[])"));
QCOMPARE(functionMinimalSignature(classA, QLatin1String("muc2")),
QLatin1String("muc2(unsigned char*[2][3])"));
QCOMPARE(functionMinimalSignature(classA, QLatin1String("mc2c")),
diff --git a/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp b/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp
index 2693ecf40..8ec4474ad 100644
--- a/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp
+++ b/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp
@@ -1330,8 +1330,12 @@ QString ShibokenGenerator::argumentString(const AbstractMetaFunction *func,
arg = modified_type.replace(QLatin1Char('$'), QLatin1Char('.'));
if (!(options & Generator::SkipName)) {
- arg += QLatin1Char(' ');
- arg += argument->name();
+ // "int a", "int a[]"
+ const int arrayPos = arg.indexOf(QLatin1Char('['));
+ if (arrayPos != -1)
+ arg.insert(arrayPos, QLatin1Char(' ') + argument->name());
+ else
+ arg.append(QLatin1Char(' ') + argument->name());
}
if ((options & Generator::SkipDefaultValues) != Generator::SkipDefaultValues &&
diff --git a/sources/shiboken2/tests/samplebinding/typesystem_sample.xml b/sources/shiboken2/tests/samplebinding/typesystem_sample.xml
index 089f835fc..0b5bd0d38 100644
--- a/sources/shiboken2/tests/samplebinding/typesystem_sample.xml
+++ b/sources/shiboken2/tests/samplebinding/typesystem_sample.xml
@@ -1159,7 +1159,7 @@
<!-- change the name of this virtual method -->
<modify-function signature="className()" rename="name"/>
- <modify-function signature="sumPointArray(int, const Point*)">
+ <modify-function signature="sumPointArray(int, const Point[])">
<modify-argument index="1">
<remove-argument/>
<conversion-rule class="native">
@@ -1950,7 +1950,7 @@
<define-ownership owner="c++"/>
</modify-argument>
</modify-function>
- <modify-function signature="acceptSequence(const char**)">
+ <modify-function signature="acceptSequence(const char*[])">
<modify-argument index="1">
<replace-type modified-type="PySequence" />
<conversion-rule class="native">