sipify improvements

* reset comment while changing section
 * fix comment at the end of a comment block
 * use SIP_FORCE to show private members
This commit is contained in:
Denis Rouzaud 2017-04-24 08:48:12 +02:00
parent 68e0a62716
commit 6e7b753ceb
4 changed files with 22 additions and 1 deletions

View File

@ -127,6 +127,7 @@ while ($line_idx < $line_count){
}
elsif ( $line =~ m/^\s*#endif/ ){
if ( $nesting_index == 0 ){
$comment = '';
$SIP_RUN = 0;
last;
}
@ -156,6 +157,7 @@ while ($line_idx < $line_count){
}
elsif ( $line =~ m/^\s*#endif/ ){
if ( $nesting_index == 0 ){
$comment = '';
$SIP_RUN = 0;
last;
}
@ -205,18 +207,26 @@ while ($line_idx < $line_count){
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
@ -236,7 +246,7 @@ while ($line_idx < $line_count){
$line = $lines[$line_idx];
$line_idx++;
$comment .= processDoxygenLine( $line =~ s/\s*\*?(.*?)(\/)?\n?$/$1/r );
if ( $line =~ m/\*\/$/ ){
if ( $line =~ m/\*\/\s*(\/\/.*?)?$/ ){
last;
}
}
@ -467,6 +477,8 @@ while ($line_idx < $line_count){
$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\//;

View File

@ -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
*/

View File

@ -262,6 +262,8 @@ Removing function body with virtual const reference
public:
void FallBackToPublic();
private:
void ShowThisPrivateOne() ;
};
class ClassWithPrivateInheritanceOnly

View File

@ -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;