aboutsummaryrefslogtreecommitdiffstats
path: root/README_from-5.4-to-5.5.md
blob: dbc55e38d8b1d098390de9a90d84130d9500ede3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398

Migration from Qt5.4 to Qt5.5
-----------------------------

This is an example session when migrating from Qt5.4.2 to Qt5.5.0 .

2015-09-04

A first build attempt results in the following shiboken warnings on QtCore:

```
Generating class model...                    [WARNING]
    enum 'QSysInfo::WinVersion' does not have a type entry or is not an enum
    enum 'QSysInfo::MacVersion' does not have a type entry or is not an enum
    enum 'QAbstractTransition::TransitionType' does not have a type entry or is not an enum
    Unable to decide type of property: 'TransitionType' in class 'QAbstractTransition'
    

Generating enum model...                     [WARNING]
    enum 'InterfaceType' does not have a type entry or is not an enum
    enum 'Role' does not have a type entry or is not an enum
    enum 'TextBoundaryType' does not have a type entry or is not an enum
    enum 'RelationFlag' does not have a type entry or is not an enum
    

Generating namespace model...                [WARNING]
    enum 'Qt::TabFocusBehavior' does not have a type entry or is not an enum
    enum 'Qt::ItemSelectionOperation' does not have a type entry or is not an enum
    

Resolving typedefs...                        [OK]
Fixing class inheritance...                  [WARNING]
    skipping field 'QSysInfo::WindowsVersion' with unmatched type 'QSysInfo::WinVersion'
    skipping field 'QSysInfo::MacintoshVersion' with unmatched type 'QSysInfo::MacVersion'
    

Detecting inconsistencies in class model...  [OK]
[OK]
    enum 'QAbstractAnimation::DeletionPolicy' is specified in typesystem, but not declared
    enum 'QAbstractAnimation::State' is specified in typesystem, but not declared
    enum 'QLocale::MeasurementSystem' is specified in typesystem, but not declared
    enum 'QLocale::FormatType' is specified in typesystem, but not declared
    enum 'QState::RestorePolicy' is specified in typesystem, but not declared
    


    There's no user provided way (conversion rule, argument removal, custom code, etc) to handle the primitive argument type 'QString *' in function 'QTextStream::readLineInto(QString * line, qint64 maxlen)'.
    

Done, 18 warnings (426 known issues)

```

By systematically looking up the missing types in the search field of the Qt5.5 documentation at
http://doc.qt.io/qt-5/ we apply the following changes to typesystem_core_common.xml:

```
diff --git a/PySide/QtCore/typesystem_core_common.xml b/PySide/QtCore/typesystem_core_common.xml
index 2f39db3..f0a504f 100644
--- a/PySide/QtCore/typesystem_core_common.xml
+++ b/PySide/QtCore/typesystem_core_common.xml
@@ -2935,6 +2935,8 @@
   <object-type name="QSysInfo">
     <enum-type name="Endian"/>
     <enum-type name="Sizes"/>
+    <enum-type name="MacVersion" since="5.5" />
+    <enum-type name="WinVersion" since="5.5" />
   </object-type>
   <object-type name="QTemporaryFile">
     <extra-includes>
@@ -3833,6 +3835,8 @@
   </object-type>
 
   <object-type name="QAbstractTransition" since="4.6">
+    <enum-type name="TransitionType" since="5.5" />
+
     <modify-function signature="QAbstractTransition(QState*)">
       <modify-argument index="1">
         <parent index="this" action="add"/>
```

As a result, this reduces the warnings to this:

