Commit 4bb532e7 authored by Patrik Stridvall's avatar Patrik Stridvall Committed by Alexandre Julliard

- Updated API files

- Don't check the *.spec.c files - Better parsing of strings - Better documentation checking - Minor bug fixes
parent c287e9fe
......@@ -6,7 +6,7 @@ HCONVLIST
HDDEDATA
HSZ
%long # --forbidden
%long --forbidden
int
......
......@@ -24,7 +24,7 @@ LPARAM
UINT
WORD
%long # --forbidden
%long --forbidden
int
......
......@@ -87,7 +87,6 @@ LPDEBUG_EVENT
LPDWORD
LPFILETIME
LPINPUT_RECORD
LPLONG
LPLDT_ENTRY
LPMEMORYSTATUS
LPMEMORY_BASIC_INFORMATION
......
......@@ -69,7 +69,6 @@ LPOLEINPLACEFRAMEINFO
LPOLEMENUGROUPWIDTHS
LPOLEOBJECT
LPOLESTREAM
LPOLESTR
LPOLESTR *
LPPERSISTSTORAGE
LPRUNNINGOBJECTTABLE *
......@@ -91,13 +90,10 @@ WORD *
void *
void **
%str
%str # ???
LPCOLESTR
%str # --forbidden
LPOLESTR16
LPOLESTR
%void
......
......@@ -56,7 +56,6 @@ LPCLSID
LPDWORD
LPFONTDESC
LPOCPFIPARAMS
LPOLESTR
LPPICTDESC
LPSTREAM
LPUNKNOWN
......@@ -84,6 +83,7 @@ void **
%str # ???
LPCOLESTR
LPOLESTR
%void
......
......@@ -27,6 +27,7 @@ HMONITOR
HRESULT
HRGN
HSZ
HTASK
HWINSTA
HWND
INT
......@@ -39,10 +40,9 @@ WCHAR
WORD
WPARAM
%long # --forbidden
%long --forbidden
HMODULE16
HTASK
int
%longlong
......
......@@ -12,6 +12,7 @@ HMIXER
HMIXEROBJ
HMMIO
HMODULE
HTASK
HWAVEIN
HWAVEOUT
HWND
......@@ -22,10 +23,9 @@ LPARAM
LRESULT
UINT
%long # --forbidden
%long --forbidden
HMMIO16
HTASK
UINT16
%ptr
......
......@@ -91,10 +91,10 @@ my %includes;
my $header = $1;
if(-e "$file_dir/$header") {
$includes{$file}{includes}{"$file_dir/$header"}++;
} elsif(-e "include/$header") {
} elsif(-e "$wine_dir/include/$header") {
$includes{$file}{includes}{"include/$header"}++;
} else {
$output->write("$file: #include \"$header\" is not a local include\n");
} else {
$output->write("$file: #include \"$header\" is not a local include ($file_dir)\n");
}
}
}
......@@ -138,6 +138,7 @@ foreach my $file ($options->files) {
my $found_function = sub {
my $documentation = shift;
my $linkage = shift;
my $return_type = shift;
my $calling_convention = shift;
my $name = shift;
......@@ -165,6 +166,7 @@ foreach my $file ($options->files) {
$functions{$name} = $function;
$function->documentation($documentation);
$function->linkage($linkage);
$function->file($file);
$function->return_type($return_type);
$function->calling_convention($calling_convention);
......@@ -234,25 +236,72 @@ foreach my $file ($options->files) {
}
}
if($options->documentation && (defined($module16) || defined($module32))) {
my $name2 = $name;
my $name3 = $name;
my $name4 = $name;
my $name5 = $name;
if($options->documentation && (defined($module16) || defined($module32)) &&
$linkage ne "extern" && $statements ne "")
{
my $name1;
my $name2;
my $name3;
my $name4;
my $name5;
if(defined($module16) && !defined($module32)) {
my @uc_modules16 = split(/\s*\&\s*/, uc($module16));
push @uc_modules16, "WIN16";
$name1 = $name;
foreach my $uc_module16 (@uc_modules16) {
if($name1 =~ s/^$uc_module16\_//) { last; }
}
$name2 = $name1;
$name2 =~ s/([AW])$/16$1/;
$name3 =~ s/16(([AW])?)$/$1/;
$name4 =~ s/^\U$module16\E\_//;
$name5 =~ s/^WIN16_//;
$name3 = $name1;
$name3 =~ s/16(([AW])?)$/$1/;
$name4 = $name1;
$name4 =~ s/^(.*?)(?:16)?$/\U$1\E/;
$name5 = $name1;
$name5 = s/^(.*?)16_fn(.*?)$/$116_$2/;
} elsif(!defined($module16) && defined($module32)) {
my @uc_modules32 = split(/\s*\&\s*/, uc($module32));
$name1 = $name;
foreach my $uc_module32 (@uc_modules32) {
if($name1 =~ s/^$uc_module32\_//) { last; }
}
$name2 = $name1;
$name2 =~ s/([AW])$/32$1/;
$name3 = $name1;
$name3 =~ s/32(([AW])?)$/$1/;
$name4 =~ s/^\U$module32\E\_//;
$name5 =~ s/^WIN16_//;
$name4 = $name1;
$name4 =~ s/AW$//;
$name5 = $name1;
} else {
my @uc_modules = split(/\s*\&\s*/, uc($module16));
push @uc_modules, split(/\s*\&\s*/, uc($module32));
$name1 = $name;
foreach my $uc_module (@uc_modules) {
if($name1 =~ s/^$uc_module\_//) { last; }
}
$name2 = $name1;
$name3 = $name1;
$name4 = $name1;
$name5 = $name1;
}
if($name !~ /^SMapLS|SUnMapLS/ && $documentation !~ /($name|$name2|$name3|$name4|$name5)/) {
if($name !~ /^SMapLS|SUnMapLS/ && $documentation !~ /($name|$name1|$name2|$name3|$name4|$name5)/) {
$output->write("$file: $name: \\\n");
$output->write("$documentation\n");
}
......@@ -313,7 +362,9 @@ foreach my $file ($options->files) {
if($check_protection) {
if((-e "$wine_dir/include/$header" || -e "$file_dir/$header")) {
$output->write("$file: #include \<$header\> is a local include\n");
if($header !~ /^ctype.h$/) {
$output->write("$file: #include \<$header\> is a local include\n");
}
}
my $macro = uc($header);
......
......@@ -33,6 +33,17 @@ sub documentation {
return $$documentation;
}
sub linkage {
my $self = shift;
my $linkage = \${$self->{LINKAGE}};
local $_ = shift;
if(defined($_)) { $$linkage = $_; }
return $$linkage;
}
sub return_type {
my $self = shift;
my $return_type = \${$self->{RETURN_TYPE}};
......
......@@ -175,7 +175,11 @@ sub new {
@$files = map {
s/^.\/(.*)$/$1/;
$_;
if(!/spec\.c$/) {
$_;
} else {
();
}
} split(/\n/, `find $paths -name \\*.c`);
return $self;
......
......@@ -10,6 +10,7 @@ sub parse_c_file {
my $preprocessor_found_callback = shift;
my $documentation;
my $linkage;
my $return_type;
my $calling_convention;
my $function = "";
......@@ -18,6 +19,7 @@ sub parse_c_file {
my $function_begin = sub {
$documentation = shift;
$linkage = shift;
$return_type= shift;
$calling_convention = shift;
$function = shift;
......@@ -26,7 +28,7 @@ sub parse_c_file {
$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 @@ sub parse_c_file {
$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 @@ sub parse_c_file {
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 @@ sub parse_c_file {
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;
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 .= "{";
print "+1: \{$_\n" if $options->debug >= 2;
$level++;
} elsif(/^(\})/) {
} elsif(s/^\}//) {
$_ = $'; $again = 1;
$line .= $1 if $level > 1;
print "-1: $_\n" if $options->debug >= 2;
$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 "{") {
if($11 eq "{") {
$level++;
}
}
my $return_type = $1;
my $calling_convention = $6;
my $name = $7;
my $arguments = $9;
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 @@ sub parse_c_file {
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) {
} elsif(/\'[^\']*\'/s) {
$_ = $'; $again = 1;
} elsif(/\{/s) {
} 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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment