@@ -51,7 +51,7 @@ sub processDoxygenLine
5151my $MULTILINE_DEFINITION = 0;
5252
5353my $comment = ' ' ;
54- my $nesting_index = 0;
54+ my $global_nesting_index = 0;
5555my $private_section_line = ' ' ;
5656my $classname = ' ' ;
5757my $return_type = ' ' ;
@@ -96,6 +96,27 @@ sub processDoxygenLine
9696
9797 # Skip preprocessor stuff
9898 if ($line =~ m / ^\s *#/ ){
99+
100+ # skip #if 0 blocks
101+ if ( $line =~ m / ^\s *#if 0/ ){
102+ my $nesting_index = 0;
103+ while ($line_idx < $line_count ){
104+ $line = $lines [$line_idx ];
105+ $line_idx ++;
106+ if ( $line =~ m / ^\s *#if(def)?\s +/ ){
107+ $nesting_index ++;
108+ }
109+ elsif ( $nesting_index == 0 && $line =~ m / ^\s *#(endif|else)/ ){
110+ $comment = ' ' ;
111+ last ;
112+ }
113+ elsif ( $nesting_index != 0 && $line =~ m / ^\s *#(endif)/ ){
114+ $nesting_index --;
115+ }
116+ }
117+ next ;
118+ }
119+
99120 if ( $line =~ m / ^\s *#ifdef SIP_RUN/ ){
100121 $SIP_RUN = 1;
101122 if ($ACCESS == PRIVATE){
@@ -105,34 +126,34 @@ sub processDoxygenLine
105126 }
106127 if ( $SIP_RUN == 1 ){
107128 if ( $line =~ m / ^\s *#endif/ ){
108- if ( $nesting_index == 0 ){
129+ if ( $global_nesting_index == 0 ){
109130 $SIP_RUN = 0;
110131 next ;
111132 }
112133 else {
113- $nesting_index --;
134+ $global_nesting_index --;
114135 }
115136 }
116137 if ( $line =~ m / ^\s *#if(def)?\s +/ ){
117- $nesting_index ++;
138+ $global_nesting_index ++;
118139 }
119140
120141 # if there is an else at this level, code will be ignored i.e. not SIP_RUN
121- if ( $line =~ m / ^\s *#else/ && $nesting_index == 0){
142+ if ( $line =~ m / ^\s *#else/ && $global_nesting_index == 0){
122143 while ($line_idx < $line_count ){
123144 $line = $lines [$line_idx ];
124145 $line_idx ++;
125146 if ( $line =~ m / ^\s *#if(def)?\s +/ ){
126- $nesting_index ++;
147+ $global_nesting_index ++;
127148 }
128149 elsif ( $line =~ m / ^\s *#endif/ ){
129- if ( $nesting_index == 0 ){
150+ if ( $global_nesting_index == 0 ){
130151 $comment = ' ' ;
131152 $SIP_RUN = 0;
132153 last ;
133154 }
134155 else {
135- $nesting_index --;
156+ $global_nesting_index --;
136157 }
137158 }
138159 }
@@ -145,9 +166,9 @@ sub processDoxygenLine
145166 $line = $lines [$line_idx ];
146167 $line_idx ++;
147168 if ( $line =~ m / ^\s *#if(def)?\s +/ ){
148- $nesting_index ++;
169+ $global_nesting_index ++;
149170 }
150- elsif ( $line =~ m / ^\s *#else/ && $nesting_index == 0 ){
171+ elsif ( $line =~ m / ^\s *#else/ && $global_nesting_index == 0 ){
151172 # code here will be printed out
152173 if ($ACCESS == PRIVATE){
153174 push @output , $private_section_line ." \n " ;
@@ -156,13 +177,13 @@ sub processDoxygenLine
156177 last ;
157178 }
158179 elsif ( $line =~ m / ^\s *#endif/ ){
159- if ( $nesting_index == 0 ){
180+ if ( $global_nesting_index == 0 ){
160181 $comment = ' ' ;
161182 $SIP_RUN = 0;
162183 last ;
163184 }
164185 else {
165- $nesting_index --;
186+ $global_nesting_index --;
166187 }
167188 }
168189 }
@@ -202,11 +223,31 @@ sub processDoxygenLine
202223 }
203224 # also skip method body if there is one
204225 if ($lines [$line_idx ] =~ m / ^\s *\{ / ){
205- while ($lines [$line_idx ] !~ m / ^\s *\} / ){
206- $line_idx ++;
226+ my $nesting_index = 0;
227+ while ($line_idx < $line_count ){
228+ $line = $lines [$line_idx ];
229+ $line_idx ++;
230+ if ( $nesting_index == 0 ){
231+ if ( $line =~ m / ^\s *(:|,)/ ){
232+ next ;
233+ }
234+ $line =~ m / ^\s *\{ / or die ' Constructor definition misses {' ;
235+ if ( $line =~ m / ^\s *\{ .*?\} / ){
236+ last ;
237+ }
238+ $nesting_index = 1;
239+ next ;
240+ }
241+ else {
242+ $nesting_index += $line =~ tr / \{// ;
243+ $nesting_index -= $line =~ tr / \}// ;
244+ if ($nesting_index eq 0){
245+ last ;
246+ }
247+ }
207248 }
208- $line_idx ++;
209249 }
250+ # line skipped, go to next iteration
210251 next ;
211252 }
212253
@@ -497,6 +538,8 @@ sub processDoxygenLine
497538 $line =~ s /\b SIP_TRANSFERTHIS\b / \/ TransferThis\/ / ;
498539 $line =~ s /\b SIP_TRANSFERBACK\b / \/ TransferBack\/ / ;
499540 $line =~ s /\b SIP_RELEASEGIL\b / \/ ReleaseGIL\/ / ;
541+ $line =~ s /\b SIP_ARRAY\b / \/ Array\/ / ;
542+ $line =~ s /\b SIP_ARRAYSIZE\b / \/ ArraySize\/ / ;
500543
501544 $line =~ s / SIP_PYNAME\(\s *(\w +)\s *\) / \/ PyName=$1 \/ / ;
502545 $line =~ s / (\w +)(\< (?>[^<>]|(?2))*\> )?\s +SIP_PYTYPE\(\s *\' ?([^()']+)(\(\s *(?:[^()]++|(?2))*\s *\) )?\' ?\s *\) / $3 / g ;
0 commit comments