```
Generating enum model...                     [WARNING]
    enum 'InterfaceType' does not have a type entry or is not an enum
    enum 'TextBoundaryType' does not have a type entry or is not an enum
    enum 'RelationFlag' does not have a type entry or is not an enum
    enum 'Role' does not have a type entry or is not an enum
    

Generating namespace model...                [WARNING]
    enum 'Qt::TabFocusBehavior' does not have a type entry or is not an enum
    enum 'Qt::ItemSelectionOperation' does not have a type entry or is not an enum
    

Resolving typedefs...                        [OK]
Fixing class inheritance...                  [OK]
Detecting inconsistencies in class model...  [OK]
[OK]
    enum 'QState::RestorePolicy' is specified in typesystem, but not declared
    enum 'QLocale::FormatType' is specified in typesystem, but not declared
    enum 'QAbstractAnimation::DeletionPolicy' is specified in typesystem, but not declared
    enum 'QLocale::MeasurementSystem' is specified in typesystem, but not declared
    enum 'QAbstractAnimation::State' is specified in typesystem, but not declared
    


    There's no user provided way (conversion rule, argument removal, custom code, etc) to handle the primitive argument type 'QString *' in function 'QTextStream::readLineInto(QString * line, qint64 maxlen)'.
    

Done, 12 warnings (422 known issues)

```

The next four enum entries "InterfaceType", "TextBoundaryType", "RelationFlag", "Role" do not
exist in QtCore, and I have no idea how they were found by shiboken. They should be entries for
QAccessible in QtGui and others. I defined them anyway, and the warnings disappeared.

We are now down to 8 warnings:

```
Generating class model...                    [OK]
Generating enum model...                     [OK]
Generating namespace model...                [WARNING]
    enum 'Qt::ItemSelectionOperation' does not have a type entry or is not an enum
    enum 'Qt::TabFocusBehavior' does not have a type entry or is not an enum
    

Resolving typedefs...                        [OK]
Fixing class inheritance...                  [OK]
Detecting inconsistencies in class model...  [OK]
[OK]
    enum 'QLocale::FormatType' is specified in typesystem, but not declared
    enum 'QLocale::MeasurementSystem' is specified in typesystem, but not declared
    enum 'QAbstractAnimation::DeletionPolicy' is specified in typesystem, but not declared
    enum 'QState::RestorePolicy' is specified in typesystem, but not declared
    enum 'QAbstractAnimation::State' is specified in typesystem, but not declared
    


    There's no user provided way (conversion rule, argument removal, custom code, etc) to handle the primitive argument type 'QString *' in function 'QTextStream::readLineInto(QString * line, qint64 maxlen)'.
    

Done, 8 warnings (422 known issues)

```

Removing the next enum complaints

```
Generating class model...                    [OK]
Generating enum model...                     [OK]
Generating namespace model...                [OK]
Resolving typedefs...                        [OK]
Fixing class inheritance...                  [OK]
Detecting inconsistencies in class model...  [OK]
[OK]
    enum 'QLocale::MeasurementSystem' is specified in typesystem, but not declared
    enum 'QState::RestorePolicy' is specified in typesystem, but not declared
    enum 'QLocale::FormatType' is specified in typesystem, but not declared
    enum 'QAbstractAnimation::DeletionPolicy' is specified in typesystem, but not declared
    enum 'QAbstractAnimation::State' is specified in typesystem, but not declared
    


    There's no user provided way (conversion rule, argument removal, custom code, etc) to handle the primitive argument type 'QString *' in function 'QTextStream::readLineInto(QString * line, qint64 maxlen)'.
    

Done, 6 warnings (418 known issues)

```

We now get rid of the last 5 enum complaints:
The enums are moved elsewhere, and I have no idea what to do when something becomes invalid?
What I did was ignoring these errors:

```
  <!-- Qt5.5: No idea how to get rid of the following five enums, which are moved elsewhere since 5.5: -->
  <suppress-warning text="enum 'QLocale::MeasurementSystem' is specified in typesystem, but not declared" />
  <suppress-warning text="enum 'QState::RestorePolicy' is specified in typesystem, but not declared" />
  <suppress-warning text="enum 'QLocale::FormatType' is specified in typesystem, but not declared" />
  <suppress-warning text="enum 'QAbstractAnimation::DeletionPolicy' is specified in typesystem, but not declared" />
  <suppress-warning text="enum 'QAbstractAnimation::State' is specified in typesystem, but not declared" />

</typesystem>
```

