Commit 20ca0011 authored by Patrik Stridvall's avatar Patrik Stridvall Committed by Alexandre Julliard

- Slightly better handling of external/internal names.

- Minor bug fixes. - Minor API files update.
parent 163652b3
......@@ -344,7 +344,6 @@ controls
dlls/kernel
dlls/user
memory
misc
windows
% dlls/user/user32.spec
......@@ -352,7 +351,6 @@ windows
controls
dlls/user
loader
misc
windows
% dlls/version/ver.spec
......
......@@ -13,6 +13,8 @@ _lwp_exit
_lwp_makecontext
_lxstat
_sysconf
_tolower
_toupper
_xmknod
_xstat
abs
......@@ -242,6 +244,7 @@ tolower
toupper
towlower
towupper
tzset
unlink
usleep
utime
......
......@@ -78,7 +78,7 @@ sub begin_if {
}
} elsif(/^(\w+)\s*(<|<=|==|!=|>=|>)\s*(\w+)\s*((\&\&|\|\|)\s*)?/) {
$_ = $';
} elsif(/^(\w+)\s*$/) {
} elsif(/^(!)?(\w+)\s*$/) {
$_ = $';
} elsif(/^\(|\)/) {
$_ = $';
......
......@@ -17,6 +17,7 @@ CLSID *
LONG *
LPBITMAPINFOHEADER
LPCLSID
LPLONG
LPVOID
PAVIFILE
PAVIFILE *
......@@ -31,3 +32,7 @@ LPCSTR
%void
void
%wstr
LPCWSTR
\ No newline at end of file
......@@ -5,17 +5,16 @@ double
%long
DWORD
HANDLE
INT
LONG
MSVCRT_clock_t
MSVCRT_complex
MSVCRT_size_t
MSVCRT_time_t
ULONG
WCHAR
int
long
size_t
unsigned int
unsigned long
......@@ -73,10 +72,10 @@ unsigned int *
va_list
void *
%str
%ptr --extension
LPSTR
LPCSTR
_beginthread_start_routine_t
_beginthreadex_start_routine_t
%unknown
......@@ -87,8 +86,3 @@ MSVCRT_ldiv_t
void
VOID
%wstr
LPCWSTR
LPWSTR
......@@ -14,7 +14,6 @@ HWND
INT
UINT
ULONG
WORD
%long # --forbidden
......@@ -52,7 +51,6 @@ LPDROPTARGET
LPDWORD
LPENUMFORMATETC *
LPENUMOLEVERB *
LPFILETIME
LPFORMATETC
LPGUID
LPLOCKBYTES *
......@@ -77,7 +75,6 @@ LPUNKNOWN
LPUNKNOWN *
LPVOID
LPVOID *
LPWORD
LPSTORAGE
LPSTREAM *
MULTI_QI *
......
......@@ -19,7 +19,6 @@ LONG
LRESULT
UINT
ULONG
WCHAR
WORD
WPARAM
......
%long
DWORD
%long # --forbidden
HTASK16
......
%long
BOOL
DWORD
HANDLE
WORD
WOW_HANDLE_TYPE
%ptr
LPDWORD
LPVOID
PDWORD
WORD *
%long
BOOL
DWORD
HANDLE
HWND
INT
LONG
UINT
SOCKET
u_long
u_short
%long # --forbidden
SOCKET16
long
%ptr
FARPROC
INT *
LPDWORD
LPINT
LPVOID
LPWSADATA
ULONG *
WIN_hostent *
WIN_protoent *
WIN_servent *
char *
struct netent *
struct sockaddr *
struct timeval *
ws_fd_set32 *
%str
LPCSTR
LPSTR
%void
void
%unknown
struct in_addr
\ No newline at end of file
......@@ -228,14 +228,18 @@ sub parse_spec_file {
my $options = \${$self->{OPTIONS}};
my $output = \${$self->{OUTPUT}};
my $function_arguments = \%{$self->{FUNCTION_ARGUMENTS}};
my $function_ordinal = \%{$self->{FUNCTION_ORDINAL}};
my $function_calling_convention = \%{$self->{FUNCTION_CALLING_CONVENTION}};
my $function_internal_arguments = \%{$self->{FUNCTION_INTERNAL_ARGUMENTS}};
my $function_external_arguments = \%{$self->{FUNCTION_EXTERNAL_ARGUMENTS}};
my $function_internal_ordinal = \%{$self->{FUNCTION_INTERNAL_ORDINAL}};
my $function_external_ordinal = \%{$self->{FUNCTION_EXTERNAL_ORDINAL}};
my $function_internal_calling_convention = \%{$self->{FUNCTION_INTERNAL_CALLING_CONVENTION}};
my $function_external_calling_convention = \%{$self->{FUNCTION_EXTERNAL_CALLING_CONVENTION}};
my $function_internal_name = \%{$self->{FUNCTION_INTERNAL_NAME}};
my $function_external_name = \%{$self->{FUNCTION_EXTERNAL_NAME}};
my $function_stub = \%{$self->{FUNCTION_STUB}};
my $function_forward = \%{$self->{FUNCTION_FORWARD}};
my $function_module = \%{$self->{FUNCTION_MODULE}};
my $function_internal_module = \%{$self->{FUNCTION_INTERNAL_MODULE}};
my $function_external_module = \%{$self->{FUNCTION_EXTERNAL_MODULE}};
my $modules = \%{$self->{MODULES}};
my $module_files = \%{$self->{MODULE_FILES}};
......@@ -283,18 +287,29 @@ sub parse_spec_file {
# FIXME: Internal name existing more than once not handled properly
$$function_internal_name{$external_name} = $internal_name;
$$function_external_name{$internal_name} = $external_name;
$$function_arguments{$internal_name} = $arguments;
$$function_ordinal{$internal_name} = $ordinal;
$$function_calling_convention{$internal_name} = $calling_convention;
if(!$$function_module{$internal_name}) {
$$function_module{$internal_name} = "$module";
} elsif($$function_module{$internal_name} !~ /$module/) {
$$function_internal_arguments{$internal_name} = $arguments;
$$function_external_arguments{$external_name} = $arguments;
$$function_internal_ordinal{$internal_name} = $ordinal;
$$function_external_ordinal{$external_name} = $ordinal;
$$function_internal_calling_convention{$internal_name} = $calling_convention;
$$function_external_calling_convention{$external_name} = $calling_convention;
if(!$$function_internal_module{$internal_name}) {
$$function_internal_module{$internal_name} = "$module";
} elsif($$function_internal_module{$internal_name} !~ /$module/) {
if(0) {
$$output->write("$file: $external_name: the internal function ($internal_name) " .
"already belongs to a module ($$function_module{$internal_name})\n");
"already belongs to a module ($$function_internal_module{$internal_name})\n");
}
$$function_module{$internal_name} .= " & $module";
$$function_internal_module{$internal_name} .= " & $module";
}
if(!$$function_external_module{$external_name}) {
$$function_external_module{$external_name} = "$module";
} elsif($$function_external_module{$external_name} !~ /$module/) {
if(0) {
$$output->write("$file: $internal_name: the external function ($external_name) " .
"already belongs to a module ($$function_external_module{$external_name})\n");
}
$$function_external_module{$external_name} .= " & $module";
}
if(0 && $$options->spec_mismatch) {
......@@ -346,10 +361,17 @@ sub parse_spec_file {
# FIXME: Internal name existing more than once not handled properly
$$function_stub{$internal_name} = 1;
if(!$$function_module{$internal_name}) {
$$function_module{$internal_name} = "$module";
} elsif($$function_module{$internal_name} !~ /$module/) {
$$function_module{$internal_name} .= " & $module";
$$function_internal_ordinal{$internal_name} = $ordinal;
$$function_external_ordinal{$external_name} = $ordinal;
if(!$$function_internal_module{$internal_name}) {
$$function_internal_module{$internal_name} = "$module";
} elsif($$function_internal_module{$internal_name} !~ /$module/) {
$$function_internal_module{$internal_name} .= " & $module";
}
if(!$$function_external_module{$external_name}) {
$$function_external_module{$external_name} = "$module";
} elsif($$function_external_module{$external_name} !~ /$module/) {
$$function_external_module{$external_name} .= " & $module";
}
} elsif(/^(\d+|@)\s+forward(?:\s+(?:-noimport|-norelay|-i386|-ret64))?\s+(\S+)\s+(\S+)\.(\S+)$/) {
$ordinal = $1;
......@@ -381,11 +403,8 @@ sub parse_spec_file {
close(IN);
$$modules{$module}++;
if(defined($module_file)) {
$$module_files{$module} = $module_file;
} else {
$$module_files{$module} = "$module.drv";
}
$$module_files{$module} = $file;
}
sub name {
......@@ -584,23 +603,23 @@ sub module_file {
return $$module_files{$module};
}
sub all_functions {
sub all_internal_functions {
my $self = shift;
my $function_calling_convention = \%{$self->{FUNCTION_CALLING_CONVENTION}};
my $function_internal_calling_convention = \%{$self->{FUNCTION_INTERNAL_CALLING_CONVENTION}};
return sort(keys(%$function_calling_convention));
return sort(keys(%$function_internal_calling_convention));
}
sub all_functions_in_module {
sub all_internal_functions_in_module {
my $self = shift;
my $function_calling_convention = \%{$self->{FUNCTION_CALLING_CONVENTION}};
my $function_module = \%{$self->{FUNCTION_MODULE}};
my $function_internal_calling_convention = \%{$self->{FUNCTION_INTERNAL_CALLING_CONVENTION}};
my $function_internal_module = \%{$self->{FUNCTION_INTERNAL_MODULE}};
my $module = shift;
my @names;
foreach my $name (keys(%$function_calling_convention)) {
if($$function_module{$name} eq $module) {
foreach my $name (keys(%$function_internal_calling_convention)) {
if($$function_internal_module{$name} eq $module) {
push @names, $name;
}
}
......@@ -615,29 +634,47 @@ sub all_functions_stub {
return sort(keys(%$function_stub));
}
sub all_functions_found {
sub all_internal_functions_found {
my $self = shift;
my $function_found = \%{$self->{FUNCTION_FOUND}};
return sort(keys(%$function_found));
}
sub function_ordinal {
sub function_internal_ordinal {
my $self = shift;
my $function_internal_ordinal = \%{$self->{FUNCTION_INTERNAL_ORDINAL}};
my $name = shift;
return $$function_internal_ordinal{$name};
}
sub function_external_ordinal {
my $self = shift;
my $function_external_ordinal = \%{$self->{FUNCTION_EXTERNAL_ORDINAL}};
my $name = shift;
return $$function_external_ordinal{$name};
}
sub function_internal_calling_convention {
my $self = shift;
my $function_ordinal = \%{$self->{FUNCTION_ORDINAL}};
my $function_internal_calling_convention = \%{$self->{FUNCTION_INTERNAL_CALLING_CONVENTION}};
my $name = shift;
return $$function_ordinal{$name};
return $$function_internal_calling_convention{$name};
}
sub function_calling_convention {
sub function_external_calling_convention {
my $self = shift;
my $function_calling_convention = \%{$self->{FUNCTION_CALLING_CONVENTION}};
my $function_external_calling_convention = \%{$self->{FUNCTION_EXTERNAL_CALLING_CONVENTION}};
my $name = shift;
return $$function_calling_convention{$name};
return $$function_external_calling_convention{$name};
}
sub function_external_name {
......@@ -651,11 +688,11 @@ sub function_external_name {
sub is_function {
my $self = shift;
my $function_calling_convention = \%{$self->{FUNCTION_CALLING_CONVENTION}};
my $function_internal_calling_convention = \%{$self->{FUNCTION_INTERNAL_CALLING_CONVENTION}};
my $name = shift;
return $$function_calling_convention{$name};
return $$function_internal_calling_convention{$name};
}
sub is_shared_function {
......@@ -676,22 +713,40 @@ sub found_shared_function {
$$function_shared{$name} = 1;
}
sub function_arguments {
sub function_internal_arguments {
my $self = shift;
my $function_internal_arguments = \%{$self->{FUNCTION_INTERNAL_ARGUMENTS}};
my $name = shift;
return $$function_internal_arguments{$name};
}
sub function_external_arguments {
my $self = shift;
my $function_external_arguments = \%{$self->{FUNCTION_EXTERNAL_ARGUMENTS}};
my $name = shift;
return $$function_external_arguments{$name};
}
sub function_internal_module {
my $self = shift;
my $function_arguments = \%{$self->{FUNCTION_ARGUMENTS}};
my $function_internal_module = \%{$self->{FUNCTION_INTERNAL_MODULE}};
my $name = shift;
return $$function_arguments{$name};
return $$function_internal_module{$name};
}
sub function_module {
sub function_external_module {
my $self = shift;
my $function_module = \%{$self->{FUNCTION_MODULE}};
my $function_external_module = \%{$self->{FUNCTION_EXTERNAL_MODULE}};
my $name = shift;
return $$function_module{$name};
return $$function_external_module{$name};
}
sub function_stub {
......@@ -703,7 +758,7 @@ sub function_stub {
return $$function_stub{$name};
}
sub found_function {
sub found_internal_function {
my $self = shift;
my $function_found = \%{$self->{FUNCTION_FOUND}};
......@@ -712,7 +767,7 @@ sub found_function {
$$function_found{$name}++;
}
sub function_found {
sub internal_function_found {
my $self = shift;
my $function_found = \%{$self->{FUNCTION_FOUND}};
......
......@@ -154,16 +154,16 @@ if($options->global) {
my $nativeapi = 'nativeapi'->new($options, $output, "$winapi_check_dir/nativeapi.dat", "$wine_dir/configure.in", "$wine_dir/include/config.h.in");
for my $name ($win32api->all_functions) {
my $module16 = $win16api->function_module($name);
my $module32 = $win32api->function_module($name);
for my $internal_name ($win32api->all_internal_functions) {
my $module16 = $win16api->function_internal_module($internal_name);
my $module32 = $win32api->function_internal_module($internal_name);
if(defined($module16)) {
$win16api->found_shared_function($name);
$win32api->found_shared_function($name);
$win16api->found_shared_function($internal_name);
$win32api->found_shared_function($internal_name);
if($options->shared) {
$output->write("*.spec: $name: is shared between $module16 (Win16) and $module32 (Win32)\n");
$output->write("*.spec: $internal_name: is shared between $module16 (Win16) and $module32 (Win32)\n");
}
}
}
......@@ -246,7 +246,7 @@ if($options->headers) {
my $statements = shift;
foreach my $winapi (@winapis) {
my $module = $winapi->function_module($internal_name);
my $module = $winapi->function_internal_module($internal_name);
if(!defined($module)) { next }
my $external_name = $winapi->function_external_name($internal_name);
......@@ -340,14 +340,14 @@ foreach my $file (@c_files) {
$win16api->found_type($argument) if $options->win16;
$win32api->found_type($argument) if $options->win32;
}
$win16api->found_function($internal_name) if $options->win16;
$win32api->found_function($internal_name) if $options->win32;
$win16api->found_internal_function($internal_name) if $options->win16;
$win32api->found_internal_function($internal_name) if $options->win32;
}
if($file_type ne "application") {
my $module16 = $win16api->function_module($internal_name);
my $module32 = $win32api->function_module($internal_name);
my $module16 = $win16api->function_internal_module($internal_name);
my $module32 = $win32api->function_internal_module($internal_name);
if(defined($module16)) {
$modules->found_module_in_dir($module16, $file_dir);
......@@ -636,9 +636,9 @@ if($options->global) {
my %module_stub_count16;
my %module_total_count16;
foreach my $name ($win16api->all_functions,$win16api->all_functions_stub) {
foreach my $module (split(/ \& /, $win16api->function_module($name))) {
if($win16api->function_stub($name)) {
foreach my $internal_name ($win16api->all_internal_functions,$win16api->all_functions_stub) {
foreach my $module (split(/ \& /, $win16api->function_internal_module($internal_name))) {
if($win16api->function_stub($internal_name)) {
$module_stub_count16{$module}++;
}
$module_total_count16{$module}++;
......@@ -668,9 +668,9 @@ if($options->global) {
my %module_stub_count32;
my %module_total_count32;
foreach my $name ($win32api->all_functions,$win32api->all_functions_stub) {
foreach my $module (split(/ \& /, $win32api->function_module($name))) {
if($win32api->function_stub($name)) {
foreach my $internal_name ($win32api->all_internal_functions,$win32api->all_functions_stub) {
foreach my $module (split(/ \& /, $win32api->function_internal_module($internal_name))) {
if($win32api->function_stub($internal_name)) {
$module_stub_count32{$module}++;
}
$module_total_count32{$module}++;
......
......@@ -75,7 +75,7 @@ sub check_documentation {
$external_name = $internal_name;
}
if($options->documentation_pedantic) {
if($options->documentation_name) {
my $n = 0;
if((++$n && defined($module16) && defined($external_name16) &&
$external_name16 ne "@" && $documentation !~ /\b\Q$external_name16\E\b/) ||
......@@ -87,17 +87,15 @@ sub check_documentation {
$external_name32 eq "@" && $documentation !~ /\@/))
{
my $external_name = ($external_name16, $external_name32)[($n-1)/2];
$output->write("documentation: wrong or missing name ($external_name) \\\n$documentation\n");
}
} else {
if($documentation !~ /\b(?:\Q$external_name\E|$internal_name|$name1|$name2)\b/) {
$output->write("documentation: wrong or missing name \\\n$documentation\n");
if($options->documentation_pedantic || $documentation !~ /\b(?:$internal_name|$name1|$name2)\b/) {
$output->write("documentation: wrong or missing name ($external_name) \\\n$documentation\n");
}
}
}
if($options->documentation_ordinal) {
if(defined($module16)) {
my $ordinal16 = $win16api->function_ordinal($internal_name);
my $ordinal16 = $win16api->function_internal_ordinal($internal_name);
if(!defined($ordinal16)) {
$output->write("function have no ordinal\n");
......@@ -112,7 +110,7 @@ sub check_documentation {
}
}
if(defined($module32)) {
my $ordinal32 = $win32api->function_ordinal($internal_name);
my $ordinal32 = $win32api->function_internal_ordinal($internal_name);
if(!defined($ordinal32)) {
$output->write("function have no ordinal\n");
......@@ -129,7 +127,7 @@ sub check_documentation {
}
if($options->documentation_pedantic) {
my $ordinal = $win16api->function_ordinal($internal_name);
my $ordinal = $win16api->function_internal_ordinal($internal_name);
if(defined($ordinal) && $documentation !~ /^ \*\s+(?:\@|\w+)(?:\s+[\(\[]\w+\.(?:\@|\d+)[\)\]])+/m) {
$output->write("documentation: pedantic check failed \\\n$documentation\n");
}
......
......@@ -20,11 +20,11 @@ sub check {
}
if($options->declared) {
foreach my $name ($winapi->all_functions) {
if(!$winapi->function_found($name) && !$nativeapi->is_function($name)) {
my $module = $winapi->function_module($name);
$output->write("*.c: $module: $name: ");
$output->write("function declared but not implemented: " . $winapi->function_arguments($name) . "\n");
foreach my $internal_name ($winapi->all_internal_functions) {
if(!$winapi->internal_function_found($internal_name) && !$nativeapi->is_function($internal_name)) {
my $module = $winapi->function_internal_module($internal_name);
$output->write("*.c: $module: $internal_name: ");
$output->write("function declared but not implemented: " . $winapi->function_internal_arguments($internal_name) . "\n");
}
}
}
......
......@@ -14,7 +14,7 @@ sub check_function {
my $nativeapi = shift;
my $winapi = shift;
my $module = $winapi->function_module($internal_name);
my $module = $winapi->function_internal_module($internal_name);
if($winapi->name eq "win16") {
if($winapi->function_stub($internal_name)) {
......@@ -89,8 +89,8 @@ sub check_function {
}
}
my $declared_calling_convention = $winapi->function_calling_convention($internal_name);
my @declared_argument_kinds = split(/\s+/, $winapi->function_arguments($internal_name));
my $declared_calling_convention = $winapi->function_internal_calling_convention($internal_name);
my @declared_argument_kinds = split(/\s+/, $winapi->function_internal_arguments($internal_name));
if($declared_calling_convention =~ /^register|interrupt$/) {
push @declared_argument_kinds, "ptr";
......@@ -122,7 +122,11 @@ sub check_function {
$output->write("function not implemented as vararg\n");
}
} elsif($#argument_types != -1 && $argument_types[$#argument_types] eq "...") {
$output->write("function not declared as vararg\n");
if($#argument_types == 0) {
pop @argument_types;
} else {
$output->write("function not declared as vararg\n");
}
}
if($#argument_types != -1 && $argument_types[$#argument_types] eq "CONTEXT *" &&
......
......@@ -96,6 +96,11 @@ my %options = (
default => 0,
parent => "documentation", description => "check for documentation comment width inconsistances"
},
"documentation-name" => {
default => 1,
parent => "documentation",
description => "check for documentation name inconsistances\n"
},
"documentation-ordinal" => {
default => 0,
parent => "documentation",
......
......@@ -257,7 +257,7 @@ sub parse_c_file {
$arguments =~ y/\t\n/ /;
$arguments =~ s/^\s*(.*?)\s*$/$1/;
if($arguments eq "") { $arguments = "void" }
if($arguments eq "") { $arguments = "..." }
my @argument_types;
my @argument_names;
......
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