Commit 14bb7f14 authored by Patrik Stridvall's avatar Patrik Stridvall Committed by Alexandre Julliard

- Updated API files.

- Improved misplaced function checking. - Fixed minor bugs.
parent b42ed542
% dlls/advapi32/advapi32.spec
dlls/advapi32
misc
% dlls/avifil32/avifil32.spec
......@@ -25,6 +26,7 @@ dlls/commdlg
% dlls/crtdll/crtdll.spec
dlls/crtdll
misc
% dlls/dciman32/dciman32.spec
......@@ -33,6 +35,7 @@ dlls/dciman32
% dlls/ddraw/ddraw.spec
dlls/ddraw
dlls/ddraw/dclipper
% dlls/dinput/dinput.spec
......@@ -41,6 +44,7 @@ dlls/dinput
% dlls/display/display.spec
dlls/display
objects
% dlls/dplayx/dplay.spec
......@@ -57,10 +61,21 @@ dlls/dsound
% dlls/gdi/gdi.spec
dlls/gdi
graphics/metafiledrv
graphics/win16drv
graphics
memory
misc
objects
% dlls/gdi/gdi32.spec
dlls/gdi
graphics/enhmetafiledrv
graphics/metafiledrv
graphics
misc
objects
% dlls/icmp/icmp.spec
......@@ -113,6 +128,9 @@ dlls/msvideo
% dlls/ntdll/ntdll.spec
dlls/ntdll
loader
misc
scheduler
% dlls/odbc32/odbc32.spec
......@@ -121,6 +139,7 @@ dlls/odbc32
% dlls/ole32/compobj.spec
dlls/ole32
files
% dlls/ole32/ole2.spec
......@@ -189,14 +208,17 @@ dlls/setupx
% dlls/shell32/shell.spec
dlls/shell32
misc
% dlls/shell32/shell32.spec
dlls/shell32
memory
% dlls/shell32/shlwapi.spec
dlls/shell32
memory
% dlls/sound/sound.spec
......@@ -214,17 +236,38 @@ dlls/tapi32
dlls/ttydrv
% dlls/urlmon/urlmon.spec
dlls/urlmon
% dlls/user/keyboard.spec
dlls/user
memory
windows
% dlls/user/user.spec
controls
dlls/user
if1632
loader
objects
memory
misc
windows
% dlls/user/user32.spec
controls
dlls/user
loader
objects
memory
misc
scheduler
win32
windows
% dlls/version/ver.spec
......@@ -237,6 +280,7 @@ dlls/version
% dlls/win32s/w32skrnl.spec
dlls/win32s
loader
% dlls/win32s/w32sys.spec
......@@ -245,6 +289,8 @@ dlls/win32s
% dlls/win32s/win32s16.spec
dlls/win32s
memory
scheduler
% dlls/win87em/win87em.spec
......@@ -266,6 +312,10 @@ dlls/windebug
dlls/wing
% dlls/wininet/wininet.spec
dlls/wininet
% dlls/winmm/joystick/joystick.spec
dlls/winmm/joystick
......@@ -308,7 +358,8 @@ dlls/winmm
% dlls/winmm/winmm.spec
dlls/winmm/winmm
dlls/winmm
windows
% dlls/winsock/winsock.spec
......@@ -317,26 +368,87 @@ dlls/winsock
% dlls/winsock/wsock32.spec
dlls/winsock
misc
% dlls/winspool/winspool.spec
dlls/winspool
win32
% dlls/x11drv/x11drv.spec
dlls/x11drv
% if1632/comm.spec
% if1632/ddeml.spec
misc
% if1632/dispdib.spec
graphics
% if1632/kernel.spec
files
if1632
loader/ne
loader
memory
misc
msdos
relay32
scheduler
win32
% if1632/ole2conv.spec
% if1632/ole2nls.spec
ole
% if1632/ole2prox.spec
% if1632/ole2thk.spec
% if1632/system.spec
misc
% if1632/toolhelp.spec
loader/ne
loader
memory
misc
windows
% if1632/wineps.spec
graphics/psdrv
% if1632/wprocs.spec
if1632
loader/ne
msdos
relay32
windows
% relay32/kernel32.spec
files
loader/ne
loader
memory
misc
objects
ole
relay32
scheduler
win32
% relay32/wow32.spec
relay32
\ No newline at end of file
......@@ -10,10 +10,13 @@ sub new {
my $options = \${$self->{OPTIONS}};
my $output = \${$self->{OUTPUT}};
my $spec_files = \%{$self->{SPEC_FILES}};
my $modules = \%{$self->{MODULES}};
$$options = shift;
$$output = shift;
my $wine_dir = shift;
my $current_dir = shift;
my $module_file = shift;
$module_file =~ s/^\.\///;
......@@ -38,12 +41,107 @@ sub new {
} else {
$allowed_dir = $1;
}
$$spec_files{$allowed_dir}{$spec_file}++;
$$modules{$allowed_dir}{$spec_file}++;
if(!-d "$wine_dir/$allowed_dir") {
$$output->write("$module_file: $spec_file: directory ($allowed_dir) doesn't exist or is no directory\n");
}
}
close(IN);
return $self;
}
sub spec_file_module {
my $self = shift;
my $modules = \%{$self->{MODULES}};
my $spec_file = shift;
$spec_file =~ s/^\.\///;
my $module = shift;
$$modules{$spec_file}{$module}++;
}
sub is_allowed_module_in_file {
my $self = shift;
my $spec_files = \%{$self->{SPEC_FILES}};
my $modules = \%{$self->{MODULES}};
my $module = shift;
my $file = shift;
$file =~ s/^\.\///;
my $dir = $file;
$dir =~ s/\/[^\/]*$//;
foreach my $spec_file (sort(keys(%{$$spec_files{$dir}}))) {
if($$modules{$spec_file}{$module}) {
return 1;
}
}
return 0;
}
sub allowed_modules_in_file {
my $self = shift;
my $spec_files = \%{$self->{SPEC_FILES}};
my $modules = \%{$self->{MODULES}};
my $file = shift;
$file =~ s/^\.\///;
my $dir = $file;
$dir =~ s/\/[^\/]*$//;
my %allowed_modules = ();
foreach my $spec_file (sort(keys(%{$$spec_files{$dir}}))) {
foreach my $module (sort(keys(%{$$modules{$spec_file}}))) {
$allowed_modules{$module}++;
}
}
return join(" & ", sort(keys(%allowed_modules)));
}
sub allowed_spec_files {
my $self = shift;
my $options = \${$self->{OPTIONS}};
my $output = \${$self->{OUTPUT}};
my $spec_files = \%{$self->{SPEC_FILES}};
my $wine_dir = shift;
my $current_dir = shift;
my @dirs = map {
s/^\.\/(.*)$/$1/;
if(/^\.$/) {
$current_dir;
} else {
if($current_dir ne ".") {
"$current_dir/$_";
} else {
$_;
}
}
} split(/\n/, `find . -type d ! -name CVS`);
my %allowed_spec_files = ();
foreach my $dir (sort(@dirs)) {
foreach my $spec_file (sort(keys(%{$$spec_files{$dir}}))) {
$allowed_spec_files{$spec_file}++;
}
}
return sort(keys(%allowed_spec_files));
}
1;
......@@ -5,9 +5,9 @@ DWORD
%ptr
CONTEXT86 *
FARPROC
LPVOID
SEGPTR *
UTGLUEPROC
%segptr
......
......@@ -7,4 +7,7 @@ HRESULT
%ptr
LPDIRECTINPUTA *
LPVOID *
LPUNKNOWN
REFCLSID
REFIID
\ No newline at end of file
......@@ -92,10 +92,10 @@ LPINPUT_RECORD
LPLDT_ENTRY
LPMEMORYSTATUS
LPMEMORY_BASIC_INFORMATION
LPMODULEENTRY
LPMODULEENTRY32
LPOVERLAPPED
LPOVERLAPPED_COMPLETION_ROUTINE
LPPROCESSENTRY
LPPROCESSENTRY32
LPPROCESS_HEAP_ENTRY
LPPROCESS_INFORMATION
LPPROGRESS_ROUTINE
......@@ -108,7 +108,7 @@ LPSYSTEM_INFO
LPSYSTEM_POWER_STATUS
LPSYSTEMTIME
LPTHREAD_START_ROUTINE
LPTHREADENTRY
LPTHREADENTRY32
LPTIME_ZONE_INFORMATION
LPTOP_LEVEL_EXCEPTION_FILTER
LPVOID
......
%long
BOOL
HRESULT
%ptr
IMoniker *
IMoniker **
LPVOID *
REFCLSID
REFIID
%wstr
LPCWSTR
LPWSTR
......@@ -3,6 +3,7 @@
BOOL
DWORD
HINTERNET
HRESULT
INTERNET_PORT
%ptr
......@@ -18,3 +19,7 @@ INTERNET_STATUS_CALLBACK
LPCSTR
LPSTR
%wstr
LPCWSTR
......@@ -108,26 +108,55 @@ sub get_spec_file_type {
my $file = shift;
my $module;
my $type;
open(IN, "< $file") || die "$file: $!\n";
$/ = "\n";
local $/ = "\n";
while(<IN>) {
if(/^type\s*(\w+)/) {
$type = $1;
last;
}
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;
return ($type, $module);
}
sub read_spec_files {
my $proto = shift;
my $class = ref($proto) || $proto;
my $path = shift;
my $modules = shift;
my $wine_dir = shift;
my $current_dir = shift;
my $files = shift;
my $win16api = shift;
my $win32api = shift;
foreach my $file (@$files) {
(my $type, my $module) = 'winapi'->get_spec_file_type("$wine_dir/$file");
$modules->spec_file_module($file, $module);
if($type eq "win16") {
$win16api->parse_spec_file("$wine_dir/$file");
} elsif($type eq "win32") {
$win32api->parse_spec_file("$wine_dir/$file");
}
}
}
sub read_all_spec_files {
my $proto = shift;
my $class = ref($proto) || $proto;
my $modules = shift;
my $wine_dir = shift;
my $current_dir = shift;
my $file_type = shift;
my $win16api = shift;
my $win32api = shift;
......@@ -139,16 +168,9 @@ sub read_spec_files {
} else {
();
}
} split(/\n/, `find $path -name \\*.spec`);
} split(/\n/, `find $wine_dir -name \\*.spec`);
foreach my $file (@files) {
my $type = 'winapi'->get_spec_file_type($file);
if($type eq "win16") {
$win16api->parse_spec_file($file);
} elsif($type eq "win32") {
$win32api->parse_spec_file($file);
}
}
'winapi'->read_spec_files($modules, $wine_dir, $current_dir, \@files, $win16api, $win32api);
}
sub parse_spec_file {
......@@ -422,6 +444,15 @@ sub all_modules {
return sort(keys(%$modules));
}
sub is_module {
my $self = shift;
my $modules = \%{$self->{MODULES}};
my $name = shift;
return $$modules{$name};
}
sub all_functions {
my $self = shift;
my $function_calling_convention = \%{$self->{FUNCTION_CALLING_CONVENTION}};
......
......@@ -44,6 +44,16 @@ BEGIN {
import winapi_parser;
}
my $current_dir = ".";
if(length($wine_dir) != 1) {
my $pwd; chomp($pwd = `pwd`);
foreach my $n (1..((length($wine_dir) + 1) / 3)) {
$pwd =~ s/\/([^\/]*)$//;
$current_dir = "$1/$current_dir";
}
$current_dir =~ s/\/.$//;
}
my $options = winapi_options->new(\@ARGV, $wine_dir);
if($options->help) {
$options->show_help;
......@@ -52,7 +62,7 @@ if($options->help) {
my $output = 'output'->new;
my $modules = 'modules'->new($options, $output, "$winapi_check_dir/modules.dat");
my $modules = 'modules'->new($options, $output, $wine_dir, $current_dir, "$winapi_check_dir/modules.dat");
my $win16api = 'winapi'->new($options, $output, "win16", "$winapi_check_dir/win16");
my $win32api = 'winapi'->new($options, $output, "win32", "$winapi_check_dir/win32");
......@@ -61,7 +71,7 @@ sub file_type {
my $file = shift;
my $file_dir = $file;
if(!($file_dir =~ s/(.*?)\/[^\/]*$/$1/)) {
if(!($file_dir =~ s/^(.*?)\/[^\/]*$/$1/)) {
$file_dir = ".";
}
......@@ -79,7 +89,12 @@ sub file_type {
}
}
'winapi'->read_spec_files($wine_dir, \&file_type, $win16api, $win32api);
if($options->global) {
'winapi'->read_all_spec_files($modules, $wine_dir, $current_dir, \&file_type, $win16api, $win32api);
} else {
my @spec_files = $modules->allowed_spec_files($wine_dir, $current_dir);
'winapi'->read_spec_files($modules, $wine_dir, $current_dir, \@spec_files, $win16api, $win32api);
}
my $nativeapi = 'nativeapi'->new($options, $output, "$winapi_check_dir/nativeapi.dat", "$wine_dir/configure.in", "$wine_dir/include/config.h.in");
......@@ -180,8 +195,9 @@ my %module_pseudo_stub_count32;
foreach my $file ($options->c_files) {
my %functions = ();
my $file_module16;
my $file_module32;
my $file_module16 = $modules->allowed_modules_in_file("$current_dir/$file");
my $file_module32 = $modules->allowed_modules_in_file("$current_dir/$file");
$progress_current++;
if($options->progress) {
......@@ -200,7 +216,8 @@ foreach my $file ($options->c_files) {
my $linkage = shift;
my $return_type = shift;
my $calling_convention = shift;
my $name = shift;
my $internal_name = shift;
my $external_name = $internal_name;
my $refarguments = shift;
my @arguments = @$refarguments;
my $statements = shift;
......@@ -213,23 +230,57 @@ foreach my $file ($options->c_files) {
$win32api->found_type($argument) if $options->win32;
}
$win16api->found_function($name) if $options->win16;
$win32api->found_function($name) if $options->win32;
$win16api->found_function($internal_name) if $options->win16;
$win32api->found_function($internal_name) if $options->win32;
}
if($file_type ne "application") {
my $module16 = $win16api->function_module($name);
my $module32 = $win32api->function_module($name);
my $module16 = $win16api->function_module($internal_name);
if(!defined($module16)) {
if($internal_name =~ /^(.*?)_(.*?)$/) {
my $module2 = lc($1);
my $name2 = $2;
if($win16api->is_module($module2)) {
$module16 = $win16api->function_module($name2);
if(defined($module16)) {
if(uc($module16) !~ /\U$module2\E/) {
$external_name = $name2;
} else {
$module16 = undef;
}
}
}
}
}
my $module32 = $win32api->function_module($internal_name);
if(!defined($module32)) {
if($internal_name =~ /^(.*?)_(.*?)$/) {
my $module2 = lc($1);
my $name2 = $2;
if($win32api->is_module($module2)) {
$module32 = $win32api->function_module($name2);
if(defined($module32)) {
if(uc($module32) =~ /\U$module2\E/) {
$external_name = $name2;
} else {
$module32 = undef;
}
}
}
}
}
my $function = 'winapi_function'->new;
$functions{$name} = $function;
$functions{$internal_name} = $function;
$function->documentation($documentation);
$function->linkage($linkage);
$function->file($file);
$function->return_type($return_type);
$function->calling_convention($calling_convention);
$function->name($name);
$function->external_name($external_name);
$function->internal_name($internal_name);
$function->arguments([@arguments]);
$function->statements($statements);
$function->module16($module16);
......@@ -241,23 +292,15 @@ foreach my $file ($options->c_files) {
my $msg = shift;
$output->write("$file: $module: $return_type ");
$output->write("$calling_convention ") if $calling_convention;
$output->write("$name(" . join(",", @arguments) . "): $msg\n");
$output->write("$internal_name(" . join(",", @arguments) . "): $msg\n");
}
};
my $output16 = &$output_module($module16);
my $output32 = &$output_module($module32);
# FIXME: Improve heuristics
if(!defined($file_module16)) {
$file_module16 = $module16;
}
# FIXME: Improve heuristics
if(!defined($file_module32)) {
$file_module32 = $module32;
}
if($options->local && $options->misplaced) {
if($options->local && $options->misplaced &&
$linkage ne "extern" && $statements)
{
if($options->win16 && $options->report_module($module16)) {
my $match = 0;
foreach my $module (split(/ & /, $module16)) {
......@@ -268,7 +311,7 @@ foreach my $file ($options->c_files) {
}
}
if(!$match) {
&$output16("doesn't belong to file module ($file_module16)");
&$output16("is misplaced\n");
}
}
......@@ -282,13 +325,13 @@ foreach my $file ($options->c_files) {
}
}
if(!$match) {
&$output32("doesn't belong to file module ($file_module32)");
&$output32("is misplaced");
}
}
}
if($options->local && $options->headers) {
if(!$declared_functions{$name}) {
if(!$declared_functions{$internal_name}) {
if($options->win16 && $options->report_module($module16)) {
&$output16("no prototype");
}
......@@ -301,11 +344,11 @@ foreach my $file ($options->c_files) {
if($options->local && $options->argument) {
if($options->win16 && $options->report_module($module16)) {
winapi_local::check_function $options, $output16,
$return_type, $calling_convention, $name, [@arguments], $win16api;
$return_type, $calling_convention, $external_name, $internal_name, [@arguments], $win16api;
}
if($options->win32 && $options->report_module($module32)) {
winapi_local::check_function $options, $output32,
$return_type, $calling_convention, $name, [@arguments], $win32api;
$return_type, $calling_convention, $external_name, $internal_name, [@arguments], $win32api;
}
}
......@@ -317,11 +360,11 @@ foreach my $file ($options->c_files) {
$_ = $';
my $called_name = $1;
if($called_name !~ /^if|for|while|switch|sizeof$/) {
$functions{$name}->function_called($called_name);
$functions{$internal_name}->function_called($called_name);
if(!defined($functions{$called_name})) {
$functions{$called_name} = 'winapi_function'->new;
}
$functions{$called_name}->function_called_by($name);
$functions{$called_name}->function_called_by($internal_name);
}
} else {
undef $_
......@@ -346,7 +389,7 @@ foreach my $file ($options->c_files) {
if($options->local && $options->documentation &&
(defined($module16) || defined($module32)) &&
$linkage ne "extern" && $statements ne "")
$linkage ne "extern" && $statements)
{
my $name1;
my $name2;
......@@ -355,7 +398,7 @@ foreach my $file ($options->c_files) {
my @uc_modules16 = split(/\s*\&\s*/, uc($module16));
push @uc_modules16, "WIN16";
$name1 = $name;
$name1 = $internal_name;
foreach my $uc_module16 (@uc_modules16) {
if($name1 =~ s/^$uc_module16\_//) { last; }
}
......@@ -366,7 +409,7 @@ foreach my $file ($options->c_files) {
} elsif(!defined($module16) && defined($module32)) {
my @uc_modules32 = split(/\s*\&\s*/, uc($module32));
$name1 = $name;
$name1 = $internal_name;
foreach my $uc_module32 (@uc_modules32) {
if($name1 =~ s/^$uc_module32\_//) { last; }
}
......@@ -377,7 +420,7 @@ foreach my $file ($options->c_files) {
my @uc_modules = split(/\s*\&\s*/, uc($module16));
push @uc_modules, split(/\s*\&\s*/, uc($module32));
$name1 = $name;
$name1 = $internal_name;
foreach my $uc_module (@uc_modules) {
if($name1 =~ s/^$uc_module\_//) { last; }
}
......@@ -385,8 +428,8 @@ foreach my $file ($options->c_files) {
$name2 = $name1;
}
if($documentation !~ /\b($name|$name1|$name2)\b/) {
$output->write("$file: $name: \\\n");
if($documentation !~ /\b($internal_name|$name1|$name2)\b/) {
$output->write("$file: $internal_name: \\\n");
$output->write("$documentation\n");
}
......@@ -396,7 +439,7 @@ foreach my $file ($options->c_files) {
$comment_width{$width}++;
if($width <= 65 || $width >= 81) {
$output->write("$file: $name: comment is $width columns wide\n");
$output->write("$file: $internal_name: comment is $width columns wide\n");
}
}
}
......
......@@ -66,15 +66,26 @@ sub calling_convention {
return $$calling_convention;
}
sub name {
sub external_name {
my $self = shift;
my $name = \${$self->{NAME}};
my $external_name = \${$self->{EXTERNAL_NAME}};
local $_ = shift;
if(defined($_)) { $$name = $_; }
if(defined($_)) { $$external_name = $_; }
return $$name;
return $$external_name;
}
sub internal_name {
my $self = shift;
my $internal_name = \${$self->{INTERNAL_NAME}};
local $_ = shift;
if(defined($_)) { $$internal_name = $_; }
return $$internal_name;
}
sub arguments {
......
......@@ -7,28 +7,29 @@ sub check_function {
my $output = shift;
my $return_type = shift;
my $calling_convention = shift;
my $name = shift;
my $external_name = shift;
my $internal_name = shift;
my $refargument_types = shift;
my @argument_types = @$refargument_types;
my $winapi = shift;
my $module = $winapi->function_module($name);
my $module = $winapi->function_module($external_name);
if($winapi->name eq "win16") {
my $name16 = $name;
my $name16 = $external_name;
$name16 =~ s/16$//;
if($name16 ne $name && $winapi->function_stub($name16)) {
if($name16 ne $external_name && $winapi->function_stub($name16)) {
if($options->implemented) {
&$output("function implemented but declared as stub in .spec file");
}
return;
} elsif($winapi->function_stub($name)) {
} elsif($winapi->function_stub($external_name)) {
if($options->implemented_win32) {
&$output("32-bit variant of function implemented but declared as stub in .spec file");
}
return;
}
} elsif($winapi->function_stub($name)) {
} elsif($winapi->function_stub($external_name)) {
if($options->implemented) {
&$output("function implemented but declared as stub in .spec file");
}
......@@ -79,8 +80,8 @@ sub check_function {
}
}
my $declared_calling_convention = $winapi->function_calling_convention($name);
my @declared_argument_kinds = split(/\s+/, $winapi->function_arguments($name));
my $declared_calling_convention = $winapi->function_calling_convention($external_name);
my @declared_argument_kinds = split(/\s+/, $winapi->function_arguments($external_name));
if($declared_calling_convention =~ /^register|interrupt$/) {
push @declared_argument_kinds, "ptr";
......@@ -111,12 +112,12 @@ sub check_function {
}
if($#argument_types != -1 && $argument_types[$#argument_types] eq "CONTEXT *" &&
$name !~ /^(Get|Set)ThreadContext$/)
$external_name !~ /^(Get|Set)ThreadContext$/) # FIXME: Kludge
{
$#argument_types--;
}
if($name =~ /^CRTDLL__ftol|CRTDLL__CIpow$/) {
if($internal_name =~ /^CRTDLL__ftol|CRTDLL__CIpow$/) { # FIXME: Kludge
# ignore
} else {
my $n = 0;
......@@ -167,7 +168,7 @@ sub check_function {
}
if($segmented && $options->shared_segmented && $winapi->is_shared_function($name)) {
if($segmented && $options->shared_segmented && $winapi->is_shared_function($internal_name)) {
&$output("function using segmented pointers shared between Win16 och Win32");
}
}
......
......@@ -59,7 +59,7 @@ my %options = (
description => "argument kind checking"
},
"calling-convention" => { default => 0, parent => "local", description => "calling convention checking" },
"misplaced" => { default => 0, parent => "local", description => "check for misplaced functions" },
"misplaced" => { default => 1, parent => "local", description => "check for misplaced functions" },
"cross-call" => { default => 0, parent => "local", description => "check for cross calling functions" },
"documentation" => { default => 1, parent => "local", description => "check for documentation inconsistances\n" },
"documentation-width" => { default => 0, parent => "documentation", description => "check for documentation width inconsistances\n" },
......
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