We get rid of the function warning from above by looking in the Docs: *readLineInto seems to be a new
function, and it has a target variable, that normally needs extra support by a code snippet in the XML:
```
bool    readLineInto(QString * line, qint64 maxlen = 0)
```

But since we do not need to forcibly support new methods, it is easiest to just remove the method
and leave a comment, as it was done before for different argument types:

```
diff --git a/PySide/QtCore/typesystem_core_common.xml b/PySide/QtCore/typesystem_core_common.xml
index 8cd71f4..63f2342 100644
--- a/PySide/QtCore/typesystem_core_common.xml
+++ b/PySide/QtCore/typesystem_core_common.xml
@@ -3656,6 +3656,8 @@
     <enum-type name="Status"/>
     <!-- Removed because it expect QString to be mutable -->
     <modify-function signature="QTextStream(QString*,QFlags&lt;QIODevice::OpenModeFlag&gt;)" remove="all"/>
+    <!-- Qt5.5: Removed because it expect QString to be mutable -->
+    <modify-function signature="readLineInto(QString*,qint64)" since="5.5" remove="all"/>
     <!-- Removed because we use the non-const version -->
     <modify-function signature="QTextStream(const QByteArray&amp;, QFlags&lt;QIODevice::OpenModeFlag&gt;)" remove="all"/>
 
```

The only remaining problem seems now to be an include file, which is now required for some unclear reason:

```
/Users/tismer/src/pyside-setup2/pyside_build/py3.4-qt5.5.0-64bit-debug/pyside/PySide/QtCore/PySide/QtCore/pyside_qtcore_python.h:56:10: fatal error: 
      'qaccessible.h' file not found
#include <qaccessible.h>
         ^
1 error generated.
```

2015-09-07

This file actually belongs to the QtGui library, and the according include files are not configured
in the cmake file for QtCore (and really should not!).

There must be something referenced by QtCore XML that reaches out into QtGui.
Actually, this looks like a shiboken bug, and we revert the change to define the enums
"InterfaceType", "TextBoundaryType", "RelationFlag", "Role" and ignore them, instead:

After suppressing these four warnings, we are faced with the following compile errors:

```
[ 22%] Building CXX object PySide/QtCore/CMakeFiles/QtCore.dir/PySide/QtCore/qbuffer_wrapper.cpp.o
/Users/tismer/src/pyside-setup2/pyside_build/py3.4-qt5.5.0-64bit-debug/pyside/PySide/QtCore/PySide/QtCore/qabstractanimation_wrapper.cpp:344:81: error: use
      of undeclared identifier 'SBK_QABSTRACTANIMATION_STATE_IDX'
        Shiboken::Conversions::copyToPython(SBK_CONVERTER(SbkPySide_QtCoreTypes[SBK_QABSTRACTANIMATION_STATE_IDX]), &newState),
                                                                                ^
/Users/tismer/src/pyside-setup2/pyside_install/py3.4-qt5.5.0-64bit-debug/include/shiboken/sbkconverter.h:339:68: note: expanded from macro 'SBK_CONVERTER'
#define SBK_CONVERTER(pyType) (*reinterpret_cast<_SbkGenericType*>(pyType)->converter)
                                                                   ^
/Users/tismer/src/pyside-setup2/pyside_build/py3.4-qt5.5.0-64bit-debug/pyside/PySide/QtCore/PySide/QtCore/qanimationgroup_wrapper.cpp:344:81: error: use of
      undeclared identifier 'SBK_QABSTRACTANIMATION_STATE_IDX'
        Shiboken::Conversions::copyToPython(SBK_CONVERTER(SbkPySide_QtCoreTypes[SBK_QABSTRACTANIMATION_STATE_IDX]), &newState),
...                                                                                ^
```

