Skip to content
Permalink
Browse files

also monkey patch the former enum type

  • Loading branch information
3nids committed Mar 25, 2019
1 parent 38c2d4a commit 9a6ddbd5c12b0a4bd9fe2ec29a6629bca86bf6db
Showing with 9 additions and 5 deletions.
  1. +1 −0 python/core/auto_additions/qgsmaplayer.py
  2. +6 −3 scripts/sipify.pl
  3. +1 −1 src/core/qgis_sip.h
  4. +1 −1 src/core/qgsmaplayer.h
@@ -1,4 +1,5 @@
# The following has been generated automatically from src/core/qgsmaplayer.h
QgsMapLayer.LayerType = QgsMapLayerType
# monkey patching scoped based enum
QgsMapLayer.VectorLayer = QgsMapLayerType.VectorLayer
QgsMapLayer.VectorLayer.__doc__ = ""
@@ -959,12 +959,15 @@ sub detect_non_method_member{
my $is_scope_based = "0";
$is_scope_based = "1" if defined $2;
my $monkeypatch = "0";
$monkeypatch = "1" if defined $is_scope_based eq "1" and $LINE =~ m/SIP_MONKEYPATCH_SCOPEENUM(_UNNEST)?(:?\(\s*(?<emkb>\w+)\s*\))?/;
$monkeypatch = "1" if defined $is_scope_based eq "1" and $LINE =~ m/SIP_MONKEYPATCH_SCOPEENUM(_UNNEST)?(:?\(\s*(?<emkb>\w+)\s*,\s*(?<emkf>\w+)\s*\))?/;
my $enum_mk_base = "";
$enum_mk_base = $+{emkb} if defined $+{emkb};
if (defined $+{emkf} and $monkeypatch eq "1"){
push @OUTPUT_PYTHON, "$enum_mk_base.$+{emkf} = $enum_qualname\n";
}
if ($LINE =~ m/\{((\s*\w+)(\s*=\s*[\w\s\d<|]+.*?)?(,?))+\s*\}/){
# one line declaration
$LINE !~ m/=/ or exit_with_error("spify.pl does not handle enum one liners with value assignment. Use multiple lines instead.");
$LINE !~ m/=/ or exit_with_error("Sipify does not handle enum one liners with value assignment. Use multiple lines instead. Or jusr write a new parser.");
next;
}
else
@@ -984,7 +987,7 @@ sub detect_non_method_member{

do {no warnings 'uninitialized';
my $enum_decl = $LINE =~ s/^(\s*(?<em>\w+))(\s+SIP_\w+(?:\([^()]+\))?)?(?:\s*=\s*(?:[\w\s\d|+-]|::|<<)+)?(,?)(:?\s*\/\/!<\s*(?<co>.*)|.*)$/$1$3$4/r;
my $enum_member = $+{em};
my $enum_member = $+{em};
my $comment = $+{co};
dbg_info("is_scope_based:$is_scope_based enum_mk_base:$enum_mk_base monkeypatch:$monkeypatch");
if ($is_scope_based eq "1") {
@@ -242,7 +242,7 @@
* These macros should be removed in QGIS 4
*/
#define SIP_MONKEYPATCH_SCOPEENUM
#define SIP_MONKEYPATCH_SCOPEENUM_UNNEST(OUTSIDE_CLASS)
#define SIP_MONKEYPATCH_SCOPEENUM_UNNEST(OUTSIDE_CLASS,FORMERNAME)


#endif // QGIS_SIP_H
@@ -58,7 +58,7 @@ class QPainter;


//! Types of layers that can be added to a map
enum class QgsMapLayerType SIP_MONKEYPATCH_SCOPEENUM_UNNEST( QgsMapLayer ) : int
enum class QgsMapLayerType SIP_MONKEYPATCH_SCOPEENUM_UNNEST( QgsMapLayer, LayerType ) : int
{
VectorLayer,
RasterLayer,

0 comments on commit 9a6ddbd

Please sign in to comment.
You can’t perform that action at this time.