Skip to content
Permalink
Browse files
support QgsSettingsEntryEnumFlag in sipify (#42888)
  • Loading branch information
3nids committed Apr 22, 2021
1 parent c259a40 commit 642deb194d7f94bd47343b4f68fb1dce265d28a7
Showing with 49 additions and 6 deletions.
  1. +33 −6 scripts/sipify.pl
  2. +14 −0 tests/code_layout/sipifyheader.expected.sip
  3. +2 −0 tests/code_layout/sipifyheader.h
@@ -95,16 +95,24 @@ sub read_line {
}

sub write_output {
my ($dbg_code, $out) = @_;
my ($dbg_code, $out, $prepend) = @_;
$prepend //= "no";
if ($debug == 1){
$dbg_code = sprintf("%d %-4s :: ", $LINE_IDX, $dbg_code);
}
else{
$dbg_code = '';
}
push @OUTPUT, "%If ($IF_FEATURE_CONDITION)\n" if $IF_FEATURE_CONDITION ne '';
push @OUTPUT, $dbg_code.$out;
push @OUTPUT, "%End\n" if $IF_FEATURE_CONDITION ne '';
if ($prepend eq "prepend")
{
unshift @OUTPUT, $dbg_code . $out;
}
else
{
push @OUTPUT, "%If ($IF_FEATURE_CONDITION)\n" if $IF_FEATURE_CONDITION ne '';
push @OUTPUT, $dbg_code . $out;
push @OUTPUT, "%End\n" if $IF_FEATURE_CONDITION ne '';
}
$IF_FEATURE_CONDITION = '';
}

@@ -1261,9 +1269,28 @@ sub detect_non_method_member{
# fix astyle placing space after % character
$LINE =~ s/\/\s+GetWrapper\s+\//\/GetWrapper\//;

# handle enum/flags QgsSettingsEntryEnumFlag
if ( $LINE =~ m/^(\s*)const QgsSettingsEntryEnumFlag<(.*)> (.+);$/ ) {
my $prep_line = "class QgsSettingsEntryEnumFlag_$3
{
%TypeHeaderCode
#include \"" .basename($headerfile) . "\"
#include \"qgssettingsentry.h\"
typedef QgsSettingsEntryEnumFlag<$2> QgsSettingsEntryEnumFlag_$3;
%End
public:
QgsSettingsEntryEnumFlag_$3( const QString &key, QgsSettings::Section section, const $2 &defaultValue, const QString &description = QString() );
QString key( const QString &dynamicKeyPart = QString() ) const;
$2 value( const QString &dynamicKeyPart = QString(), bool useDefaultValueOverride = false, const $2 &defaultValueOverride = $2() ) const;
};";
$LINE = "$1const QgsSettingsEntryEnumFlag_$3 $3;";
$COMMENT = '';
write_output("ENF", "$prep_line\n", "prepend");
}

write_output("NOR", "$LINE\n");
if ($PYTHON_SIGNATURE ne ''){
write_output("PSI", "$PYTHON_SIGNATURE\n");
if ($PYTHON_SIGNATURE ne '') {
write_output("PSI", "$PYTHON_SIGNATURE\n");
}

# multiline definition (parenthesis left open)
@@ -5,6 +5,18 @@
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
class QgsSettingsEntryEnumFlag_settingsDigitizingDefaultSnapType
{
%TypeHeaderCode
#include "sipifyheader.h"
#include "qgssettingsentry.h"
typedef QgsSettingsEntryEnumFlag<QgsSnappingConfig::SnappingTypes> QgsSettingsEntryEnumFlag_settingsDigitizingDefaultSnapType;
%End
public:
QgsSettingsEntryEnumFlag_settingsDigitizingDefaultSnapType( const QString &key, QgsSettings::Section section, const QgsSnappingConfig::SnappingTypes &defaultValue, const QString &description = QString() );
QString key( const QString &dynamicKeyPart = QString() ) const;
QgsSnappingConfig::SnappingTypes value( const QString &dynamicKeyPart = QString(), bool useDefaultValueOverride = false, const QgsSnappingConfig::SnappingTypes &defaultValueOverride = QgsSnappingConfig::SnappingTypes() ) const;
};



@@ -86,6 +98,8 @@ typedef QtClass<QVariant> QtClassQVariantBase;

enum OneLiner { Success, NoSuccess };

const QgsSettingsEntryEnumFlag_settingsDigitizingDefaultSnapType settingsDigitizingDefaultSnapType;

struct Data
{
Data( QgsMapLayer *layer, Qstring name );
@@ -120,6 +120,8 @@ class CORE_EXPORT QgsSipifyHeader : public QtClass<QVariant>, private Ui::QgsBas

enum OneLiner { Success, NoSuccess };

static const inline QgsSettingsEntryEnumFlag<QgsSnappingConfig::SnappingTypes> settingsDigitizingDefaultSnapType = QgsSettingsEntryEnumFlag<QgsSnappingConfig::SnappingTypes>( QStringLiteral( "/qgis/digitizing/default_snap_type" ), QgsSettings::NoSection, QgsSnappingConfig::VertexFlag );

/**
* Docstring headers for structs are not supported by sip (as of 4.18) and
* therefore this docstring must not to be copied to the sipfile.

0 comments on commit 642deb1

Please sign in to comment.