From cec294e4f3aa2b2d2d1aabdd7c51810b4a9f09d8 Mon Sep 17 00:00:00 2001 From: Patrik Stridvall Date: Mon, 30 Jul 2001 18:49:10 +0000 Subject: [PATCH] A few bug fixes. --- tools/winapi/config.pm | 16 ++-- tools/winapi/make_parser.pm | 130 +++++++++++++++++++---------- tools/winapi/options.pm | 24 +++++- tools/winapi_check/modules.dat | 2 + tools/winapi_check/modules.pm | 157 ++++++++++++++++++++++-------------- tools/winapi_check/win32/ttydrv.api | 16 ++++ tools/winapi_check/win32/wineps.api | 47 +++++++++++ tools/winapi_check/win32/x11drv.api | 23 ++++++ tools/winapi_check/winapi.pm | 127 +++++++++-------------------- tools/winapi_check/winapi_check | 37 +++++---- tools/winapi_check/winapi_local.pm | 2 +- tools/winapi_check/winapi_parser.pm | 8 +- 12 files changed, 368 insertions(+), 221 deletions(-) create mode 100644 tools/winapi_check/win32/wineps.api diff --git a/tools/winapi/config.pm b/tools/winapi/config.pm index 26c56f30955..87e80d07b08 100644 --- a/tools/winapi/config.pm +++ b/tools/winapi/config.pm @@ -110,16 +110,16 @@ sub file_normalize { } sub file_directory { - my $file = shift; - $file =~ s%^./%%; + local $_ = shift; - my $dir = $file; - $dir =~ s%/?[^/]*$%%; - if(!$dir) { - $dir = "."; + s%/?[^/]*$%%; + if(!$_) { + $_ = "."; } - - return $dir; + + s%^(?:\./)?(.*?)(?:/\.)?%$1%; + + return $_; } sub _get_files { diff --git a/tools/winapi/make_parser.pm b/tools/winapi/make_parser.pm index 124f5397024..62e844da133 100644 --- a/tools/winapi/make_parser.pm +++ b/tools/winapi/make_parser.pm @@ -30,10 +30,30 @@ my $function; ######################################################################## sub error { + my $where = shift; + + if(!defined($where)) { + $where = ""; + } + + my $context; + if($tool) { + $context = "$tool"; + if($where) { + $context .= "<$where>"; + } + } else { + if($where) { + $context = "<$where>"; + } else { + $context = "<>"; + } + } + if(defined($tool)) { - $output->write("make_filter: $tool: can't parse output: '$current'\n"); + $output->write("make_filter: $context: can't parse output: '$current'\n"); } else { - $output->write("make_filter: <>: can't parse output: '$current'\n"); + $output->write("make_filter: $context: can't parse output: '$current'\n"); } exit 1; } @@ -57,20 +77,25 @@ sub line { $function = ""; + my $progress = ""; + if($directory && $directory ne ".") { + $progress .= "$directory: "; + } + $progress .= "$tool: "; + if($tool =~ /^cd|make$/) { # Nothing } elsif($tool =~ /^ld$/) { foreach my $file (@{$read_files}) { - $output->lazy_progress("$directory: ld: reading '$file'"); + $output->lazy_progress("$progress: reading '$file'"); } my $file = $$write_files[0]; - $output->progress("$directory: ld: writing '$file'"); + $output->progress("$progress: writing '$file'"); } elsif($tool =~ /^rm$/) { foreach my $file (@{$remove_files}) { - $output->lazy_progress("$directory: rm: removing '$file'"); + $output->lazy_progress("$progress: removing '$file'"); } } else { - my $progress = "$directory: $tool: "; if($#$read_files >= 0) { $progress .= "read[" . join(" ", @{$read_files}) . "]"; } @@ -89,6 +114,7 @@ sub line { $output->progress($progress); } + return 0; } @@ -102,7 +128,7 @@ sub line { $tool = "make"; make_output($1, $_); } elsif(!defined($tool)) { - error(); + error("line"); } elsif($tool eq "bison" && /^conflicts:\s+\d+\s+shift\/reduce$/) { # Nothing } elsif($tool eq "gcc" && /^In file included from (.+?):(\d+):$/) { @@ -120,7 +146,7 @@ sub line { } elsif($tool eq "cd" && s/^\/bin\/sh:\s*cd:\s*//) { parse_cd_output($_); } else { - error(); + error("line"); } $file =~ s/^\.\///; @@ -147,7 +173,7 @@ sub make_output { if(/^File \`(.+?)\' has modification time in the future \((.+?) > \(.+?\)\)$/) { # Nothing } else { - error(); + error("make_output"); } } elsif(/^\`(.*?)\' is up to date.$/) { # Nothing @@ -177,10 +203,10 @@ sub make_output { if(/^Clock skew detected. Your build may be incomplete.$/) { # Nothing } else { - error(); + error("make_output"); } } else { - error(); + error("make_output"); } } @@ -204,61 +230,61 @@ sub command { # Nothing } - if(s/^ar\s*//) { + if(s/^ar\s+//) { $tool = "ar"; ($read_files, $write_files) = ar_command($_); - } elsif(s/^as\s*//) { + } elsif(s/^as\s+//) { $tool = "as"; ($read_files, $write_files) = as_command($_); - } elsif(s/^bison\s*//) { + } elsif(s/^bison\s+//) { $tool = "bison"; ($read_files, $write_files) = bison_command($_); - } elsif(s/^cd\s*//) { + } elsif(s/^cd\s+//) { $tool = "cd"; ($read_files, $write_files) = cd_command($_); - } elsif(s/^flex\s*//) { + } elsif(s/^flex\s+//) { $tool = "flex"; ($read_files, $write_files) = flex_command($_); - } elsif(s/^for\s*//) { + } elsif(s/^for\s+//) { $tool = "for"; ($read_files, $write_files) = for_command($_); - } elsif(s/^\/usr\/bin\/install\s*//) { + } elsif(s/^\/usr\/bin\/install\s+//) { $tool = "install"; ($read_files, $write_files) = install_command($_); - } elsif(s/^ld\s*//) { + } elsif(s/^ld\s+//) { $tool = "ld"; ($read_files, $write_files) = ld_command($_); - } elsif(s/^\/sbin\/ldconfig\s*//) { + } elsif(s/^\/sbin\/ldconfig\s+//) { $tool = "ldconfig"; ($read_files, $write_files) = ldconfig_command(); - } elsif(s/^gcc\s*//) { + } elsif(s/^gcc\s+//) { $tool = "gcc"; ($read_files, $write_files) = gcc_command($_); - } elsif(s/^(?:(?:\.\.\/)+|\.\/)tools\/makedep\s*//) { + } elsif(s/^(?:(?:\.\.\/)+|\.\/)tools\/makedep\s+//) { $tool = "makedep"; ($read_files, $write_files) = makedep_command($_); - } elsif(s/^mkdir\s*//) { + } elsif(s/^mkdir\s+//) { $tool = "mkdir"; ($read_files, $write_files) = mkdir_command($_); - } elsif(s/^ranlib\s*//) { + } elsif(s/^ranlib\s+//) { $tool = "ranlib"; ($read_files, $write_files) = ranlib_command($_); - } elsif(s/^rm\s*//) { + } elsif(s/^rm\s+//) { $tool = "rm"; ($read_files, $write_files, $remove_files) = rm_command($_); - } elsif(s/^sed\s*//) { + } elsif(s/^sed\s+//) { $tool = "sed"; ($read_files, $write_files) = sed_command($_); - } elsif(s/^strip\s*//) { + } elsif(s/^strip\s+//) { $tool = "sed"; ($read_files, $write_files) = strip_command($_); - } elsif(s/^LD_LIBRARY_PATH="(?:(?:\.\.\/)*unicode)?:\$LD_LIBRARY_PATH"\s+(?:\.\.\/)*tools\/winebuild\/winebuild\s*//) { + } elsif(s/^LD_LIBRARY_PATH="(?:(?:\.\.\/)*unicode)?:\$LD_LIBRARY_PATH"\s+(?:\.\.\/)*tools\/winebuild\/winebuild\s+//) { $tool = "winebuild"; ($read_files, $write_files) = winebuild_command($_); - } elsif(s/^LD_LIBRARY_PATH="(?:(?:\.\.\/)*unicode)?:\$LD_LIBRARY_PATH"\s+(?:\.\.\/)*tools\/wmc\/wmc\s*//) { + } elsif(s/^LD_LIBRARY_PATH="(?:(?:\.\.\/)*unicode)?:\$LD_LIBRARY_PATH"\s+(?:\.\.\/)*tools\/wmc\/wmc\s+//) { $tool = "wmc"; ($read_files, $write_files) = wmc_command($_); - } elsif(s/^LD_LIBRARY_PATH="(?:(?:\.\.\/)*unicode)?:\$LD_LIBRARY_PATH"\s+(?:\.\.\/)*tools\/wrc\/wrc\s*//) { + } elsif(s/^LD_LIBRARY_PATH="(?:(?:\.\.\/)*unicode)?:\$LD_LIBRARY_PATH"\s+(?:\.\.\/)*tools\/wrc\/wrc\s+//) { $tool = "wrc"; ($read_files, $write_files) = wrc_command($_); } @@ -282,7 +308,7 @@ sub ar_command { $read_files =~ s/^\s*//; $read_files = [split(/\s+/, $read_files)]; } else { - error(); + error("ar_command"); } return ($read_files, $write_files); @@ -302,7 +328,7 @@ sub as_command { $write_files = [$1]; $read_files = [$2]; } else { - error(); + error("as_command"); } return ($read_files, $write_files); @@ -378,7 +404,7 @@ sub gcc_command { $write_files = [$1]; $read_files = [""]; } else { - error(); + error("gcc_command"); } return ($read_files, $write_files); @@ -400,7 +426,19 @@ sub gcc_output { if(0) { # Nothing } elsif(/^((?:signed |unsigned )?(?:int|long)) format, (different type|\S+) arg \(arg (\d+)\)$/) { - $supress = 0; + my $type = $2; + if($type =~ /^ + HACCEL|HANDLE|HBITMAP|HBRUSH|HCALL|HCURSOR|HDC|HDRVR|HDESK| + HGDIOBJ|HKL|HGLOBAL|HINSTANCE|HKEY| + HMENU|HMIDISTRM|HMIDIIN|HMIDIOUT|HMIXER|HMIXEROBJ|HMMIO|HMODULE| + HLINE|HPHONE|HPHONEAPP| + HRASCONN|HRGN|HRSRC|HWAVEIN|HWAVEOUT|HWINSTA|HWND|WSAEVENT| + handle_t|pointer$/x) + { + $supress = 1; + } else { + $supress = 0; + } } elsif(/^\(near initialization for \`(.*?)\'\)$/) { $supress = 0; } elsif(/^\`(.*?)\' defined but not used$/) { @@ -442,7 +480,13 @@ sub gcc_output { } elsif(/^ordered comparison of pointer with integer zero$/) { $supress = 0; } elsif(/^passing arg (\d+) of (?:pointer to function|\`(\S+)\') from incompatible pointer type$/) { - $supress = 0; + my $arg = $1; + my $name = $2; + if(defined($name) && $name =~ /^GDI_AllocObject$/) { + $supress = 1; + } else { + $supress = 0; + } } elsif(/^passing arg (\d+) of (?:pointer to function|\`(\S+)\') makes integer from pointer without a cast$/) { $supress = 0; } elsif(/^passing arg (\d+) of (?:pointer to function|\`(\S+)\') makes pointer from integer without a cast$/) { @@ -458,14 +502,14 @@ sub gcc_output { } elsif(!$options->pedantic) { $supress = 0; } else { - error(); + error("gcc_output"); } if(!$supress) { if($function) { - $message = "function $function: $_"; + $message = "function $function: warning: $_"; } else { - $message = "$_"; + $message = "warning: $_"; } } else { $message = ""; @@ -487,14 +531,14 @@ sub gcc_output { } elsif(!$options->pedantic) { $message = "$_"; } else { - error(); + error("gcc_output"); } } elsif(/^In function \`(.*?)\':$/) { $function = $1; } elsif(/^At top level:$/) { $function = ""; } else { - error(); + error("gcc_output"); } } @@ -522,7 +566,7 @@ sub ld_command { $write_files = [$2]; $read_files = [split(/\s+/, $1)]; } else { - error(); + error("ld_command"); } return ($read_files, $write_files); @@ -657,7 +701,7 @@ sub wmc_command { $write_files = [$rc_file]; $read_files = [$mc_file]; } else { - error(); + error("wmc_command"); } return ($read_files, $write_files); @@ -691,7 +735,7 @@ sub wrc_command { $write_files = [$o_file]; $read_files = [$rc_file]; } else { - error(); + error("wrc_command"); } return ($read_files, $write_files); diff --git a/tools/winapi/options.pm b/tools/winapi/options.pm index b0fdd4d8b11..4f2e6c51c2b 100644 --- a/tools/winapi/options.pm +++ b/tools/winapi/options.pm @@ -41,7 +41,6 @@ package _options; use strict; -use config qw($current_dir $wine_dir); use output qw($output); sub new { @@ -182,6 +181,7 @@ sub parse_files { my $self = shift; my $arguments = \@{$self->{_ARGUMENTS}}; + my $directories = \@{$self->{_DIRECTORIES}}; my $c_files = \@{$self->{_C_FILES}}; my $h_files = \@{$self->{_H_FILES}}; @@ -245,6 +245,16 @@ sub parse_files { } } split(/\n/, `$h_command`)); } + + my %dirs; + foreach my $file (@$c_files, @$h_files) { + my $dir = $file; + $dir =~ s%/?[^/]+$%%; + if(!$dir) { $dir = "."; } + $dirs{$dir}++ + } + + @$directories = sort(keys(%dirs)); } sub options_set { @@ -392,4 +402,16 @@ sub h_files { return @$h_files; } +sub directories { + my $self = shift; + + my $directories = \@{$self->{_DIRECTORIES}}; + + if(!defined(@$directories)) { + $self->parse_files; + } + + return @$directories; +} + 1; diff --git a/tools/winapi_check/modules.dat b/tools/winapi_check/modules.dat index 706a32e6dae..e9a016f7bc3 100644 --- a/tools/winapi_check/modules.dat +++ b/tools/winapi_check/modules.dat @@ -391,6 +391,8 @@ dlls/winedos % dlls/wineps/wineps.spec +dlls/wineps + % dlls/wineps/wineps16.spec dlls/wineps diff --git a/tools/winapi_check/modules.pm b/tools/winapi_check/modules.pm index 357e8504dfb..1880b490b36 100644 --- a/tools/winapi_check/modules.pm +++ b/tools/winapi_check/modules.pm @@ -14,7 +14,7 @@ use vars qw($modules); use config qw( &file_type &files_skip &file_directory - &get_c_files + &get_c_files &get_spec_files $current_dir $wine_dir $winapi_check_dir ); @@ -23,36 +23,58 @@ use output qw($output); $modules = 'modules'->new; +sub get_spec_file_type { + my $file = shift; + + my $module; + my $type; + + open(IN, "< $file") || die "$file: $!\n"; + local $/ = "\n"; + while() { + s/^\s*(.*?)\s*$/$1/; + s/^(.*?)\s*#.*$/$1/; + /^$/ && next; + + if(/^name\s*(\S*)/) { $module = $1; } + if(/^type\s*(\w+)/) { $type = $1; } + + if(defined($module) && defined($type)) { last; } + } + close(IN); + + if(!defined($module)) { + $module = $file; + $module =~ s%^.*?([^/]+)\.spec|%$1%; + } + + if(!defined($type)) { + $type = ""; + } + + return ($type, $module); +} + sub new { my $proto = shift; my $class = ref($proto) || $proto; my $self = {}; bless ($self, $class); + my $spec_files16 = \@{$self->{SPEC_FILES16}}; + my $spec_files32 = \@{$self->{SPEC_FILES32}}; my $dir2spec_file = \%{$self->{DIR2SPEC_FILE}}; my $spec_file2dir = \%{$self->{SPEC_FILE2DIR}}; my $spec_file2module = \%{$self->{SPEC_FILE2MODULE}}; + my $module2spec_file = \%{$self->{MODULE2SPEC_FILE}}; my $module_file = "$winapi_check_dir/modules.dat"; - my @all_spec_files = map { - s/^.\/(.*)$/$1/; - if(file_type($_) eq "winelib") { - $_; - } else { - (); - } - } split(/\n/, `find $wine_dir -name \\*.spec`); - - my %all_spec_files; - foreach my $file (@all_spec_files) { - $all_spec_files{$file}++ ; - } - if($options->progress) { $output->progress("modules.dat"); } + my %spec_file_found; my $allowed_dir; my $spec_file; @@ -65,17 +87,13 @@ sub new { if(/^%\s+(.*?)$/) { $spec_file = $1; - + if(!-f "$wine_dir/$spec_file") { $output->write("modules.dat: $spec_file: file ($spec_file) doesn't exist or is no file\n"); } - if($wine_dir eq ".") { - $all_spec_files{$spec_file}--; - } else { - $all_spec_files{"$wine_dir/$spec_file"}--; - } - $$dir2spec_file{""}{$spec_file}++; # FIXME: Kludge + $spec_file_found{$spec_file}++; + $$spec_file2dir{$spec_file} = {}; next; } else { $allowed_dir = $1; @@ -89,8 +107,40 @@ sub new { } close(IN); - foreach my $spec_file (sort(keys(%all_spec_files))) { - if($all_spec_files{$spec_file} > 0) { + my @spec_files; + if($wine_dir eq ".") { + @spec_files = get_spec_files("winelib"); + } else { + my %spec_files = (); + foreach my $dir ($options->directories) { + $dir = "$current_dir/$dir"; + $dir =~ s%/\.$%%; + foreach my $spec_file (sort(keys(%{$$dir2spec_file{$dir}}))) { + $spec_files{$spec_file}++; + } + } + @spec_files = sort(keys(%spec_files)); + } + + @$spec_files16 = (); + @$spec_files32 = (); + foreach my $spec_file (@spec_files) { + (my $type, my $module) = get_spec_file_type("$wine_dir/$spec_file"); + + $$spec_file2module{$spec_file} = $module; + $$module2spec_file{$module} = $spec_file; + + if($type eq "win16") { + push @$spec_files16, $spec_file; + } elsif($type eq "win32") { + push @$spec_files32, $spec_file; + } else { + $output->write("$spec_file: unknown type '$type'\n"); + } + } + + foreach my $spec_file (@spec_files) { + if(!$spec_file_found{$spec_file}) { $output->write("modules.dat: $spec_file: exists but is not specified\n"); } } @@ -146,19 +196,14 @@ sub complete_modules { return @complete_modules; } -sub spec_file_module { +sub is_allowed_module { my $self = shift; - my $spec_file2module = \%{$self->{SPEC_FILE2MODULE}}; my $module2spec_file = \%{$self->{MODULE2SPEC_FILE}}; - my $spec_file = shift; - $spec_file =~ s/^\.\///; - my $module = shift; - - $$spec_file2module{$spec_file} = $module; - $$module2spec_file{$module} = $spec_file; + + return defined($$module2spec_file{$module}); } sub is_allowed_module_in_file { @@ -205,7 +250,9 @@ sub allowed_modules_in_file { $allowed_modules{$module}++; } - return join(" & ", sort(keys(%allowed_modules))); + my $module = join(" & ", sort(keys(%allowed_modules))); + + return $module; } sub allowed_dirs_for_module { @@ -221,32 +268,20 @@ sub allowed_dirs_for_module { return sort(keys(%{$$spec_file2dir{$spec_file}})); } -sub allowed_spec_files { +sub allowed_spec_files16 { my $self = shift; - my $dir2spec_file = \%{$self->{DIR2SPEC_FILE}}; + my $spec_files16 = \@{$self->{SPEC_FILES16}}; - my @dirs = map { - s/^\.\/(.*)$/$1/; - if(/^\.$/) { - $current_dir; - } else { - if($current_dir ne ".") { - "$current_dir/$_"; - } else { - $_; - } - } - } split(/\n/, `find . -type d ! -name CVS`); + return @$spec_files16; +} - my %allowed_spec_files = (); - foreach my $dir (sort(@dirs)) { - foreach my $spec_file (sort(keys(%{$$dir2spec_file{$dir}}))) { - $allowed_spec_files{$spec_file}++; - } - } +sub allowed_spec_files32 { + my $self = shift; + + my $spec_files32 = \@{$self->{SPEC_FILES32}}; - return sort(keys(%allowed_spec_files)); + return @$spec_files32; } sub found_module_in_dir { @@ -257,6 +292,9 @@ sub found_module_in_dir { my $used_module_dirs = \%{$self->{USED_MODULE_DIRS}}; + $dir = "$current_dir/$dir"; + $dir =~ s%/\.$%%; + $$used_module_dirs{$module}{$dir}++; } @@ -264,15 +302,16 @@ sub global_report { my $self = shift; my $dir2spec_file = \%{$self->{DIR2SPEC_FILE}}; - my $spec_file2module = \%{$self->{SPEC_FILE2MODULE}}; + my $module2spec_file = \%{$self->{MODULE2SPEC_FILE}}; my $used_module_dirs = \%{$self->{USED_MODULE_DIRS}}; my @messages; - foreach my $dir (sort(keys(%$dir2spec_file))) { - if($dir eq "") { next; } - foreach my $spec_file (sort(keys(%{$$dir2spec_file{$dir}}))) { - my $module = $$spec_file2module{$spec_file}; + foreach my $dir ($options->directories) { + $dir = "$current_dir/$dir"; + $dir =~ s%/\.$%%; + foreach my $module ($self->all_modules) { if(!$$used_module_dirs{$module}{$dir}) { + my $spec_file = $$module2spec_file{$module}; push @messages, "modules.dat: $spec_file: directory ($dir) is not used\n"; } } diff --git a/tools/winapi_check/win32/ttydrv.api b/tools/winapi_check/win32/ttydrv.api index ae8a27cc634..e08e9d34a75 100644 --- a/tools/winapi_check/win32/ttydrv.api +++ b/tools/winapi_check/win32/ttydrv.api @@ -2,10 +2,13 @@ BOOL CHAR +COLORREF DWORD INT HANDLE HDC +HBITMAP +HGDIOBJ HRGN HWND LONG @@ -20,16 +23,28 @@ int %ptr +BITMAPINFO * BYTE * +DC * +DEVMODEA * +DWORD * CREATESTRUCTA * LPBYTE +LPCVOID LPDIDEVICEOBJECTDATA LPDWORD +LPINT LPMOUSE_EVENT_PROC +LPSIZE +LPTEXTMETRICW LPVOID +INT * +POINT * +RECT * WINDOWPOS * struct tagCURSORICONINFO * struct tagWND * +void * %str @@ -38,6 +53,7 @@ LPSTR %wstr +LPCWSTR LPWSTR %void diff --git a/tools/winapi_check/win32/wineps.api b/tools/winapi_check/win32/wineps.api new file mode 100644 index 00000000000..89b4309704c --- /dev/null +++ b/tools/winapi_check/win32/wineps.api @@ -0,0 +1,47 @@ +%long + +BOOL +COLORREF +DWORD +HDC +HGDIOBJ +HWND +INT +LPARAM +UINT +WORD + +%ptr + +BITMAPINFO * +DC * +DEVICEFONTENUMPROC +DEVMODEA * +DOCINFOA * +DWORD * +INT * +LPDEVMODEA +LPINT +LPLOGFONTW +LPSIZE +POINT * +RECT * +TEXTMETRICW * +void * + +%ptr # --forbidden + +SEGPTR + +%str + +LPCSTR +LPSTR + +%wstr + +LPCWSTR + +%void + +VOID diff --git a/tools/winapi_check/win32/x11drv.api b/tools/winapi_check/win32/x11drv.api index 67a6c9cb51f..2dfd72c5ca0 100644 --- a/tools/winapi_check/win32/x11drv.api +++ b/tools/winapi_check/win32/x11drv.api @@ -2,14 +2,18 @@ BOOL CHAR +COLORREF DWORD HANDLE +HBITMAP HDC +HGDIOBJ HICON HRGN HWND INT LONG +LPARAM UINT WPARAM WORD @@ -22,20 +26,39 @@ int %ptr +BITMAPINFO * BYTE * +DC * CURSORICONINFO * CREATESTRUCTA * +DEVICEFONTENUMPROC +DEVMODEA * +DWORD * HANDLE * +INT * LPBYTE +LPCVOID LPDIDEVICEOBJECTDATA LPDWORD +LPINT +LPLOGFONTW LPMOUSE_EVENT_PROC LPPOINT LPRECT +LPSIZE LPVOID +LPVOID * +PIXELFORMATDESCRIPTOR * +POINT * RECT * +TEXTMETRICW * WINDOWPOS * WND * +void * + +%ptr # --forbidden + +SEGPTR %str diff --git a/tools/winapi_check/winapi.pm b/tools/winapi_check/winapi.pm index 813aa6ad7ef..4eb33e47adb 100644 --- a/tools/winapi_check/winapi.pm +++ b/tools/winapi_check/winapi.pm @@ -13,28 +13,31 @@ use vars qw($win16api $win32api @winapis); use config qw( &file_type - &get_api_files &get_spec_files + &get_api_files $current_dir $wine_dir ); use modules qw($modules); use options qw($options); use output qw($output); -$win16api = 'winapi'->new("win16"); -$win32api = 'winapi'->new("win32"); -@winapis = ($win16api, $win32api); +my @spec_files16 = $modules->allowed_spec_files16; +$win16api = 'winapi'->new("win16", \@spec_files16); -my @spec_files = get_spec_files("winelib"); -foreach my $file (@spec_files) { - (my $type, my $module) = 'winapi'->get_spec_file_type("$wine_dir/$file"); - $modules->spec_file_module($file, $module); -} +my @spec_files32 = $modules->allowed_spec_files32; +$win32api = 'winapi'->new("win32", \@spec_files32); + +@winapis = ($win16api, $win32api); -if($wine_dir eq ".") { - 'winapi'->read_spec_files(\@spec_files); -} else { - @spec_files = $modules->allowed_spec_files; - 'winapi'->read_spec_files(\@spec_files); +for my $internal_name ($win32api->all_internal_functions) { + my $module16 = $win16api->function_internal_module($internal_name); + my $module32 = $win16api->function_internal_module($internal_name); + if(defined($module16) && + !$win16api->is_function_stub_in_module($module16, $internal_name) && + !$win32api->is_function_stub_in_module($module32, $internal_name)) + { + $win16api->found_shared_internal_function($internal_name); + $win32api->found_shared_internal_function($internal_name); + } } sub new { @@ -44,19 +47,34 @@ sub new { bless ($self, $class); my $name = \${$self->{NAME}}; + my $function_forward = \%{$self->{FUNCTION_FORWARD}}; + my $function_internal_name = \%{$self->{FUNCTION_INTERNAL_NAME}}; + my $function_module = \%{$self->{FUNCTION_MODULE}}; $$name = shift; + my $refspec_files = shift; + + foreach my $file (@$refspec_files) { + $self->parse_spec_file("$wine_dir/$file"); + } foreach my $file (get_api_files($$name)) { my $module = $file; + $module =~ s/.*?\/([^\/]*?)\.api$/$1/; - if($options->progress) { - $output->lazy_progress("$file"); + if($modules->is_allowed_module($module)) { + $self->parse_api_file($file,$module); } - - $module =~ s/.*?\/([^\/]*?)\.api$/$1/; - $self->parse_api_file($file,$module); } + + foreach my $forward_name (sort(keys(%$function_forward))) { + $$function_forward{$forward_name} =~ /^(\S*):(\S*)\.(\S*)$/; + (my $from_module, my $to_module, my $external_name) = ($1, $2, $3); + my $internal_name = $$function_internal_name{$external_name}; + if(defined($internal_name)) { + $$function_module{$internal_name} .= " & $from_module"; + } + } return $self; } @@ -88,7 +106,7 @@ sub parse_api_file { my $forbidden = 0; if($options->progress) { - $output->progress("$file"); + $output->lazy_progress("$file"); } open(IN, "< $wine_dir/$file") || die "$wine_dir/$file: $!\n"; @@ -173,75 +191,6 @@ sub parse_api_file { close(IN); } -sub get_spec_file_type { - my $proto = shift; - my $class = ref($proto) || $proto; - - my $file = shift; - - my $module; - my $type; - - open(IN, "< $file") || die "$file: $!\n"; - local $/ = "\n"; - while() { - s/^\s*(.*?)\s*$/$1/; - s/^(.*?)\s*#.*$/$1/; - /^$/ && next; - - if(/^name\s*(\S*)/) { $module = $1; } - if(/^type\s*(\w+)/) { $type = $1; } - - if(defined($module) && defined($type)) { last; } - } - close(IN); - - return ($type, $module); -} - -sub read_spec_files { - my $proto = shift; - my $class = ref($proto) || $proto; - - my $files = shift; - - foreach my $file (@$files) { - (my $type, my $module) = 'winapi'->get_spec_file_type("$wine_dir/$file"); - if($type eq "win16") { - $win16api->parse_spec_file("$wine_dir/$file"); - } elsif($type eq "win32") { - $win32api->parse_spec_file("$wine_dir/$file"); - } - } - - foreach my $self ($win16api, $win32api) { - my $function_forward = \%{$self->{FUNCTION_FORWARD}}; - my $function_internal_name = \%{$self->{FUNCTION_INTERNAL_NAME}}; - my $function_module = \%{$self->{FUNCTION_MODULE}}; - - foreach my $forward_name (sort(keys(%$function_forward))) { - $$function_forward{$forward_name} =~ /^(\S*):(\S*)\.(\S*)$/; - (my $from_module, my $to_module, my $external_name) = ($1, $2, $3); - my $internal_name = $$function_internal_name{$external_name}; - if(defined($internal_name)) { - $$function_module{$internal_name} .= " & $from_module"; - } - } - } - - for my $internal_name ($win32api->all_internal_functions) { - my $module16 = $win16api->function_internal_module($internal_name); - my $module32 = $win16api->function_internal_module($internal_name); - if(defined($module16) && - !$win16api->is_function_stub_in_module($module16, $internal_name) && - !$win32api->is_function_stub_in_module($module32, $internal_name)) - { - $win16api->found_shared_internal_function($internal_name); - $win32api->found_shared_internal_function($internal_name); - } - } -} - sub parse_spec_file { my $self = shift; diff --git a/tools/winapi_check/winapi_check b/tools/winapi_check/winapi_check index f327cd56656..b7feb3744e4 100755 --- a/tools/winapi_check/winapi_check +++ b/tools/winapi_check/winapi_check @@ -98,6 +98,26 @@ my @h_files = $options->h_files; @h_files = files_skip(@h_files); @h_files = files_filter("winelib", @h_files); +my $all_modules = 0; +my %complete_module; +if($options->global) { + my @complete_modules = $modules->complete_modules(\@c_files); + + foreach my $module (@complete_modules) { + $complete_module{$module}++; + } + + my $all_modules = 1; + foreach my $module ($modules->all_modules) { + if(!$complete_module{$module}) { + $all_modules = 0; + if($wine_dir eq ".") { + $output->write("*.c: module $module is not complete\n"); + } + } + } +} + my $progress_current = 0; my $progress_max = scalar(@c_files); @@ -289,7 +309,7 @@ foreach my $file (@c_files) { (defined($module16) || defined($module32)) && $linkage eq "" && defined($statements)) { - # &winapi_documentation::check_documentation($function); + &winapi_documentation::check_documentation($function); } if(1) { @@ -523,7 +543,7 @@ foreach my $file (@c_files) { } } }; - + &winapi_parser::parse_c_file($file, $create_function, $found_function, $create_type, $found_type, $found_preprocessor); if($options->config_unnessary) { @@ -536,12 +556,7 @@ foreach my $file (@c_files) { } if($options->global) { - my @complete_modules = $modules->complete_modules(\@c_files); - my %complete_module; - - foreach my $module (@complete_modules) { - $complete_module{$module}++; - } + my @complete_modules = sort(keys(%complete_module)); if($options->declared) { foreach my $module (@complete_modules) { @@ -575,12 +590,6 @@ if($options->global) { } } - my $all_modules = 1; - foreach my $module ($modules->all_modules) { - if(!$complete_module{$module}) { - $all_modules = 0; - } - } if($all_modules) { &winapi_documentation::report_documentation; diff --git a/tools/winapi_check/winapi_local.pm b/tools/winapi_check/winapi_local.pm index a4c523156a3..7203693033c 100644 --- a/tools/winapi_check/winapi_local.pm +++ b/tools/winapi_check/winapi_local.pm @@ -323,7 +323,7 @@ sub _check_statements { } } } - } else { + } elsif($options->cross_call) { $$functions{$internal_name}->function_called($called_name); if(!defined($$functions{$called_name})) { $$functions{$called_name} = 'winapi_function'->new; diff --git a/tools/winapi_check/winapi_parser.pm b/tools/winapi_check/winapi_parser.pm index 5aa3b3ad690..1e6e4af665e 100644 --- a/tools/winapi_check/winapi_parser.pm +++ b/tools/winapi_check/winapi_parser.pm @@ -293,10 +293,6 @@ sub parse_c_file { } } - if(!defined($statements)) { - $statements = ""; - } - if($line !~ /^\s*$/) { $statements .= "$line\n"; } @@ -408,9 +404,9 @@ sub parse_c_file { $function_line, $linkage, $return_type, $calling_convention, $name, \@argument_types,\@argument_names,\@argument_documentations); if($level == 0) { - &$function_end($statements); - $statements = undef; + &$function_end(undef); } + $statements = ""; } elsif(/__ASM_GLOBAL_FUNC\(\s*(.*?)\s*,/s) { my @lines = split(/\n/, $&); my $function_line = $. - scalar(@lines) + 1; -- 2.11.4.GIT