Skip to content

Commit

Permalink
Fix SIP build errors by using /NoTypeName/
Browse files Browse the repository at this point in the history
The typedef is only present in the .sip file, but without this
annotation SIP assumes it also exists in QGIS headers. This didn't
completely break the build, since we concatenate multiple SIP headers
into larger files, so the typedefs from one part "fixed" another. Run
sip-build without --concatenate to see the issue clearly.

This fix is currently sadly not fully effective due to a SIP bug:
Python-SIP/sip#66
  • Loading branch information
dvdkon committed Jan 3, 2025
1 parent c714c55 commit 5823d02
Show file tree
Hide file tree
Showing 11 changed files with 42 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@



typedef QgsOptional<QgsExpression> QgsOptionalQgsExpressionBase;
typedef QgsOptional<QgsExpression> QgsOptionalQgsExpressionBase /NoTypeName/;

class QgsOptionalExpression : QgsOptionalQgsExpressionBase
{
Expand Down
4 changes: 2 additions & 2 deletions python/PyQt6/core/auto_generated/qgsrange.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ Returns ``True`` if this range overlaps another range.



typedef QgsRange<double> QgsRangedoubleBase;
typedef QgsRange<double> QgsRangedoubleBase /NoTypeName/;

class QgsDoubleRange : QgsRangedoubleBase
{
Expand Down Expand Up @@ -210,7 +210,7 @@ Returns ``True`` if the range consists of all possible values.



typedef QgsRange<int> QgsRangeintBase;
typedef QgsRange<int> QgsRangeintBase /NoTypeName/;

class QgsIntRange : QgsRangeintBase
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@



typedef QgsSettingsEntryBaseTemplate<QVariant> QgsSettingsEntryBaseTemplateQVariantBase;
typedef QgsSettingsEntryBaseTemplate<QVariant> QgsSettingsEntryBaseTemplateQVariantBase /NoTypeName/;

class QgsSettingsEntryVariant : QgsSettingsEntryBaseTemplateQVariantBase
{
Expand Down Expand Up @@ -110,7 +110,7 @@ Returns settings value.
};


typedef QgsSettingsEntryBaseTemplate<QString> QgsSettingsEntryBaseTemplateQStringBase;
typedef QgsSettingsEntryBaseTemplate<QString> QgsSettingsEntryBaseTemplateQStringBase /NoTypeName/;

class QgsSettingsEntryString : QgsSettingsEntryBaseTemplateQStringBase
{
Expand Down Expand Up @@ -211,7 +211,7 @@ Returns the string maximum length. By -1 there is no limitation.



typedef QgsSettingsEntryBaseTemplate<QStringList> QgsSettingsEntryBaseTemplateQStringListBase;
typedef QgsSettingsEntryBaseTemplate<QStringList> QgsSettingsEntryBaseTemplateQStringListBase /NoTypeName/;

class QgsSettingsEntryStringList : QgsSettingsEntryBaseTemplateQStringListBase
{
Expand Down Expand Up @@ -289,7 +289,7 @@ This constructor is intended to be used from plugins.



typedef QgsSettingsEntryBaseTemplate<bool> QgsSettingsEntryBaseTemplateboolBase;
typedef QgsSettingsEntryBaseTemplate<bool> QgsSettingsEntryBaseTemplateboolBase /NoTypeName/;

class QgsSettingsEntryBool : QgsSettingsEntryBaseTemplateboolBase
{
Expand Down Expand Up @@ -367,7 +367,7 @@ This constructor is intended to be used from plugins.



typedef QgsSettingsEntryBaseTemplate<int> QgsSettingsEntryBaseTemplateintBase;
typedef QgsSettingsEntryBaseTemplate<int> QgsSettingsEntryBaseTemplateintBase /NoTypeName/;

class QgsSettingsEntryInteger : QgsSettingsEntryBaseTemplateintBase
{
Expand Down Expand Up @@ -470,7 +470,7 @@ Returns the maximum value.



typedef QgsSettingsEntryBaseTemplate<double> QgsSettingsEntryBaseTemplatedoubleBase;
typedef QgsSettingsEntryBaseTemplate<double> QgsSettingsEntryBaseTemplatedoubleBase /NoTypeName/;

class QgsSettingsEntryDouble : QgsSettingsEntryBaseTemplatedoubleBase
{
Expand Down Expand Up @@ -595,7 +595,7 @@ Returns how much decimals should be shown in the Gui.



typedef QgsSettingsEntryBaseTemplate<QColor> QgsSettingsEntryBaseTemplateQColorBase;
typedef QgsSettingsEntryBaseTemplate<QColor> QgsSettingsEntryBaseTemplateQColorBase /NoTypeName/;

class QgsSettingsEntryColor : QgsSettingsEntryBaseTemplateQColorBase
{
Expand Down Expand Up @@ -689,7 +689,7 @@ Returns ``True`` if transparency is allowed for the color
};


typedef QgsSettingsEntryBaseTemplate<QVariantMap> QgsSettingsEntryBaseTemplateQVariantMapBase;
typedef QgsSettingsEntryBaseTemplate<QVariantMap> QgsSettingsEntryBaseTemplateQVariantMapBase /NoTypeName/;

class QgsSettingsEntryVariantMap : QgsSettingsEntryBaseTemplateQVariantMapBase
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ Returns the layer id of the source layer.
};


typedef QgsAbstractFeatureIteratorFromSource<QgsVectorLayerFeatureSource> QgsAbstractFeatureIteratorFromSourceQgsVectorLayerFeatureSourceBase;
typedef QgsAbstractFeatureIteratorFromSource<QgsVectorLayerFeatureSource> QgsAbstractFeatureIteratorFromSourceQgsVectorLayerFeatureSourceBase /NoTypeName/;

class QgsVectorLayerFeatureIterator : QgsAbstractFeatureIteratorFromSourceQgsVectorLayerFeatureSourceBase
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ To be re-implemented to implemeent type specific configuration (e.g. opacity for



typedef QgsSettingsEditorWidgetWrapperTemplate<QgsSettingsEntryString,QLineEdit,QString> QgsSettingsEditorWidgetWrapperTemplateQgsSettingsEntryStringQLineEditQStringBase;
typedef QgsSettingsEditorWidgetWrapperTemplate<QgsSettingsEntryString,QLineEdit,QString> QgsSettingsEditorWidgetWrapperTemplateQgsSettingsEntryStringQLineEditQStringBase /NoTypeName/;

class QgsSettingsStringLineEditWrapper : QgsSettingsEditorWidgetWrapperTemplateQgsSettingsEntryStringQLineEditQStringBase
{
Expand Down Expand Up @@ -122,7 +122,7 @@ Constructor of the wrapper for a given ``setting`` and its widget ``editor``



typedef QgsSettingsEditorWidgetWrapperTemplate<QgsSettingsEntryString,QComboBox,QString> QgsSettingsEditorWidgetWrapperTemplateQgsSettingsEntryStringQComboBoxQStringBase;
typedef QgsSettingsEditorWidgetWrapperTemplate<QgsSettingsEntryString,QComboBox,QString> QgsSettingsEditorWidgetWrapperTemplateQgsSettingsEntryStringQComboBoxQStringBase /NoTypeName/;

class QgsSettingsStringComboBoxWrapper : QgsSettingsEditorWidgetWrapperTemplateQgsSettingsEntryStringQComboBoxQStringBase
{
Expand Down Expand Up @@ -179,7 +179,7 @@ Constructor of the wrapper for a given ``setting`` and its widget ``editor``



typedef QgsSettingsEditorWidgetWrapperTemplate<QgsSettingsEntryBool,QCheckBox,bool> QgsSettingsEditorWidgetWrapperTemplateQgsSettingsEntryBoolQCheckBoxboolBase;
typedef QgsSettingsEditorWidgetWrapperTemplate<QgsSettingsEntryBool,QCheckBox,bool> QgsSettingsEditorWidgetWrapperTemplateQgsSettingsEntryBoolQCheckBoxboolBase /NoTypeName/;

class QgsSettingsBoolCheckBoxWrapper : QgsSettingsEditorWidgetWrapperTemplateQgsSettingsEntryBoolQCheckBoxboolBase
{
Expand Down Expand Up @@ -223,7 +223,7 @@ Constructor of the wrapper for a given ``setting`` and its widget ``editor``
};


typedef QgsSettingsEditorWidgetWrapperTemplate<QgsSettingsEntryInteger,QSpinBox,int> QgsSettingsEditorWidgetWrapperTemplateQgsSettingsEntryIntegerQSpinBoxintBase;
typedef QgsSettingsEditorWidgetWrapperTemplate<QgsSettingsEntryInteger,QSpinBox,int> QgsSettingsEditorWidgetWrapperTemplateQgsSettingsEntryIntegerQSpinBoxintBase /NoTypeName/;

class QgsSettingsIntegerSpinBoxWrapper : QgsSettingsEditorWidgetWrapperTemplateQgsSettingsEntryIntegerQSpinBoxintBase
{
Expand Down Expand Up @@ -268,7 +268,7 @@ Constructor of the wrapper for a given ``setting`` and its widget ``editor``



typedef QgsSettingsEditorWidgetWrapperTemplate<QgsSettingsEntryDouble,QDoubleSpinBox,double> QgsSettingsEditorWidgetWrapperTemplateQgsSettingsEntryDoubleQDoubleSpinBoxdoubleBase;
typedef QgsSettingsEditorWidgetWrapperTemplate<QgsSettingsEntryDouble,QDoubleSpinBox,double> QgsSettingsEditorWidgetWrapperTemplateQgsSettingsEntryDoubleQDoubleSpinBoxdoubleBase /NoTypeName/;

class QgsSettingsDoubleSpinBoxWrapper : QgsSettingsEditorWidgetWrapperTemplateQgsSettingsEntryDoubleQDoubleSpinBoxdoubleBase
{
Expand Down Expand Up @@ -313,7 +313,7 @@ Constructor of the wrapper for a given ``setting`` and its widget ``editor``



typedef QgsSettingsEditorWidgetWrapperTemplate<QgsSettingsEntryColor,QgsColorButton,QColor> QgsSettingsEditorWidgetWrapperTemplateQgsSettingsEntryColorQgsColorButtonQColorBase;
typedef QgsSettingsEditorWidgetWrapperTemplate<QgsSettingsEntryColor,QgsColorButton,QColor> QgsSettingsEditorWidgetWrapperTemplateQgsSettingsEntryColorQgsColorButtonQColorBase /NoTypeName/;

class QgsSettingsColorButtonWrapper : QgsSettingsEditorWidgetWrapperTemplateQgsSettingsEntryColorQgsColorButtonQColorBase
{
Expand Down
2 changes: 1 addition & 1 deletion python/core/auto_generated/qgsoptionalexpression.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@



typedef QgsOptional<QgsExpression> QgsOptionalQgsExpressionBase;
typedef QgsOptional<QgsExpression> QgsOptionalQgsExpressionBase /NoTypeName/;

class QgsOptionalExpression : QgsOptionalQgsExpressionBase
{
Expand Down
4 changes: 2 additions & 2 deletions python/core/auto_generated/qgsrange.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ Returns ``True`` if this range overlaps another range.



typedef QgsRange<double> QgsRangedoubleBase;
typedef QgsRange<double> QgsRangedoubleBase /NoTypeName/;

class QgsDoubleRange : QgsRangedoubleBase
{
Expand Down Expand Up @@ -210,7 +210,7 @@ Returns ``True`` if the range consists of all possible values.



typedef QgsRange<int> QgsRangeintBase;
typedef QgsRange<int> QgsRangeintBase /NoTypeName/;

class QgsIntRange : QgsRangeintBase
{
Expand Down
16 changes: 8 additions & 8 deletions python/core/auto_generated/settings/qgssettingsentryimpl.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@



typedef QgsSettingsEntryBaseTemplate<QVariant> QgsSettingsEntryBaseTemplateQVariantBase;
typedef QgsSettingsEntryBaseTemplate<QVariant> QgsSettingsEntryBaseTemplateQVariantBase /NoTypeName/;

class QgsSettingsEntryVariant : QgsSettingsEntryBaseTemplateQVariantBase
{
Expand Down Expand Up @@ -110,7 +110,7 @@ Returns settings value.
};


typedef QgsSettingsEntryBaseTemplate<QString> QgsSettingsEntryBaseTemplateQStringBase;
typedef QgsSettingsEntryBaseTemplate<QString> QgsSettingsEntryBaseTemplateQStringBase /NoTypeName/;

class QgsSettingsEntryString : QgsSettingsEntryBaseTemplateQStringBase
{
Expand Down Expand Up @@ -211,7 +211,7 @@ Returns the string maximum length. By -1 there is no limitation.



typedef QgsSettingsEntryBaseTemplate<QStringList> QgsSettingsEntryBaseTemplateQStringListBase;
typedef QgsSettingsEntryBaseTemplate<QStringList> QgsSettingsEntryBaseTemplateQStringListBase /NoTypeName/;

class QgsSettingsEntryStringList : QgsSettingsEntryBaseTemplateQStringListBase
{
Expand Down Expand Up @@ -289,7 +289,7 @@ This constructor is intended to be used from plugins.



typedef QgsSettingsEntryBaseTemplate<bool> QgsSettingsEntryBaseTemplateboolBase;
typedef QgsSettingsEntryBaseTemplate<bool> QgsSettingsEntryBaseTemplateboolBase /NoTypeName/;

class QgsSettingsEntryBool : QgsSettingsEntryBaseTemplateboolBase
{
Expand Down Expand Up @@ -367,7 +367,7 @@ This constructor is intended to be used from plugins.



typedef QgsSettingsEntryBaseTemplate<int> QgsSettingsEntryBaseTemplateintBase;
typedef QgsSettingsEntryBaseTemplate<int> QgsSettingsEntryBaseTemplateintBase /NoTypeName/;

class QgsSettingsEntryInteger : QgsSettingsEntryBaseTemplateintBase
{
Expand Down Expand Up @@ -470,7 +470,7 @@ Returns the maximum value.



typedef QgsSettingsEntryBaseTemplate<double> QgsSettingsEntryBaseTemplatedoubleBase;
typedef QgsSettingsEntryBaseTemplate<double> QgsSettingsEntryBaseTemplatedoubleBase /NoTypeName/;

class QgsSettingsEntryDouble : QgsSettingsEntryBaseTemplatedoubleBase
{
Expand Down Expand Up @@ -595,7 +595,7 @@ Returns how much decimals should be shown in the Gui.



typedef QgsSettingsEntryBaseTemplate<QColor> QgsSettingsEntryBaseTemplateQColorBase;
typedef QgsSettingsEntryBaseTemplate<QColor> QgsSettingsEntryBaseTemplateQColorBase /NoTypeName/;

class QgsSettingsEntryColor : QgsSettingsEntryBaseTemplateQColorBase
{
Expand Down Expand Up @@ -689,7 +689,7 @@ Returns ``True`` if transparency is allowed for the color
};


typedef QgsSettingsEntryBaseTemplate<QVariantMap> QgsSettingsEntryBaseTemplateQVariantMapBase;
typedef QgsSettingsEntryBaseTemplate<QVariantMap> QgsSettingsEntryBaseTemplateQVariantMapBase /NoTypeName/;

class QgsSettingsEntryVariantMap : QgsSettingsEntryBaseTemplateQVariantMapBase
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ Returns the layer id of the source layer.
};


typedef QgsAbstractFeatureIteratorFromSource<QgsVectorLayerFeatureSource> QgsAbstractFeatureIteratorFromSourceQgsVectorLayerFeatureSourceBase;
typedef QgsAbstractFeatureIteratorFromSource<QgsVectorLayerFeatureSource> QgsAbstractFeatureIteratorFromSourceQgsVectorLayerFeatureSourceBase /NoTypeName/;

class QgsVectorLayerFeatureIterator : QgsAbstractFeatureIteratorFromSourceQgsVectorLayerFeatureSourceBase
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ To be re-implemented to implemeent type specific configuration (e.g. opacity for



typedef QgsSettingsEditorWidgetWrapperTemplate<QgsSettingsEntryString,QLineEdit,QString> QgsSettingsEditorWidgetWrapperTemplateQgsSettingsEntryStringQLineEditQStringBase;
typedef QgsSettingsEditorWidgetWrapperTemplate<QgsSettingsEntryString,QLineEdit,QString> QgsSettingsEditorWidgetWrapperTemplateQgsSettingsEntryStringQLineEditQStringBase /NoTypeName/;

class QgsSettingsStringLineEditWrapper : QgsSettingsEditorWidgetWrapperTemplateQgsSettingsEntryStringQLineEditQStringBase
{
Expand Down Expand Up @@ -122,7 +122,7 @@ Constructor of the wrapper for a given ``setting`` and its widget ``editor``



typedef QgsSettingsEditorWidgetWrapperTemplate<QgsSettingsEntryString,QComboBox,QString> QgsSettingsEditorWidgetWrapperTemplateQgsSettingsEntryStringQComboBoxQStringBase;
typedef QgsSettingsEditorWidgetWrapperTemplate<QgsSettingsEntryString,QComboBox,QString> QgsSettingsEditorWidgetWrapperTemplateQgsSettingsEntryStringQComboBoxQStringBase /NoTypeName/;

class QgsSettingsStringComboBoxWrapper : QgsSettingsEditorWidgetWrapperTemplateQgsSettingsEntryStringQComboBoxQStringBase
{
Expand Down Expand Up @@ -179,7 +179,7 @@ Constructor of the wrapper for a given ``setting`` and its widget ``editor``



typedef QgsSettingsEditorWidgetWrapperTemplate<QgsSettingsEntryBool,QCheckBox,bool> QgsSettingsEditorWidgetWrapperTemplateQgsSettingsEntryBoolQCheckBoxboolBase;
typedef QgsSettingsEditorWidgetWrapperTemplate<QgsSettingsEntryBool,QCheckBox,bool> QgsSettingsEditorWidgetWrapperTemplateQgsSettingsEntryBoolQCheckBoxboolBase /NoTypeName/;

class QgsSettingsBoolCheckBoxWrapper : QgsSettingsEditorWidgetWrapperTemplateQgsSettingsEntryBoolQCheckBoxboolBase
{
Expand Down Expand Up @@ -223,7 +223,7 @@ Constructor of the wrapper for a given ``setting`` and its widget ``editor``
};


typedef QgsSettingsEditorWidgetWrapperTemplate<QgsSettingsEntryInteger,QSpinBox,int> QgsSettingsEditorWidgetWrapperTemplateQgsSettingsEntryIntegerQSpinBoxintBase;
typedef QgsSettingsEditorWidgetWrapperTemplate<QgsSettingsEntryInteger,QSpinBox,int> QgsSettingsEditorWidgetWrapperTemplateQgsSettingsEntryIntegerQSpinBoxintBase /NoTypeName/;

class QgsSettingsIntegerSpinBoxWrapper : QgsSettingsEditorWidgetWrapperTemplateQgsSettingsEntryIntegerQSpinBoxintBase
{
Expand Down Expand Up @@ -268,7 +268,7 @@ Constructor of the wrapper for a given ``setting`` and its widget ``editor``



typedef QgsSettingsEditorWidgetWrapperTemplate<QgsSettingsEntryDouble,QDoubleSpinBox,double> QgsSettingsEditorWidgetWrapperTemplateQgsSettingsEntryDoubleQDoubleSpinBoxdoubleBase;
typedef QgsSettingsEditorWidgetWrapperTemplate<QgsSettingsEntryDouble,QDoubleSpinBox,double> QgsSettingsEditorWidgetWrapperTemplateQgsSettingsEntryDoubleQDoubleSpinBoxdoubleBase /NoTypeName/;

class QgsSettingsDoubleSpinBoxWrapper : QgsSettingsEditorWidgetWrapperTemplateQgsSettingsEntryDoubleQDoubleSpinBoxdoubleBase
{
Expand Down Expand Up @@ -313,7 +313,7 @@ Constructor of the wrapper for a given ``setting`` and its widget ``editor``



typedef QgsSettingsEditorWidgetWrapperTemplate<QgsSettingsEntryColor,QgsColorButton,QColor> QgsSettingsEditorWidgetWrapperTemplateQgsSettingsEntryColorQgsColorButtonQColorBase;
typedef QgsSettingsEditorWidgetWrapperTemplate<QgsSettingsEntryColor,QgsColorButton,QColor> QgsSettingsEditorWidgetWrapperTemplateQgsSettingsEntryColorQgsColorButtonQColorBase /NoTypeName/;

class QgsSettingsColorButtonWrapper : QgsSettingsEditorWidgetWrapperTemplateQgsSettingsEntryColorQgsColorButtonQColorBase
{
Expand Down
10 changes: 6 additions & 4 deletions scripts/sipify.py
Original file line number Diff line number Diff line change
Expand Up @@ -1884,19 +1884,21 @@ def cpp_to_python_signature(cpp_function: str) -> str:
f'\n%TypeHeaderCode\n#include "{os.path.basename(CONTEXT.header_file)}"'
)

# for template based inheritance, add a typedef to define the base type
# for template based inheritance, add a typedef to define the base type,
# since SIP doesn't allow inheriting from template classes directly
while template_inheritance_template:
tpl = template_inheritance_template.pop()
cls1 = template_inheritance_class1.pop()
cls2 = template_inheritance_class2.pop()
cls3 = template_inheritance_class3.pop()

if cls2 == "":
CONTEXT.current_line = f"\ntypedef {tpl}<{cls1}> {tpl}{cls1}Base;\n\n{CONTEXT.current_line}"
# We use /NoTypeName/ to say that this typedef is not present in actual QGIS headers
CONTEXT.current_line = f"\ntypedef {tpl}<{cls1}> {tpl}{cls1}Base /NoTypeName/;\n\n{CONTEXT.current_line}"
elif cls3 == "":
CONTEXT.current_line = f"\ntypedef {tpl}<{cls1},{cls2}> {tpl}{cls1}{cls2}Base;\n\n{CONTEXT.current_line}"
CONTEXT.current_line = f"\ntypedef {tpl}<{cls1},{cls2}> {tpl}{cls1}{cls2}Base /NoTypeName/;\n\n{CONTEXT.current_line}"
else:
CONTEXT.current_line = f"\ntypedef {tpl}<{cls1},{cls2},{cls3}> {tpl}{cls1}{cls2}{cls3}Base;\n\n{CONTEXT.current_line}"
CONTEXT.current_line = f"\ntypedef {tpl}<{cls1},{cls2},{cls3}> {tpl}{cls1}{cls2}{cls3}Base /NoTypeName/;\n\n{CONTEXT.current_line}"

if tpl not in CONTEXT.declared_classes:
tpl_header = f"{tpl.lower()}.h"
Expand Down

0 comments on commit 5823d02

Please sign in to comment.