This is pretty crazy, and after quite a while of searching, I found out that this is due to the new "Q_ENUM" macro.
I commented the macros away in qabstractanimation.h, and compilation went on much further.

Then, by scanning the sources folder, I found out that certain macros in Qt get special treatment
in shiboken, and now it is clear that I have to augment shiboken, once again.

```
$ grep -rn  Q_ENUM sources/
sources//pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_kernel_qobject.cpp:290:    Q_ENUMS(Priority)
sources//pyside2/doc/codesnippets/doc/src/snippets/moc/myclass2.h:54:    Q_ENUMS(Priority)
sources//pyside2/doc/pyside.qdocconf.in:159:                          Q_ENUMS \
sources//pyside2/README_from-5.4-to-5.5.md:246:This is pretty crazy, and after quite a while of searching, I found out that this is due to the new "Q_ENUM" macro.
sources//shiboken2/ApiExtractor/abstractmetalang.h:1305:    // Has the enum been declared inside a Q_ENUMS() macro in its enclosing class?
sources//shiboken2/ApiExtractor/parser/lexer.cpp:1338:            token_stream[(int) index++].kind = Token_Q_ENUMS;
sources//shiboken2/ApiExtractor/parser/parser.cpp:425:    case Token_Q_ENUMS:
sources//shiboken2/ApiExtractor/parser/parser.cpp:426:        return parseQ_ENUMS(node);
sources//shiboken2/ApiExtractor/parser/parser.cpp:1781:    } else if (parseQ_ENUMS(node)) {
sources//shiboken2/ApiExtractor/parser/parser.cpp:4002:bool Parser::parseQ_ENUMS(DeclarationAST *&node)
sources//shiboken2/ApiExtractor/parser/parser.cpp:4004:    if (token_stream.lookAhead() != Token_Q_ENUMS)
sources//shiboken2/ApiExtractor/parser/parser.h:167:    bool parseQ_ENUMS(DeclarationAST *&node);
sources//shiboken2/ApiExtractor/parser/tokens.cpp:135:    "Q_ENUMS"
sources//shiboken2/ApiExtractor/parser/tokens.h:136:    Token_Q_ENUMS,
```

Now we first need to change shiboken, and then evaluatet a lot of things, again.

---------

2015-09-17

After a longer break, shiboken was fixed for Qt5.5 .

# QtCore 
has a problem with the new entry in `qmetaobject.h`:

```
    template<typename T> static QMetaEnum fromType() {
        Q_STATIC_ASSERT_X(QtPrivate::IsQEnumHelper<T>::Value,
                          "QMetaEnum::fromType only works with enums declared as Q_ENUM or Q_FLAG");
        const QMetaObject *metaObject = qt_getEnumMetaObject(T());
        const char *name = qt_getEnumName(T());
        return metaObject->enumerator(metaObject->indexOfEnumerator(name));
    }
```
Because the C compiler did not know how to resolve the template, I disabled the function like so:
```
    <!-- Qt5.5: "template<typename T> static QMetaEnum fromType()" is not understood by the compiler.
         We therefore ignore this 5.5 addition for now: -->
    <modify-function signature="fromType()" since="5.5" remove="all" />
```
If somebody finds a better way to support it, please improve this!

Anyway, this change was now enough to make the 5.5 version build!

The remaining warnings are as follows:

