ggobi / qtbase

Dynamic bindings from R to the Qt library
20 stars 7 forks source link

Data type conversion problem when building against Qt5.4.0 #33

Closed tsieger closed 9 years ago

tsieger commented 9 years ago

When building against Qt5.4.0, the smoke-generated code does not compile using GNU g++ 4.9.1:

[ 69%] Building CXX object smoke/qt/CMakeFiles/smokeqt.dir/x_1.cpp.obj
C:/src/qtbase-master141107/qtbase/kdebindings-build/smoke/qt/x_1.cpp:1:0: warning: -fPIC ignored for target (all code is position independent)
 //Auto-generated by C:\src\qtbase-master141107\qtbase\kdebindings-build\generator\bin\smokegen.exe. DO NOT EDIT.
 ^
C:/src/qtbase-master141107/qtbase/kdebindings-build/smoke/qt/x_1.cpp: In member function 'void __smokeqt::x_QAbstractVideoBuffer::x_6(Smoke::Stack)':
C:/src/qtbase-master141107/qtbase/kdebindings-build/smoke/qt/x_1.cpp:12638:180: error: no matching function for call to '__smokeqt::x_QAbstractVideoBuffer::mapP
lanes(QAbstractVideoBuffer::MapMode, int*, int [4], unsigned char (*&)[4])'
         int xret = this->QAbstractVideoBuffer::mapPlanes((QAbstractVideoBuffer::MapMode)x[1].s_enum,(int*)x[2].s_class,*(int(*)[4])x[3].s_class,*(unsigned char
(**)[4])x[4].s_class);

                    ^
C:/src/qtbase-master141107/qtbase/kdebindings-build/smoke/qt/x_1.cpp:12638:180: note: candidate is:
In file included from C:/Qt/Qt5.4.0/5.4/mingw491_32/include/QtMultimedia/qvideoframe.h:40:0,
                 from C:/Qt/Qt5.4.0/5.4/mingw491_32/include/QtMultimedia/qcameraimagecapture.h:40,
                 from C:/Qt/Qt5.4.0/5.4/mingw491_32/include/QtMultimedia/QtMultimedia:29,
                 from C:/src/qtbase-master141107/qtbase/kdebindings/smoke/qt/qt_includes.h:11,
                 from C:/src/qtbase-master141107/qtbase/kdebindings-build/smoke/qt/x_1.cpp:2:
C:/Qt/Qt5.4.0/5.4/mingw491_32/include/QtMultimedia/qabstractvideobuffer.h:81:9: note: int QAbstractVideoBuffer::mapPlanes(QAbstractVideoBuffer::MapMode, int*, int*, uchar**)
     int mapPlanes(MapMode mode, int *numBytes, int bytesPerLine[4], uchar *data[4]);
         ^
C:/Qt/Qt5.4.0/5.4/mingw491_32/include/QtMultimedia/qabstractvideobuffer.h:81:9: note:   no known conversion for argument 4 from 'unsigned char (*)[4]' to 'uchar ** {aka unsigned char**}'

The relevant x_1.cpp snippet:

    void x_6(Smoke::Stack x) {
        // int mapPlanes(QAbstractVideoBuffer::MapMode, int*, int[4], unsigned char(*)[4])
        int xret = this->QAbstractVideoBuffer::mapPlanes((QAbstractVideoBuffer::MapMode)x[1].s_enum,(int*)x[2].s_class,*(int(*)[4])x[3].s_class,*(unsigned char(**)[4])x[4].s_class);
        x[0].s_int = xret;
    }

Removing the Multimedia and MultimediaWidgets modules from kdebindings/smoke/qt/CMakeLists.txt overcomes this.

BTW qtbase does not work even with Qt5.4.0, see #28.

lawremi commented 9 years ago

Wow, that array size syntax ([4]) is likely confusing both the compiler and smokegen. The generated code is not correct (why is the s_class field additionally referenced?), and there might be a bug in the compiler, although I'm not familiar enough with that syntax to know what should work.

But all that is irrelevant, because qtbase does not handle return-by-reference arguments, and the reason is that any Qt API that uses them is generally too low-level for R. In this example, the only use case mentioned by the documentation of QAbstractVideoBuffer is to implement a "new hardware accelerated video system". No way that is happening in R. Users should be content with QVideoFrame. Thus, I will remove QAbstractVideoBuffer from the generation list.