- Updated API files
- Don't check the *.spec.c files
- Better parsing of strings
- Better documentation checking
- Minor bug fixes
diff --git a/tools/winapi_check/winapi_parser.pm b/tools/winapi_check/winapi_parser.pm
index bb8d198..e8b263c 100644
--- a/tools/winapi_check/winapi_parser.pm
+++ b/tools/winapi_check/winapi_parser.pm
@@ -10,6 +10,7 @@
my $preprocessor_found_callback = shift;
my $documentation;
+ my $linkage;
my $return_type;
my $calling_convention;
my $function = "";
@@ -18,6 +19,7 @@
my $function_begin = sub {
$documentation = shift;
+ $linkage = shift;
$return_type= shift;
$calling_convention = shift;
$function = shift;
@@ -26,7 +28,7 @@
$statements = "";
};
my $function_end = sub {
- &$function_found_callback($documentation,$return_type,$calling_convention,$function,$arguments,$statements);
+ &$function_found_callback($documentation,$linkage,$return_type,$calling_convention,$function,$arguments,$statements);
$function = "";
};
@@ -53,7 +55,7 @@
$lookahead_count = 0;
}
$lookahead_count++;
- print "$level: $line\n" if $options->debug >= 2;
+ print " $level: $line\n" if $options->debug >= 2;
} else {
$lookahead_count = 0;
$again = 0;
@@ -94,7 +96,7 @@
my $documentation;
{
my $n = $#comments;
- while($n >= 0 && $comments[$n] !~ /\/\*\*/) { $n-- }
+ while($n >= 0 && ($comments[$n] !~ /^\/\*\*/ || $comments[$n] =~ /^\/\*\*+\//)) { $n-- }
if(defined($comments[$n]) && $n >= 0) {
$documentation = $comments[$n];
} else {
@@ -104,45 +106,90 @@
if($level > 0)
{
- my $line;
- s/^([^\{\}]*)//s;
- $line = $1;
- if(/^(\{)/) {
- $_ = $'; $again = 1;
+ my $line = "";
+ while(/^[^\{\}]/) {
+ s/^([^\{\}\'\"]*)//s;
$line .= $1;
- print "+1: $_\n" if $options->debug >= 2;
- $level++;
- } elsif(/^(\})/) {
+ if(s/^\'//) {
+ $line .= "\'";
+ while(/^./ && !s/^\'//) {
+ s/^([^\'\\]*)//s;
+ $line .= $1;
+ if(s/^\\//) {
+ $line .= "\\";
+ if(s/^(.)//s) {
+ $line .= $1;
+ if($1 eq "0") {
+ s/^(\d{0,3})//s;
+ $line .= $1;
+ }
+ }
+ }
+ }
+ $line .= "\'";
+ } elsif(s/^\"//) {
+ $line .= "\"";
+ while(/^./ && !s/^\"//) {
+ s/^([^\"\\]*)//s;
+ $line .= $1;
+ if(s/^\\//) {
+ $line .= "\\";
+ if(s/^(.)//s) {
+ $line .= $1;
+ if($1 eq "0") {
+ s/^(\d{0,3})//s;
+ $line .= $1;
+ }
+ }
+ }
+ }
+ $line .= "\"";
+ }
+ }
+
+ if(s/^\{//) {
$_ = $'; $again = 1;
- $line .= $1 if $level > 1;
- print "-1: $_\n" if $options->debug >= 2;
+ $line .= "{";
+ print "+1: \{$_\n" if $options->debug >= 2;
+ $level++;
+ } elsif(s/^\}//) {
+ $_ = $'; $again = 1;
+ $line .= "}" if $level > 1;
+ print "-1: \}$_\n" if $options->debug >= 2;
$level--;
}
+
if($line !~ /^\s*$/) {
$statements .= "$line\n";
- }
+ }
+
if($function && $level == 0) {
&$function_end;
}
next;
- } elsif(/((struct\s+|union\s+|enum\s+)?\w+((\s*\*)+\s*|\s+))((__cdecl|__stdcall|VFWAPIV|VFWAPI|WINAPIV|WINAPI)\s+)?(\w+(\(\w+\))?)\s*\(([^\)]*)\)\s*(\{|\;)/s) {
+ } elsif(/(extern\s+|static\s+)?((struct\s+|union\s+|enum\s+)?\w+((\s*\*)+\s*|\s+))((__cdecl|__stdcall|VFWAPIV|VFWAPI|WINAPIV|WINAPI)\s+)?(\w+(\(\w+\))?)\s*\(([^\)]*)\)\s*(\{|\;)/s) {
$_ = $'; $again = 1;
-
- if($10 eq ";") {
- next;
- } elsif($10 eq "{") {
- $level++;
- }
- my $return_type = $1;
- my $calling_convention = $6;
- my $name = $7;
- my $arguments = $9;
+ if($11 eq "{") {
+ $level++;
+ }
+
+ my $linkage = $1;
+ my $return_type = $2;
+ my $calling_convention = $7;
+ my $name = $8;
+ my $arguments = $10;
+
+ if(!defined($linkage)) {
+ $linkage = "";
+ }
if(!defined($calling_convention)) {
$calling_convention = "";
}
+ $linkage =~ s/\s*$//;
+
$return_type =~ s/\s*$//;
$return_type =~ s/\s*\*\s*/*/g;
$return_type =~ s/(\*+)/ $1/g;
@@ -180,76 +227,83 @@
if($options->debug) {
print "$file: $return_type $calling_convention $name(" . join(",", @arguments) . ")\n";
}
- &$function_begin($documentation,$return_type,$calling_convention,$name,\@arguments);
+ &$function_begin($documentation,$linkage,$return_type,$calling_convention,$name,\@arguments);
+ if($level == 0) {
+ &$function_end;
+ }
} elsif(/DC_(GET_X_Y|GET_VAL_16)\s*\(\s*(.*?)\s*,\s*(.*?)\s*,\s*(.*?)\s*\)/s) {
$_ = $'; $again = 1;
my @arguments = ("HDC16");
- &$function_begin($documentation,$2, "WINAPI", $3, \@arguments);
+ &$function_begin($documentation, "", $2, "WINAPI", $3, \@arguments);
&$function_end;
} elsif(/DC_(GET_VAL_32)\s*\(\s*(.*?)\s*,\s*(.*?)\s*,.*?\)/s) {
$_ = $'; $again = 1;
my @arguments = ("HDC");
- &$function_begin($documentation,$2, "WINAPI", $3, \@arguments);
+ &$function_begin($documentation, "", $2, "WINAPI", $3, \@arguments);
&$function_end;
} elsif(/DC_(GET_VAL_EX)\s*\(\s*(.*?)\s*,\s*(.*?)\s*,\s*(.*?)\s*,\s*(.*?)\s*\)/s) {
$_ = $'; $again = 1;
my @arguments16 = ("HDC16", "LP" . $5 . "16");
my @arguments32 = ("HDC", "LP" . $5);
- &$function_begin($documentation,"BOOL16", "WINAPI", $2 . "16", \@arguments16);
+ &$function_begin($documentation, "", "BOOL16", "WINAPI", $2 . "16", \@arguments16);
&$function_end;
- &$function_begin($documentation,"BOOL", "WINAPI", $2, \@arguments32);
+ &$function_begin($documentation, "", "BOOL", "WINAPI", $2, \@arguments32);
&$function_end;
} elsif(/DC_(SET_MODE)\s*\(\s*(.*?)\s*,\s*(.*?)\s*,\s*(.*?)\s*,\s*(.*?)\s*\)/s) {
$_ = $'; $again = 1;
my @arguments16 = ("HDC16", "INT16");
my @arguments32 = ("HDC", "INT");
- &$function_begin($documentation,"INT16", "WINAPI", $2 . "16", \@arguments16);
+ &$function_begin($documentation, "", "INT16", "WINAPI", $2 . "16", \@arguments16);
&$function_end;
- &$function_begin($documentation,"INT", "WINAPI", $2, \@arguments32);
+ &$function_begin($documentation, "", "INT", "WINAPI", $2, \@arguments32);
&$function_end;
} elsif(/WAVEIN_SHORTCUT_0\s*\(\s*(.*?)\s*,\s*(.*?)\s*\)/s) {
$_ = $'; $again = 1;
my @arguments16 = ("HWAVEIN16");
my @arguments32 = ("HWAVEIN");
- &$function_begin($documentation,"UINT16", "WINAPI", "waveIn" . $1 . "16", \@arguments16);
+ &$function_begin($documentation, "", "UINT16", "WINAPI", "waveIn" . $1 . "16", \@arguments16);
&$function_end;
- &$function_begin($documentation,"UINT", "WINAPI", "waveIn" . $1, \@arguments32);
+ &$function_begin($documentation, "", "UINT", "WINAPI", "waveIn" . $1, \@arguments32);
&$function_end;
} elsif(/WAVEOUT_SHORTCUT_0\s*\(\s*(.*?)\s*,\s*(.*?)\s*\)/s) {
$_ = $'; $again = 1;
my @arguments16 = ("HWAVEOUT16");
my @arguments32 = ("HWAVEOUT");
- &$function_begin($documentation,"UINT16", "WINAPI", "waveOut" . $1 . "16", \@arguments16);
+ &$function_begin($documentation, "", "UINT16", "WINAPI", "waveOut" . $1 . "16", \@arguments16);
&$function_end;
- &$function_begin($documentation,"UINT", "WINAPI", "waveOut" . $1, \@arguments32);
+ &$function_begin($documentation, "", "UINT", "WINAPI", "waveOut" . $1, \@arguments32);
&$function_end;
} elsif(/WAVEOUT_SHORTCUT_(1|2)\s*\(\s*(.*?)\s*,\s*(.*?)\s*,\s*(.*?)\s*\)/s) {
$_ = $'; $again = 1;
if($1 eq "1") {
my @arguments16 = ("HWAVEOUT16", $4);
my @arguments32 = ("HWAVEOUT", $4);
- &$function_begin($documentation,"UINT16", "WINAPI", "waveOut" . $2 . "16", \@arguments16);
+ &$function_begin($documentation, "", "UINT16", "WINAPI", "waveOut" . $2 . "16", \@arguments16);
&$function_end;
- &$function_begin($documentation,"UINT", "WINAPI", "waveOut" . $2, \@arguments32);
+ &$function_begin($documentation, "", "UINT", "WINAPI", "waveOut" . $2, \@arguments32);
&$function_end;
} elsif($1 eq 2) {
my @arguments16 = ("UINT16", $4);
my @arguments32 = ("UINT", $4);
- &$function_begin($documentation,"UINT16", "WINAPI", "waveOut". $2 . "16", \@arguments16);
+ &$function_begin($documentation, "", "UINT16", "WINAPI", "waveOut". $2 . "16", \@arguments16);
&$function_end;
- &$function_begin($documentation,"UINT", "WINAPI", "waveOut" . $2, \@arguments32);
+ &$function_begin($documentation, "", "UINT", "WINAPI", "waveOut" . $2, \@arguments32);
&$function_end;
}
} elsif(/DEFINE_REGS_ENTRYPOINT_\d+\(\s*(\S*)\s*,\s*([^\s,\)]*).*?\)/s) {
$_ = $'; $again = 1;
$regs_entrypoints{$2} = $1;
+ } elsif(/\'[^\']*\'/s) {
+ $_ = $'; $again = 1;
+ } elsif(/\"[^\"]*\"/s) {
+ $_ = $'; $again = 1;
} elsif(/;/s) {
$_ = $'; $again = 1;
- } elsif(/\{/s) {
- $_ = $'; $again = 1;
- print "+1: $_\n" if $options->debug >= 2;
- $level++;
+ } elsif(/\{/s) {
+ $_ = $'; $again = 1;
+ print "+1: $_\n" if $options->debug >= 2;
+ $level++;
} else {
$lookahead = 1;
}