Hit bug in sip wrapper generation of template expansion involving enums

Phil Thompson phil at riverbankcomputing.com
Thu Mar 4 14:19:59 GMT 2021


On 03/03/2021 23:43, Gehlhaar, Daniel Kurt wrote:
> I hit a problem moving from sip 4.19.3 to sip 6.0.2 involving the code
> generation relating to the following sample, specifically the
> QMap<MyEnum,QColor>:
> 
> 
> #ifndef COLORS_H
> #define COLORS_H
> 
> #include <qcolor.h>
> #include <qobject.h>
> #include <qmap.h>
> #include "DefinesMyEnum.h"
> 
> class Colors : public QObject
> {
>   Q_OBJECT;
> 
> public:
>   Colors();
> 
>   const QMap<MyEnum, QColor> &GetColors() const
>     { return colors; }
> 
> protected:
> 
>   QMap<MyEnum, QColor> colors;
> };
> 
> #endif
> 
> 
> #ifndef DEFINES_MY_ENUM_H
> #define DEFINES_MY_ENUM_H
> 
> enum MyEnum
>   { THIS, THAT };
> 
> #endif
> 
> %Module Colors
> 
> class Colors : QObject
> {
> %TypeHeaderCode
> #include "Colors.h"
> %End
> 
> public:
>   Colors();
> 
>   const QMap<MyEnum, QColor> &GetColors() const ;
> };
> 
> In sip 4.19.3, each .sip file generated a .cpp file. In sip 6.0.2,
> this is not necessarily the case. In this case, the
> QMap<MyEnum,QColor> gets wrapped in its own .cpp file that DOES NOT
> INCLUDE the definition of the MyEnum type (i.e. it does not include
> "DefinesMyEnum.h").  This results in myriad compiler errors:
> 
> sipPyTESTQMap0100MyEnum0100QColor.cpp(18): error C2065: 'MyEnum':
> undeclared identifier
> sipPyTESTQMap0100MyEnum0100QColor.cpp(18): error C2923: 'QMap':
> 'MyEnum' is not a valid template type argument for parameter 'Key'
> 
> Please fix, or let me know what I need to do on my end to fix.

Please provide a complete example as separately attached files. The 
pyproject.toml file is missing along with the .sip file for MyEnum.

Phil


More information about the PyQt mailing list