# QtGui
```
[ 22%] Running generator for QtGui...
** WARNING scope not found for function definition:QtPrivate::IsMetaTypePair<T,true>::registerConverter
    definition *ignored*
Generating class model...                    [WARNING]
    enum 'QImageIOHandler::Transformation' does not have a type entry or is not an enum
    enum 'QWheelEvent::DefaultDeltasPerStep' does not have a type entry or is not an enum
    

Generating enum model...                     [OK]
Generating namespace model...                [OK]
Resolving typedefs...                        [OK]
Fixing class inheritance...                  [OK]
Detecting inconsistencies in class model...  [OK]
[OK]

    There's no user provided way (conversion rule, argument removal, custom code, etc) to handle the primitive argument type 'float *' in function 'QQuaternion::getAxisAndAngle(float * x, float * y, float * z, float * angle) const'.
    /Users/tismer/src/pyside-setup2/sources/shiboken2/generator/shiboken/cppgenerator.cpp:4452 FIXME:
    The code tried to qRegisterMetaType the unqualified name 'iterator'. This is currently fixed by a hack(ct) and needs improvement!
    signature 'parent()const' for function modification in 'QSortFilterProxyModel' not found. Possible candidates: parent(QModelIndex)const in QSortFilterProxyModel
    There's no user provided way (conversion rule, argument removal, custom code, etc) to handle the primitive argument type 'float *' in function 'QQuaternion::getAxisAndAngle(QVector3D * axis, float * angle) const'.
    There's no user provided way (conversion rule, argument removal, custom code, etc) to handle the primitive argument type 'float *' in function 'QQuaternion::getEulerAngles(float * pitch, float * yaw, float * roll) const'.
    

Done, 7 warnings (556 known issues)
```
The first enum was a simple addition, after looking it up in http://doc.qt.io/qt-5/qimageiohandler.html :
We simply added the new enum with a 'since' tag.
```
  <object-type name="QImageIOHandler">
    <extra-includes>
      <include file-name="QRect" location="global"/>
    </extra-includes>
    <enum-type name="ImageOption"/>
    <enum-type name="Transformation" flags="Transformations" since="5.5" />
    <modify-function signature="setDevice(QIODevice*)">
      <modify-argument index="1">
        <parent index="this" action="add"/>
      </modify-argument>
    </modify-function>
  </object-type>
```
The `QWheelEvent::DefaultDeltasPerStep` was harder, because it had no entry in the Qt docs. So we had to look
into the source. It turns out that the enum is a nameless one:
```
#ifndef QT_NO_WHEELEVENT
class Q_GUI_EXPORT QWheelEvent : public QInputEvent
{
public:
    enum { DefaultDeltasPerStep = 120 };
    ...
```
We suppress the warning, no idea what else can be done:
```
  <!-- Qt5.5: suppress this nameless enum -->
  <suppress-warning text="enum 'QWheelEvent::DefaultDeltasPerStep' does not have a type entry or is not an enum" />
```
We ignore the `QQuaternion` methods, which have output variables.
It is easy to support them later, but I think nobody cares at the moment.
They are marked for later review.
```
  <value-type name="QQuaternion" since="4.6">
    ...
    <!-- Qt5.5: XXX support the output variables! For now, I just suppressed the new methods. -->
    <modify-function signature="getAxisAndAngle(float *, float *, float *, float *) const" since="5.5" remove="all" />
    <modify-function signature="getAxisAndAngle(QVector3D *, float *) const" since="5.5" remove="all" />
    <modify-function signature="getEulerAngles(float *, float *, float *) const" since="5.5" remove="all" />
  </value-type>
```
The remaining warning is from me, and it shall stay there, until some brave soul fixes that shiboken problem:
```
The code tried to qRegisterMetaType the unqualified name 'iterator'. This is currently fixed by a hack(ct) and needs improvement!
```

The remaining messages in QtGui and QtWidgets are of the form:
```
signature 'parent()const' for function modification in 'QSortFilterProxyModel' not found. ...
```
These entries were useful in Qt5.4 :
```
    <!-- ### This reimplementation of "QObject::parent()" is used in C++ only
         when "using QObject::parent;" is not available. It's useless in Python. -->
    <modify-function signature="parent()const" remove="all"/>
```
but make no more sense in Qt5.5 . Because there is no easy way to specify, when something is _removed_, I simply
removed these entries, which will produce warnings when building for Qt5.4 (ignoring this).

# That's all, Folks