Commit d07a646f authored by Patrik Stridvall's avatar Patrik Stridvall Committed by Alexandre Julliard

Several additions and bug fixes.

parent fcef0261
......@@ -12,7 +12,7 @@ require Exporter;
&file_absolutize &file_normalize
&file_type &files_filter
&file_skip &files_skip
&get_spec_files
&get_c_files &get_h_files &get_spec_files
);
@EXPORT_OK = qw(
$current_dir $wine_dir $winapi_dir $winapi_check_dir
......@@ -98,20 +98,27 @@ sub file_normalize {
return $_;
}
sub get_spec_files {
$output->progress("$wine_dir: searching for *.spec");
sub _get_files {
my $extension = shift;
my $type = shift;
$output->progress("$wine_dir: searching for *.$extension");
my @spec_files = map {
my @files = map {
s%^\./%%;
s%^$wine_dir/%%;
if(file_type($_) eq "winelib") {
if(file_type($_) eq $type) {
$_;
} else {
();
}
} split(/\n/, `find $wine_dir -name \\*.spec`);
} split(/\n/, `find $wine_dir -name \\*.$extension`);
return @spec_files;
return @files;
}
sub get_c_files { return _get_files("c", @_); }
sub get_h_files { return _get_files("h", @_); }
sub get_spec_files { return _get_files("spec", @_); }
1;
......@@ -34,11 +34,13 @@ sub new {
my $progress = \${$self->{PROGRESS}};
my $last_progress = \${$self->{LAST_PROGRESS}};
my $last_time = \${$self->{LAST_TIME}};
my $progress_count = \${$self->{PROGRESS_COUNT}};
my $prefix = \${$self->{PREFIX}};
$$progress = "";
$$last_progress = "";
$$last_time = 0;
$$progress_count = 0;
$$prefix = "";
......@@ -107,10 +109,26 @@ sub update_progress {
sub progress {
my $self = shift;
my $progress = \${$self->{PROGRESS}};
my $last_time = \${$self->{LAST_TIME}};
$$progress = shift;
$self->update_progress;
$$last_time = 0;
}
sub lazy_progress {
my $self = shift;
my $progress = \${$self->{PROGRESS}};
my $last_time = \${$self->{LAST_TIME}};
$$progress = shift;
my $time = time();
if($time - $$last_time > 0) {
$self->update_progress;
$$last_time = $time;
}
}
sub prefix {
......
......@@ -50,9 +50,7 @@ BEGIN {
exit 1;
}
push @INC, ($winapi_check_dir, $winapi_dir) if $tool eq "winapi_check";
push @INC, ($winapi_dir, $winapi_check_dir) if $tool eq "winapi_extract";
push @INC, ($winapi_dir, $winapi_check_dir) if $tool eq "winapi_fixup";
push @INC, ($winapi_dir, $winapi_check_dir);
}
1;
......@@ -55,7 +55,7 @@ my %module2type;
{
local $_;
foreach my $spec_file (get_spec_files) {
foreach my $spec_file (get_spec_files("winelib")) {
my $module;
my $type;
......@@ -177,13 +177,15 @@ sub statements_stub {
}
}
my @files = files_skip($options->c_files);
my @c_files = $options->c_files;
@c_files = files_skip(@c_files);
@c_files = files_filter("winelib", @c_files);
my $progress_output;
my $progress_current = 0;
my $progress_max = scalar(@files);
my $progress_max = scalar(@c_files);
foreach my $file (@files) {
foreach my $file (@c_files) {
my %functions;
$progress_current++;
......
......@@ -133,6 +133,10 @@ sub is_allowed_module_in_file {
my $dir = $file;
$dir =~ s/\/[^\/]*$//;
if($dir =~ m%^include%) {
return 1;
}
foreach my $spec_file (sort(keys(%{$$dir2spec_file{$dir}}))) {
if($$spec_file2module{$spec_file} eq $module) {
return 1;
......
package output;
use strict;
my $stdout_isatty = -t STDOUT;
my $stderr_isatty = -t STDERR;
sub new {
my $proto = shift;
my $class = ref($proto) || $proto;
my $self = {};
bless ($self, $class);
my $progress = \${$self->{PROGRESS}};
my $last_progress = \${$self->{LAST_PROGRESS}};
my $progress_count = \${$self->{PROGRESS_COUNT}};
my $prefix = \${$self->{PREFIX}};
$$progress = "";
$$last_progress = "";
$$progress_count = 0;
$$prefix = "";
return $self;
}
sub show_progress {
my $self = shift;
my $progress = \${$self->{PROGRESS}};
my $last_progress = \${$self->{LAST_PROGRESS}};
my $progress_count = \${$self->{PROGRESS_COUNT}};
$$progress_count++;
if($$progress_count > 0 && $$progress && $stderr_isatty) {
print STDERR $$progress;
$$last_progress = $$progress;
}
}
sub hide_progress {
my $self = shift;
my $progress = \${$self->{PROGRESS}};
my $last_progress = \${$self->{LAST_PROGRESS}};
my $progress_count = \${$self->{PROGRESS_COUNT}};
$$progress_count--;
if($$last_progress && $stderr_isatty) {
my $message;
for (1..length($$last_progress)) {
$message .= " ";
}
print STDERR $message;
undef $$last_progress;
}
}
sub update_progress {
my $self = shift;
my $progress = \${$self->{PROGRESS}};
my $last_progress = \${$self->{LAST_PROGRESS}};
my $prefix = "";
my $suffix = "";
if($$last_progress) {
for (1..length($$last_progress)) {
$prefix .= "";
}
my $diff = length($$last_progress)-length($$progress);
if($diff > 0) {
for (1..$diff) {
$suffix .= " ";
}
for (1..$diff) {
$suffix .= "";
}
}
}
print STDERR $prefix . $$progress . $suffix;
$$last_progress = $$progress;
}
sub progress {
my $self = shift;
my $progress = \${$self->{PROGRESS}};
$$progress = shift;
$self->update_progress;
}
sub prefix {
my $self = shift;
my $prefix = \${$self->{PREFIX}};
$$prefix = shift;
}
sub write {
my $self = shift;
my $message = shift;
my $prefix = \${$self->{PREFIX}};
$self->hide_progress if $stdout_isatty;
print $$prefix . $message;
$self->show_progress if $stdout_isatty;
}
1;
......@@ -14,8 +14,6 @@ MSVCRT_time_t
WCHAR
int
long
size_t
time_t
unsigned int
unsigned long
......@@ -56,7 +54,6 @@ bad_typeid *
char *
char **
char ***
double *
exception *
int *
jmp_buf
......@@ -66,13 +63,12 @@ struct _stat *
struct _timeb *
struct _utimbuf *
struct _wfinddata_t *
struct tm *
terminate_function
time_t *
type_info *
unexpected_function
unsigned char *
unsigned int *
unsigned long *
va_list
void *
......
......@@ -84,7 +84,6 @@ REFGUID
REFIID
SNB
STGMEDIUM *
WCHAR *
WORD *
void *
void **
......
......@@ -89,6 +89,10 @@ REFCLSID
REFIID
UINT *
%ptr # --forbidden
int *
%str
LPCSTR
......
......@@ -26,6 +26,10 @@ sub new {
$$name = shift;
my $path = shift;
if($$options->progress) {
$$output->progress("$path: searching for *.api");
}
my @files = map {
s%^\./%%;
$_;
......@@ -33,6 +37,11 @@ sub new {
foreach my $file (@files) {
my $module = $file;
if($$options->progress) {
$$output->lazy_progress("$file");
}
$module =~ s/.*?\/([^\/]*?)\.api$/$1/;
$self->parse_api_file($file,$module);
}
......@@ -289,7 +298,7 @@ sub parse_spec_file {
my $module_file;
if($$options->progress) {
$$output->progress("$file");
$$output->lazy_progress("$file");
}
open(IN, "< $file") || die "$file: $!\n";
......@@ -585,24 +594,6 @@ sub all_declared_types {
return sort(keys(%$translate_argument));
}
sub found_type {
my $self = shift;
my $type_found = \%{$self->{TYPE_FOUND}};
my $name = shift;
$$type_found{$name}++;
}
sub type_found {
my $self = shift;
my $type_found= \%{$self->{TYPE_FOUND}};
my $name = shift;
return $$type_found{$name};
}
sub is_allowed_type_format {
my $self = shift;
my $type_format = \%{$self->{TYPE_FORMAT}};
......@@ -734,13 +725,6 @@ sub all_functions_stub_in_module {
return sort(keys(%{$$function_stub{$module}}));
}
sub all_internal_functions_found {
my $self = shift;
my $function_found = \%{$self->{FUNCTION_FOUND}};
return sort(keys(%$function_found));
}
sub function_internal_ordinal {
my $self = shift;
my $function_internal_ordinal = \%{$self->{FUNCTION_INTERNAL_ORDINAL}};
......@@ -892,24 +876,6 @@ sub is_function_stub_in_module {
return $$function_stub{$module}{$name};
}
sub found_internal_function {
my $self = shift;
my $function_found = \%{$self->{FUNCTION_FOUND}};
my $name = shift;
$$function_found{$name}++;
}
sub internal_function_found {
my $self = shift;
my $function_found = \%{$self->{FUNCTION_FOUND}};
my $name = shift;
return $$function_found{$name};
}
########################################################################
# class methods
#
......
......@@ -22,6 +22,13 @@ sub new {
}
########################################################################
# is_win
#
sub is_win16 { my $self = shift; return defined($self->_module($win16api, @_)); }
sub is_win32 { my $self = shift; return defined($self->_module($win32api, @_)); }
########################################################################
# external_name
#
......@@ -190,6 +197,7 @@ sub prefix {
my $module32 = $self->module32;
my $file = $self->file;
my $function_line = $self->function_line;
my $return_type = $self->return_type;
my $internal_name = $self->internal_name;
my $calling_convention = $self->calling_convention;
......@@ -208,7 +216,12 @@ sub prefix {
push @modules, $module;
$used{$module}++;
}
$prefix .= "$file: ";
$prefix .= "$file:";
if(defined($function_line)) {
$prefix .= "$function_line: ";
} else {
$prefix .= "<>: ";
}
if($#modules >= 0) {
$prefix .= join(" & ", @modules) . ": ";
} else {
......
......@@ -7,12 +7,13 @@ sub check {
my $output = shift;
my $winapi = shift;
my $nativeapi = shift;
my $type_found = shift;
my $winver = $winapi->name;
if($options->argument) {
foreach my $type ($winapi->all_declared_types) {
if(!$winapi->type_found($type) && !$winapi->is_limited_type($type) && $type ne "CONTEXT86 *") {
if(!$$type_found{$type} && !$winapi->is_limited_type($type) && $type ne "CONTEXT86 *") {
$output->write("*.c: $winver: ");
$output->write("type ($type) not used\n");
}
......
......@@ -118,9 +118,12 @@ my %options = (
"implemented" => { default => 0, parent => "local", description => "implemented checking" },
"implemented-win32" => { default => 0, parent => "implemented", description => "implemented as win32 checking" },
"include" => { default => 1, parent => "global", description => "include checking" },
"headers" => { default => 0, parent => "global", description => "headers checking" },
"headers" => { default => 0, description => "headers checking" },
"headers-duplicated" => { default => 0, parent => "headers", description => "duplicated function declarations checking" },
"headers-misplaced" => { default => 0, parent => "headers", description => "misplaced function declarations checking" },
"headers-needed" => { default => 1, parent => "headers", description => "headers needed checking" },
"headers-unused" => { default => 0, parent => "headers", description => "headers unused checking" },
);
my %short_options = (
......@@ -147,6 +150,7 @@ sub new {
my $h_files = \@{$self->{H_FILES}};
my $module = \${$self->{MODULE}};
my $global = \${$self->{GLOBAL}};
my $headers = \${$self->{HEADERS}};
my @files;
......@@ -285,11 +289,14 @@ sub new {
}
}
if($#h_files >= 0) {
$$headers = 1;
}
if($#c_files == -1 && $#h_files == -1 &&
($#paths == -1 || ($#paths == 0 && $paths[0] eq $wine_dir)))
{
@paths = ".";
push @h_files, "$wine_dir/include";
} else {
$$global = 0;
}
......@@ -308,8 +315,8 @@ sub new {
} split(/\n/, `$c_command`));
}
if($#h_files != -1) {
my $h_command = "find " . join(" ", @h_files) . " -name \\*.h";
if($#paths != -1 || $#h_files != -1) {
my $h_command = "find " . join(" ", @paths, @h_files) . " -name \\*.h";
my %found;
@$h_files = sort(map {
......
......@@ -62,8 +62,9 @@ sub parse_c_file {
$function->file($file);
$function->debug_channels([@$debug_channels]);
$function->documentation($documentation);
$function->documentation_line($documentation_line);
$function->documentation($documentation);
$function->function_line($function_line);
$function->linkage($linkage);
$function->return_type($return_type);
$function->calling_convention($calling_convention);
......@@ -255,8 +256,8 @@ sub parse_c_file {
if($internal_name && $level == 0) {
&$function_end;
}
next;
} elsif(/(extern\s+|static\s+)?((struct\s+|union\s+|enum\s+)?\w+((\s*\*)+\s*|\s+))
next;
} elsif(/(extern\s+|static\s+)?((struct\s+|union\s+|enum\s+|signed\s+|unsigned\s+)?\w+((\s*\*)+\s*|\s+))
((__cdecl|__stdcall|CDECL|VFWAPIV|VFWAPI|WINAPIV|WINAPI|CALLBACK)\s+)?
(\w+(\(\w+\))?)\s*\(([^\)]*)\)\s*(\{|\;)/sx)
{
......
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