Skip to content

Commit

Permalink
[sipify] fix SIP new restrictions on Docstrings
Browse files Browse the repository at this point in the history
class members, operators cannot be documented anymore
  • Loading branch information
3nids committed Jan 9, 2018
1 parent b355886 commit 9deef83
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions scripts/sipify.pl
Expand Up @@ -67,13 +67,14 @@
sub read_line { sub read_line {
my $new_line = $INPUT_LINES[$LINE_IDX]; my $new_line = $INPUT_LINES[$LINE_IDX];
$LINE_IDX++; $LINE_IDX++;
$debug == 0 or print sprintf('LIN:%d DEPTH:%d ACC:%d BRCK:%d SIP:%d MLT:%d CLSS: %s/%d', $debug == 0 or print sprintf('LIN:%d DEPTH:%d ACC:%d BRCK:%d SIP:%d MLT:%d OVR: %d CLSS: %s/%d',
$LINE_IDX, $LINE_IDX,
$#ACCESS, $#ACCESS,
$ACCESS[$#ACCESS], $ACCESS[$#ACCESS],
$GLOB_BRACKET_NESTING_IDX[$#GLOB_BRACKET_NESTING_IDX], $GLOB_BRACKET_NESTING_IDX[$#GLOB_BRACKET_NESTING_IDX],
$SIP_RUN, $SIP_RUN,
$MULTILINE_DEFINITION, $MULTILINE_DEFINITION,
$IS_OVERRIDE,
$ACTUAL_CLASS, $ACTUAL_CLASS,
$#CLASSNAME)." :: ".$new_line."\n"; $#CLASSNAME)." :: ".$new_line."\n";
return $new_line; return $new_line;
Expand Down Expand Up @@ -358,6 +359,12 @@ sub detect_comment_block{
return 0; return 0;
} }


# Detect if line is a non method member declaration
# https://regex101.com/r/gUBZUk/10
sub detect_non_method_member{
return 1 if $LINE =~ m/^\s*(?:template\s*<\w+>\s+)?(?:(const|mutable|static|friend|unsigned)\s+)*\w+(::\w+)?(<([\w<> *&,()]|::)+>)?(,?\s+\*?\w+( = (-?\d+(\.\d+)?|(\w+::)*\w+(\([^()]+\))?)|\[\d+\])?)+;/;
return 0;
}




write_header_footer(); write_header_footer();
Expand Down Expand Up @@ -806,10 +813,9 @@ sub detect_comment_block{
} }


# skip non-method member declaration in non-public sections # skip non-method member declaration in non-public sections
# https://regex101.com/r/gUBZUk/10
if ( $SIP_RUN != 1 && if ( $SIP_RUN != 1 &&
$ACCESS[$#ACCESS] != PUBLIC && $ACCESS[$#ACCESS] != PUBLIC &&
$LINE =~ m/^\s*(?:template\s*<\w+>\s+)?(?:(const|mutable|static|friend|unsigned)\s+)*\w+(::\w+)?(<([\w<> *&,()]|::)+>)?(,?\s+\*?\w+( = (-?\d+(\.\d+)?|(\w+::)*\w+(\([^()]+\))?)|\[\d+\])?)+;/){ detect_non_method_member() == 1){
dbg_info("skip non-method member declaration in non-public sections"); dbg_info("skip non-method member declaration in non-public sections");
next; next;
} }
Expand Down Expand Up @@ -969,19 +975,20 @@ sub detect_comment_block{
# do not comment now for templates, wait for class definition # do not comment now for templates, wait for class definition
next; next;
} }
if ( $LINE =~ m/^\s*namespace\s+\w+/){
$COMMENT = '';
}
if ( $LINE =~ m/\/\// || if ( $LINE =~ m/\/\// ||
$LINE =~ m/\s*typedef / || $LINE =~ m/\s*typedef / ||
$LINE =~ m/\s*struct / || $LINE =~ m/\s*struct / ||
$LINE =~ m/operator\[\]\(/ || $LINE =~ m/operator\[\]\(/ ||
$LINE =~ m/operator==/ || $LINE =~ m/^\s*operator\b/ ||
($LINE =~ m/operator[!+-=*\/\[\]]{1,2}/ && $#ACCESS == 0) || # apparently global operators cannot be documented $LINE =~ m/operator\s?[!+-=*\/\[\]<>]{1,2}/ ||
$LINE =~ m/^\s*%\w+(.*)?$/ ){ $LINE =~ m/^\s*%\w+(.*)?$/ ||
$LINE =~ m/^\s*namespace\s+\w+/ ||
$LINE =~ m/^\s*(virtual\s*)?~/ ||
detect_non_method_member() == 1 ){
dbg_info('skipping comment'); dbg_info('skipping comment');
$COMMENT = ''; $COMMENT = '';
$RETURN_TYPE = ''; $RETURN_TYPE = '';
$IS_OVERRIDE = 0;
} }
elsif ( $COMMENT !~ m/^\s*$/ || $RETURN_TYPE ne ''){ elsif ( $COMMENT !~ m/^\s*$/ || $RETURN_TYPE ne ''){
if ( $IS_OVERRIDE == 1 && $COMMENT =~ m/^\s*$/ ){ if ( $IS_OVERRIDE == 1 && $COMMENT =~ m/^\s*$/ ){
Expand Down

0 comments on commit 9deef83

Please sign in to comment.