@@ -78,7 +78,7 @@ sub processDoxygenLine
78
78
sub dbg
79
79
{
80
80
my $msg = ' ' ;
81
- $debug == 0 or $msg = sprintf (" %-4s %-1d %-1d " , $_ [0], $SIP_RUN , $MULTILINE_DEFINITION );
81
+ $debug == 0 or $msg = sprintf (" %d % -4s %-1d %-1d " , $line_idx , $_ [0], $SIP_RUN , $MULTILINE_DEFINITION );
82
82
return $msg ;
83
83
}
84
84
sub dbg_info
@@ -89,6 +89,42 @@ sub dbg_info
89
89
}
90
90
}
91
91
92
+ sub remove_constructor_or_body {
93
+ # https://regex101.com/r/ZaP3tC/1
94
+ do {no warnings ' uninitialized' ;
95
+ if ( $line =~ m / ^(\s *)?(explicit )?(virtual )?(static |const )*(([\w :]+(<.*?>)?\s +(\* |&)?)?(~?\w +|operator.{1,2})\( ([\w =()\/ ,&*<>-]|::)*\) ( (?:const|SIP_[A-Z_]*?))*)\s *((\s *[:,]\s +\w +\( .*\) )*\s *\{ .*\} ;?|(?!;))(\s *\/\/ .*)?$ /
96
+ || $line =~ m / SIP_SKIP\s *(?!;)\s *(\/\/ .*)?$ / ){
97
+ dbg_info(" remove constructor definition, function bodies, member initializing list" );
98
+ my $newline = " $1$2$3$4$5 ;" ;
99
+ if ($line !~ m / {.*}(\s *SIP_\w +)?\s *(\/\/ .*)?$ / ){
100
+ dbg_info(" go for multiline" );
101
+ $line = $lines [$line_idx ];
102
+ $line_idx ++;
103
+ while ( $line =~ m / ^\s *[:,] \s +[\w <>] +\( .*?\) / ){
104
+ dbg_info(" member initializing list" );
105
+ $line = $lines [$line_idx ];
106
+ $line_idx ++;
107
+ }
108
+ if ( $line =~ m / ^\s *\{ / ){
109
+ my $nesting_index = 0;
110
+ while ($line_idx < $line_count ){
111
+ dbg_info(" remove body" );
112
+ $nesting_index += $line =~ tr / \{// ;
113
+ $nesting_index -= $line =~ tr / \}// ;
114
+ if ($nesting_index == 0){
115
+ last ;
116
+ }
117
+ $line = $lines [$line_idx ];
118
+ $line_idx ++;
119
+ }
120
+ }
121
+ }
122
+ $line = $newline ;
123
+ }
124
+ };
125
+ }
126
+
127
+
92
128
# main loop
93
129
while ($line_idx < $line_count ){
94
130
$line = $lines [$line_idx ];
@@ -233,46 +269,23 @@ sub dbg_info
233
269
234
270
# SIP_SKIP
235
271
if ( $line =~ m / SIP_SKIP/ ){
236
- $comment = ' ' ;
237
- # if multiline definition, remove previous lines
238
- if ( $MULTILINE_DEFINITION == 1){
239
- my $opening_line = ' ' ;
240
- while ( $opening_line !~ m / ^[^()] *\( ([^()]*\( [^()]*\) [^()]*)*[^()] *$ / ){
241
- $opening_line = pop (@output );
242
- $#output >= 0 or die ' could not reach opening definition' ;
243
- }
272
+ dbg_info(' SIP SKIP!' );
273
+ $comment = ' ' ;
274
+ # if multiline definition, remove previous lines
275
+ if ( $MULTILINE_DEFINITION == 1){
276
+ dbg_info(' SIP_SKIP with MultiLine' );
277
+ my $opening_line = ' ' ;
278
+ while ( $opening_line !~ m / ^[^()] *\( ([^()]*\( [^()]*\) [^()]*)*[^()] *$ / ){
279
+ $opening_line = pop (@output );
280
+ $#output >= 0 or die ' could not reach opening definition' ;
281
+ }
244
282
dbg_info(" removed multiline definition of SIP_SKIP method" );
245
283
$MULTILINE_DEFINITION = 0;
246
- }
247
- # also skip method body if there is one
248
- if ($lines [$line_idx ] =~ m / ^\s *\{ / ){
249
- my $nesting_index = 0;
250
- dbg_info(" skipping method body of SIP_SKIP method" );
251
- while ($line_idx < $line_count ){
252
- $line = $lines [$line_idx ];
253
- $line_idx ++;
254
- if ( $nesting_index == 0 ){
255
- if ( $line =~ m / ^\s *(:|,)/ ){
256
- next ;
257
- }
258
- $line =~ m / ^\s *\{ / or die ' Constructor definition misses {' ;
259
- if ( $line =~ m / ^\s *\{ .*?\} / ){
260
- last ;
261
- }
262
- $nesting_index = 1;
263
- next ;
264
- }
265
- else {
266
- $nesting_index += $line =~ tr / \{// ;
267
- $nesting_index -= $line =~ tr / \}// ;
268
- if ($nesting_index eq 0){
269
- last ;
270
- }
271
- }
272
284
}
273
- }
274
- # line skipped, go to next iteration
275
- next ;
285
+ # also skip method body if there is one
286
+ remove_constructor_or_body();
287
+ # line skipped, go to next iteration
288
+ next ;
276
289
}
277
290
278
291
# Detect comment block
@@ -305,12 +318,14 @@ sub dbg_info
305
318
pop (@global_bracket_nesting_index );
306
319
pop (@ACCESS );
307
320
}
308
- else {
321
+ if ($#ACCESS == 1){
322
+ dbg_info(" reached top level" );
309
323
# top level should stasy public
310
324
dbg_info
311
325
$ACCESS [$#ACCESS ] = PUBLIC;
312
326
$comment = ' ' ;
313
327
}
328
+ $private_section_line = ' ' ;
314
329
}
315
330
dbg_info(" new bracket balance: @global_bracket_nesting_index " );
316
331
}
@@ -495,35 +510,7 @@ sub dbg_info
495
510
$line =~ s /\s *=\s *default\b // g ;
496
511
497
512
# remove constructor definition, function bodies, member initializing list
498
- # https://regex101.com/r/ZaP3tC/1
499
- if ( $SIP_RUN != 1 && $line =~ m / ^(\s *)?(explicit )?(virtual )?(static |const )*(([\w :]+(<.*?>)?\s +(\* |&)?)?(~?\w +|operator.{1,2})\( ([\w =()\/ ,&*<>-]|::)*\) ( (?:const|SIP_[A-Z_]*?))*)\s *((\s *[:,]\s +\w +\( .*\) )*\s *\{ .*\} ;?|(?!;))(\s *\/\/ .*)?$ / ){
500
- dbg_info(" remove constructor definition, function bodies, member initializing list" );
501
- my $newline = " $1$2$3$4$5 ;" ;
502
- if ($line !~ m /\{ .*?\}\s *(\/\/ .*)?$ / ){
503
- dbg_info(" go for multiline" );
504
- $line = $lines [$line_idx ];
505
- $line_idx ++;
506
- while ( $line =~ m / ^\s *[:,] \s +[\w <>] +\( .*?\) / ){
507
- dbg_info(" member initializing list" );
508
- $line = $lines [$line_idx ];
509
- $line_idx ++;
510
- }
511
- my $nesting_index = 1;
512
- if ( $line =~ m / ^\s *\{ $ / ){
513
- while ($line_idx < $line_count ){
514
- dbg_info(" remove body" );
515
- $line = $lines [$line_idx ];
516
- $line_idx ++;
517
- $nesting_index += $line =~ tr / \{// ;
518
- $nesting_index -= $line =~ tr / \}// ;
519
- if ($nesting_index == 0){
520
- last ;
521
- }
522
- }
523
- }
524
- }
525
- $line = $newline ;
526
- }
513
+ $SIP_RUN == 1 or remove_constructor_or_body();
527
514
528
515
# remove inline declarations
529
516
if ( $line =~ m / ^(\s *)?(static |const )*(([\w :]+(<.*?>)?\s +(\* |&)?)?(\w +)( (?:const*?))*)\s *(\{ .*\} );(\s *\/\/ .*)?$ / ){
0 commit comments