Skip to content

Commit

Permalink
sipify improvements
Browse files Browse the repository at this point in the history
 * reset comment while changing section
 * fix comment at the end of a comment block
 * use SIP_FORCE to show private members
  • Loading branch information
3nids committed Apr 24, 2017
1 parent 68e0a62 commit 6e7b753
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
14 changes: 13 additions & 1 deletion scripts/sipify.pl
Expand Up @@ -127,6 +127,7 @@ sub processDoxygenLine
}
elsif ( $line =~ m/^\s*#endif/ ){
if ( $nesting_index == 0 ){
$comment = '';
$SIP_RUN = 0;
last;
}
Expand Down Expand Up @@ -156,6 +157,7 @@ sub processDoxygenLine
}
elsif ( $line =~ m/^\s*#endif/ ){
if ( $nesting_index == 0 ){
$comment = '';
$SIP_RUN = 0;
last;
}
Expand Down Expand Up @@ -205,18 +207,26 @@ sub processDoxygenLine
if ( $line =~ m/^\s*private( slots)?:/ ){
$ACCESS = PRIVATE;
$private_section_line = $line;
$comment = '';
next;
}
elsif ( $line =~ m/^\s*(public)( slots)?:.*$/ ){
$ACCESS = PUBLIC;
$comment = '';
}
elsif ( $line =~ m/^\};.*$/ ) {
$ACCESS = PUBLIC;
$comment = '';
}
elsif ( $line =~ m/^\s*(protected)( slots)?:.*$/ ){
$ACCESS = PROTECTED;
$comment = '';
}
elsif ( $ACCESS == PRIVATE && $line =~ m/SIP_FORCE/){
push @output, $private_section_line."\n";
}
elsif ( $ACCESS == PRIVATE && $SIP_RUN == 0 ) {
$comment = '';
next;
}
# Skip assignment operator
Expand All @@ -236,7 +246,7 @@ sub processDoxygenLine
$line = $lines[$line_idx];
$line_idx++;
$comment .= processDoxygenLine( $line =~ s/\s*\*?(.*?)(\/)?\n?$/$1/r );
if ( $line =~ m/\*\/$/ ){
if ( $line =~ m/\*\/\s*(\/\/.*?)?$/ ){
last;
}
}
Expand Down Expand Up @@ -467,6 +477,8 @@ sub processDoxygenLine
$line =~ s/(\w+)(\<(?>[^<>]|(?2))*\>)?\s+SIP_PYTYPE\(\s*\'?([^()']+)(\(\s*(?:[^()]++|(?2))*\s*\))?\'?\s*\)/$3/g;
$line =~ s/=\s+[^=]*?\s+SIP_PYDEFAULTVALUE\(\s*\'?([^()']+)(\(\s*(?:[^()]++|(?2))*\s*\))?\'?\s*\)/= $1/g;

$line =~ s/SIP_FORCE//;

# fix astyle placing space after % character
$line =~ s/\s*% (MappedType|TypeHeaderCode|ConvertFromTypeCode|ConvertToTypeCode|MethodCode|End)/%$1/;
$line =~ s/\/\s+GetWrapper\s+\//\/GetWrapper\//;
Expand Down
5 changes: 5 additions & 0 deletions src/core/qgis.h
Expand Up @@ -438,6 +438,11 @@ typedef unsigned long long qgssize;
*/
#define SIP_SKIP

/*
* force a private line to be written
*/
#define SIP_FORCE

/*
* specify an alternative type for SIP methods
*/
Expand Down
2 changes: 2 additions & 0 deletions tests/scripts/sipifyheader.expected.sip
Expand Up @@ -262,6 +262,8 @@ Removing function body with virtual const reference
public:
void FallBackToPublic();

private:
void ShowThisPrivateOne() ;
};

class ClassWithPrivateInheritanceOnly
Expand Down
2 changes: 2 additions & 0 deletions tests/scripts/sipifyheader.h
Expand Up @@ -272,6 +272,8 @@ class CORE_EXPORT QgsSipifyHeader : public QtClass<QVariant>, private Ui::QgsBas
void PrivateAgain();
/* Single line block comments shouldn't break the parser */

void ShowThisPrivateOne() SIP_FORCE;

struct ProcessFeatureWrapper
{
QgsGeometrySnapper *instance = nullptr;
Expand Down

0 comments on commit 6e7b753

Please sign in to comment.